function FSS_GetMenus($menutype) { $getmenus = FSS_GetAllMenus(); //echo "<br>Menu Type : $menutype<br>-<br>"; $have = array(); $not = array(); switch ($menutype) { case FSS_IT_KB: $have['view'] = "kb"; $not['layout'] = ""; break; case FSS_IT_FAQ: $have['view'] = "faq"; $not['layout'] = ""; break; case FSS_IT_TEST: $have['view'] = "test"; $not['layout'] = ""; break; case FSS_IT_NEWTICKET: $have['view'] = "ticket"; $have['layout'] = "open"; break; case FSS_IT_VIEWTICKETS: $have['view'] = "ticket"; $not['layout'] = ""; break; case FSS_IT_ANNOUNCE: $have['view'] = "announce"; $not['layout'] = ""; break; case FSS_IT_GLOSSARY: $have['view'] = "glossary"; $not['layout'] = ""; break; case FSS_IT_ADMIN: $have['view'] = "admin"; $not['layout'] = ""; break; default: return array(); } $results = array(); if (count($getmenus) > 0) { foreach ($getmenus as $object) { $linkok = 1; $link = strtolower(substr($object->link, strpos($object->link, "?") + 1)); //echo $link."<br>"; $parts = explode("&", $link); $inlink = array(); foreach ($parts as $part) { list($key, $value) = explode("=", $part); $inlink[$key] = $value; if (array_key_exists($key, $not)) { //echo "Has ".$key."<br>"; $linkok = 0; } } foreach ($have as $key => $value) { if (!array_key_exists($key, $inlink)) { //echo "Doesnt have ".$key."<br>"; $linkok = 0; } else { if ($inlink[$key] != $value) { //echo "Value mismatch for ".$key." - " . $value . " should be " . $inlink[$key] . "<br>"; $linkok = 0; } } } if ($linkok) { $results[] = $object; //echo "VALID : " . $link . "<br>"; } } } return $results; }
function ValidateMenuLinks() { $allmenus = FSS_GetAllMenus(); $basemenus = array(); if (count($allmenus) > 0) { foreach ($allmenus as $allmenu) { $basemenus[$allmenu->id] = $allmenu; } } //print_r($basemenus); //print_r($this->menus); if (count($this->menus) > 0) { foreach ($this->menus as &$menu) { if ($menu['itemtype'] == FSS_IT_LINK) { continue; } $itemid = $menu['itemid']; if ($menu['link'] != "") { if (array_key_exists($itemid, $basemenus)) { if ($basemenus[$itemid]->link != $menu['link']) { //echo "Not using $itemid, link different<br>"; $menu['link'] = ""; $menu['itemid'] = 0; } } else { //echo "Not using $itemid, link not found<br>"; $menu['link'] = ""; $menu['itemid'] = 0; } } // menu link as null, find out itemid and link from database and store it $menus = FSS_GetMenus($menu['itemtype']); if ($menu['link'] == "") { if (count($menus) > 0) { /*print_r($menus[0]);*/ $menu['link'] = $menus[0]->link; $menu['itemid'] = $menus[0]->id; $db = JFactory::getDBO(); $id = $menu['id']; $qry = "UPDATE #__fss_main_menu SET link = '" . FSSJ3Helper::getEscaped($db, $menu['link']) . "', itemid = '" . FSSJ3Helper::getEscaped($db, $menu['itemid']) . "' WHERE id = '" . FSSJ3Helper::getEscaped($db, $id) . "'"; $db->setQuery($qry); $db->Query(); //echo $qry."<br>"; } else { $id = $menu['id']; $qry = "UPDATE #__fss_main_menu SET link = '', itemid = 0 WHERE id = '{$id}'"; $db = JFactory::getDBO(); $db->setQuery($qry); $db->Query(); switch ($menu['itemtype']) { case FSS_IT_KB: $menu['link'] = JRoute::_('index.php?option=com_fss&view=kb'); break; case FSS_IT_FAQ: $menu['link'] = JRoute::_('index.php?option=com_fss&view=faq'); break; case FSS_IT_TEST: $menu['link'] = JRoute::_('index.php?option=com_fss&view=test'); break; case FSS_IT_NEWTICKET: $menu['link'] = JRoute::_('index.php?option=com_fss&view=ticket&layout=open'); break; case FSS_IT_VIEWTICKETS: $menu['link'] = JRoute::_('index.php?option=com_fss&view=ticket'); break; case FSS_IT_ANNOUNCE: $menu['link'] = JRoute::_('index.php?option=com_fss&view=announce'); break; case FSS_IT_GLOSSARY: $menu['link'] = JRoute::_('index.php?option=com_fss&view=glossary'); break; case FSS_IT_ADMIN: $menu['link'] = JRoute::_('index.php?option=com_fss&view=admin'); break; case FSS_IT_GROUPS: $menu['link'] = JRoute::_('index.php?option=com_fss&view=admin_groups'); break; } } } } } }