mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-22 10:08:45 +02:00
- Automatic selection of the default (first) menu.
SVN:code[19]
This commit is contained in:
20
pages/UI.php
20
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', '');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user