/** * * Get K2 category children * @param int $catid * @param boolean $clear if true return array which is removed value construction * @return array */ public static function getK2CategoryChildren($catid, $clear = false) { static $array = array(); if ($clear) { $array = array(); } $user = JFactory::getUser(); $aid = $user->get('aid') ? $user->get('aid') : 1; $catid = (int) $catid; $db = JFactory::getDBO(); $query = "SELECT * FROM #__k2_categories WHERE parent={$catid} AND published=1 AND trash=0 AND access<={$aid} ORDER BY ordering "; $db->setQuery($query); $rows = $db->loadObjectList(); foreach ($rows as $row) { array_push($array, $row->id); if (modJABulletin::hasK2Children($row->id)) { modJABulletin::getK2CategoryChildren($row->id); } } return $array; }