public static function getRandomCategory($parentid, $ordering = ' ORDER BY RAND()')
{
$db = Factory::getDBO();
$groups = Factory::getUser()->getAuthorisedViewLevels();
if (count($groups)) {
$access = ' AND a.access IN(' . implode(',', $groups) . ')';
} else {
$access = '';
}
$query = 'SELECT a.id, a.extid' . ' FROM #__phocagallery_categories AS a' . ' WHERE a.parent_id = ' . (int) $parentid . ' AND a.published = 1 ' . $access . $ordering;
$db->setQuery($query);
$images = $db->loadObjectList();
return $images;
}