diff --git a/pages/UI.php b/pages/UI.php index 0c1beb251d..3b77f4ce71 100644 --- a/pages/UI.php +++ b/pages/UI.php @@ -7,7 +7,25 @@ require_once('../application/startup.inc.php'); $oContext = new UserContext(); $oAppContext = new ApplicationContext(); -$iActiveNodeId = utils::ReadParam('menu', 1); +$iActiveNodeId = utils::ReadParam('menu', ''); +if (empty($iActiveNodeId)) +{ + // No menu specified, let's get the default one: + // 1) It's a root menu item (parent_id == 0) + // 2) with the lowest rank + $oFilter = DBObjectSearch::FromOQL('SELECT menuNode AS M WHERE M.parent_id = 0'); + if ($oFilter) + { + $oMenuSet = new CMDBObjectSet($oFilter); + while($oMenu = $oMenuSet->Fetch()) + { + $aRanks[$oMenu->GetKey()] = $oMenu->Get('rank'); + } + asort($aRanks); // sort by ascending rank: menuId => rank + $aKeys = array_keys($aRanks); + $iActiveNodeId = array_shift($aKeys); // Takes the first key, i.e. the menuId with the lowest rank + } +} $currentOrganization = utils::ReadParam('org_id', ''); $operation = utils::ReadParam('operation', '');