- Automatic selection of the default (first) menu.

SVN:code[19]
This commit is contained in:
Denis Flaven
2009-03-30 11:35:38 +00:00
parent 36bf4136b9
commit 32ab1cd1c1

View File

@@ -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', '');