diff --git a/application/menunode.class.inc.php b/application/menunode.class.inc.php index b0d453d2d..73ef30a34 100644 --- a/application/menunode.class.inc.php +++ b/application/menunode.class.inc.php @@ -586,6 +586,10 @@ class OQLMenuNode extends MenuNode public function SetParameters($aParams) { $this->m_aParams = $aParams; + foreach($aParams as $sKey => $value) + { + $this->aReflectionProperties[$sKey] = $value; + } } public function RenderContent(WebPage $oPage, $aExtraParams = array()) diff --git a/datamodel/itop-change-mgmt-1.0.0/datamodel.itop-change-mgmt.xml b/datamodel/itop-change-mgmt-1.0.0/datamodel.itop-change-mgmt.xml index f2809c506..8fa7b0d08 100644 --- a/datamodel/itop-change-mgmt-1.0.0/datamodel.itop-change-mgmt.xml +++ b/datamodel/itop-change-mgmt-1.0.0/datamodel.itop-change-mgmt.xml @@ -2985,24 +2985,28 @@
diff --git a/datamodel/itop-change-mgmt-1.0.0/main.itop-change-mgmt.php b/datamodel/itop-change-mgmt-1.0.0/main.itop-change-mgmt.php index 75755c5ff..f1ac92b4b 100644 --- a/datamodel/itop-change-mgmt-1.0.0/main.itop-change-mgmt.php +++ b/datamodel/itop-change-mgmt-1.0.0/main.itop-change-mgmt.php @@ -14,17 +14,4 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -$oMyMenuGroup = new MenuGroup('ChangeManagement', 50 /* fRank */); -new TemplateMenuNode('Change:Overview', dirname(__FILE__).'/overview.html', $oMyMenuGroup->GetIndex() /* oParent */, 0 /* fRank */); -new NewObjectMenuNode('NewChange', 'Change', $oMyMenuGroup->GetIndex(), 1 /* fRank */); -new SearchMenuNode('SearchChanges', 'Change', $oMyMenuGroup->GetIndex(), 2 /* fRank */); -$oShortcutNode = new TemplateMenuNode('Change:Shortcuts', '', $oMyMenuGroup->GetIndex(), 3 /* fRank */); -$oNode = new OQLMenuNode('MyChanges', 'SELECT Change WHERE agent_id = :current_contact_id AND status NOT IN ("closed", "resolved")', $oShortcutNode->GetIndex(), 1 /* fRank */); -$oNode->SetParameters(array('auto_reload' => 'fast')); -$oNode = new OQLMenuNode('Changes', 'SELECT Change WHERE status != "closed"', $oShortcutNode->GetIndex(), 2 /* fRank */); -$oNode->SetParameters(array('auto_reload' => 'fast')); -$oNode = new OQLMenuNode('WaitingApproval', 'SELECT ApprovedChange WHERE status IN ("plannedscheduled")', $oShortcutNode->GetIndex(), 3 /* fRank */); -$oNode->SetParameters(array('auto_reload' => 'fast')); -$oNode = new OQLMenuNode('WaitingAcceptance', 'SELECT NormalChange WHERE status IN ("new")', $oShortcutNode->GetIndex(), 4 /* fRank */); -$oNode->SetParameters(array('auto_reload' => 'fast')); ?> diff --git a/datamodel/itop-config-mgmt-1.0.0/main.itop-config-mgmt.php b/datamodel/itop-config-mgmt-1.0.0/main.itop-config-mgmt.php index 86c4547cc..3615edb81 100644 --- a/datamodel/itop-config-mgmt-1.0.0/main.itop-config-mgmt.php +++ b/datamodel/itop-config-mgmt-1.0.0/main.itop-config-mgmt.php @@ -22,43 +22,4 @@ MetaModel::RegisterRelation("depends on", array("description"=>"That impacts ", // choice 'All Organizations' will always be available in the menu ApplicationMenu::SetFavoriteSiloQuery('SELECT Organization'); -$oAdminMenu = new MenuGroup('DataAdministration', 70 /* fRank */, 'Organization', UR_ACTION_MODIFY, UR_ALLOWED_YES|UR_ALLOWED_DEPENDS); -$iAdminGroup = $oAdminMenu->GetIndex(); - -new WebPageMenuNode('Audit', utils::GetAbsoluteUrlAppRoot().'pages/audit.php', $iAdminGroup, 33 /* fRank */); - -$oTypologyNode = new TemplateMenuNode('Catalogs', '', $iAdminGroup, 50 /* fRank */); -$iTopology = $oTypologyNode->GetIndex(); -new OQLMenuNode('Organization', 'SELECT Organization', $iTopology, 10 /* fRank */, true /* bSearch */); -new OQLMenuNode('Application', 'SELECT Application', $iTopology, 20 /* fRank */); -new OQLMenuNode('DBServer', 'SELECT DBServer', $iTopology, 40 /* fRank */); - - -$oConfigManagementGroup = new MenuGroup('ConfigManagement', 20 /* fRank */); - -// Create an entry, based on a custom template, for the Configuration management overview, under the top-level group -new TemplateMenuNode('ConfigManagementOverview', dirname(__FILE__).'/overview.html', $oConfigManagementGroup->GetIndex(), 0 /* fRank */); - - -$oContactNode = new TemplateMenuNode('Contact', dirname(__FILE__).'/contacts_menu.html', $oConfigManagementGroup->GetIndex(), 1 /* fRank */); -new NewObjectMenuNode('NewContact', 'Contact', $oContactNode->GetIndex(), 1 /* fRank */); -new SearchMenuNode('SearchContacts', 'Contact', $oContactNode->GetIndex(), 2 /* fRank */); - -new OQLMenuNode('Document', 'SELECT Document', $oConfigManagementGroup->GetIndex(), 2 /* fRank */, true /* bSearch */); -new OQLMenuNode('Location', 'SELECT Location', $oConfigManagementGroup->GetIndex(), 3 /* fRank */, true /* bSearch */); -new OQLMenuNode('Group', 'SELECT Group', $oConfigManagementGroup->GetIndex(), 4 /* fRank */, true /* bSearch */); - - -$oCINode = new TemplateMenuNode('ConfigManagementCI', dirname(__FILE__).'/cis_menu.html', $oConfigManagementGroup->GetIndex(), 5 /* fRank */); -new NewObjectMenuNode('NewCI', 'FunctionalCI', $oCINode->GetIndex(), 0 /* fRank */); -new SearchMenuNode('SearchCIs', 'FunctionalCI', $oCINode->GetIndex(), 1 /* fRank */); - -$oShortcutsNode = new TemplateMenuNode('ConfigManagement:Shortcuts', '', $oConfigManagementGroup->GetIndex(), 6 /* fRank */); -new OQLMenuNode('Server', 'SELECT Server', $oShortcutsNode->GetIndex(), 1 /* fRank */); -new OQLMenuNode('NetworkDevice', 'SELECT NetworkDevice', $oShortcutsNode->GetIndex(), 2 /* fRank */); -new OQLMenuNode('Printer', 'SELECT Printer', $oShortcutsNode->GetIndex(), 3 /* fRank */); -new OQLMenuNode('PC', 'SELECT PC', $oShortcutsNode->GetIndex(), 4 /* fRank */); -new OQLMenuNode('BusinessProcess', 'SELECT BusinessProcess', $oShortcutsNode->GetIndex(), 5 /* fRank */); -new OQLMenuNode('ApplicationSolution', 'SELECT ApplicationSolution', $oShortcutsNode->GetIndex(), 6 /* fRank */); - ?> diff --git a/datamodel/itop-incident-mgmt-1.0.0/datamodel.itop-incident-mgmt.xml b/datamodel/itop-incident-mgmt-1.0.0/datamodel.itop-incident-mgmt.xml index 0d6121cb8..fe0149aa5 100644 --- a/datamodel/itop-incident-mgmt-1.0.0/datamodel.itop-incident-mgmt.xml +++ b/datamodel/itop-incident-mgmt-1.0.0/datamodel.itop-incident-mgmt.xml @@ -734,18 +734,21 @@ diff --git a/datamodel/itop-incident-mgmt-1.0.0/main.itop-incident-mgmt.php b/datamodel/itop-incident-mgmt-1.0.0/main.itop-incident-mgmt.php index c953bb266..f1ac92b4b 100644 --- a/datamodel/itop-incident-mgmt-1.0.0/main.itop-incident-mgmt.php +++ b/datamodel/itop-incident-mgmt-1.0.0/main.itop-incident-mgmt.php @@ -14,16 +14,4 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -$oMyMenuGroup = new MenuGroup('IncidentManagement', 40 /* fRank */); -new TemplateMenuNode('Incident:Overview', dirname(__FILE__).'/overview.html', $oMyMenuGroup->GetIndex() /* oParent */, 0 /* fRank */); -new NewObjectMenuNode('NewIncident', 'Incident', $oMyMenuGroup->GetIndex(), 1 /* fRank */); -new SearchMenuNode('SearchIncidents', 'Incident', $oMyMenuGroup->GetIndex(), 2 /* fRank */); -$oShortcutNode = new TemplateMenuNode('Incident:Shortcuts', '', $oMyMenuGroup->GetIndex(), 3 /* fRank */); -$oNode = new OQLMenuNode('Incident:MyIncidents', 'SELECT Incident WHERE agent_id = :current_contact_id AND status NOT IN ("closed", "resolved")', $oShortcutNode->GetIndex(), 1 /* fRank */); -$oNode->SetParameters(array('auto_reload' => 'fast')); -$oNode = new OQLMenuNode('Incident:EscalatedIncidents', 'SELECT Incident WHERE status IN ("escalated_tto", "escalated_ttr")', $oShortcutNode->GetIndex(), 2 /* fRank */); -$oNode->SetParameters(array('auto_reload' => 'fast')); -$oNode = new OQLMenuNode('Incident:OpenIncidents', 'SELECT Incident WHERE status IN ("new", "assigned", "escalated_tto", "escalated_ttr", "resolved")', $oShortcutNode->GetIndex(), 3 /* fRank */); -$oNode->SetParameters(array('auto_reload' => 'standard')); - ?> diff --git a/datamodel/itop-knownerror-mgmt-1.0.0/main.itop-knownerror-mgmt.php b/datamodel/itop-knownerror-mgmt-1.0.0/main.itop-knownerror-mgmt.php index f620ad82c..f1ac92b4b 100644 --- a/datamodel/itop-knownerror-mgmt-1.0.0/main.itop-knownerror-mgmt.php +++ b/datamodel/itop-knownerror-mgmt-1.0.0/main.itop-knownerror-mgmt.php @@ -14,11 +14,4 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -$oMyMenuGroup = new MenuGroup('ProblemManagement', 42 /* fRank */); -$iIndex = $oMyMenuGroup->GetIndex(); -new NewObjectMenuNode('NewError', 'KnownError', $iIndex, 3 /* fRank */); -new SearchMenuNode('SearchError', 'KnownError', $iIndex, 4 /* fRank */); -$oShortcutNode = new TemplateMenuNode('Problem:Shortcuts', '', $iIndex, 5 /* fRank */); -new OQLMenuNode('Problem:KnownErrors', 'SELECT KnownError', $oShortcutNode->GetIndex(), 3 /* fRank */,true /*bsearch */); - ?> diff --git a/datamodel/itop-problem-mgmt-1.0.0/main.itop-problem-mgmt.php b/datamodel/itop-problem-mgmt-1.0.0/main.itop-problem-mgmt.php index e810a97f1..f1ac92b4b 100644 --- a/datamodel/itop-problem-mgmt-1.0.0/main.itop-problem-mgmt.php +++ b/datamodel/itop-problem-mgmt-1.0.0/main.itop-problem-mgmt.php @@ -14,13 +14,4 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -$oMyMenuGroup = new MenuGroup('ProblemManagement', 42 /* fRank */); // Will create if it does not exist -$iIndex = $oMyMenuGroup->GetIndex(); -new TemplateMenuNode('Problem:Overview', dirname(__FILE__).'/overview.html', $iIndex /* oParent */, 0 /* fRank */); -new NewObjectMenuNode('NewProblem', 'Problem', $iIndex, 1 /* fRank */); -new SearchMenuNode('SearchProblems', 'Problem', $iIndex, 2 /* fRank */); -$oShortcutNode = new TemplateMenuNode('Problem:Shortcuts', '', $iIndex, 5 /* fRank */); -new OQLMenuNode('Problem:MyProblems', 'SELECT Problem WHERE agent_id = :current_contact_id AND status NOT IN ("closed", "resolved")', $oShortcutNode->GetIndex(), 1 /* fRank */); -new OQLMenuNode('Problem:OpenProblems', 'SELECT Problem WHERE status IN ("new", "assigned", "resolved")', $oShortcutNode->GetIndex(), 2 /* fRank */); - ?> diff --git a/datamodel/itop-request-mgmt-1.0.0/datamodel.itop-request-mgmt.xml b/datamodel/itop-request-mgmt-1.0.0/datamodel.itop-request-mgmt.xml index 0a42b474b..a1a5e2e6d 100644 --- a/datamodel/itop-request-mgmt-1.0.0/datamodel.itop-request-mgmt.xml +++ b/datamodel/itop-request-mgmt-1.0.0/datamodel.itop-request-mgmt.xml @@ -696,18 +696,21 @@ diff --git a/datamodel/itop-request-mgmt-1.0.0/main.itop-request-mgmt.php b/datamodel/itop-request-mgmt-1.0.0/main.itop-request-mgmt.php index 3f990c4c9..f1ac92b4b 100644 --- a/datamodel/itop-request-mgmt-1.0.0/main.itop-request-mgmt.php +++ b/datamodel/itop-request-mgmt-1.0.0/main.itop-request-mgmt.php @@ -14,17 +14,4 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -$oMyMenuGroup = new MenuGroup('RequestManagement', 30 /* fRank */); - -new TemplateMenuNode('UserRequest:Overview', dirname(__FILE__).'/overview.html', $oMyMenuGroup->GetIndex() /* oParent */, 0 /* fRank */); -new NewObjectMenuNode('NewUserRequest', 'UserRequest', $oMyMenuGroup->GetIndex(), 1 /* fRank */); -new SearchMenuNode('SearchUserRequests', 'UserRequest', $oMyMenuGroup->GetIndex(), 2 /* fRank */); -$oShortcutNode = new TemplateMenuNode('UserRequest:Shortcuts', '', $oMyMenuGroup->GetIndex(), 3 /* fRank */); -$oNode = new OQLMenuNode('UserRequest:MyRequests', 'SELECT UserRequest WHERE agent_id = :current_contact_id AND status NOT IN ("closed","resolved")', $oShortcutNode->GetIndex(), 1 /* fRank */); -$oNode->SetParameters(array('auto_reload' => 'fast')); -$oNode = new OQLMenuNode('UserRequest:EscalatedRequests', 'SELECT UserRequest WHERE status IN ("escalated_tto", "escalated_ttr")', $oShortcutNode->GetIndex(), 2 /* fRank */); -$oNode->SetParameters(array('auto_reload' => 'fast')); -$oNode = new OQLMenuNode('UserRequest:OpenRequests', 'SELECT UserRequest WHERE status IN ("new", "assigned", "escalated_tto", "escalated_ttr", "frozen", "resolved")', $oShortcutNode->GetIndex(), 3 /* fRank */); -$oNode->SetParameters(array('auto_reload' => 'fast')); - ?> diff --git a/datamodel/itop-service-mgmt-1.0.0/main.itop-service-mgmt.php b/datamodel/itop-service-mgmt-1.0.0/main.itop-service-mgmt.php index f00a931c8..f1ac92b4b 100644 --- a/datamodel/itop-service-mgmt-1.0.0/main.itop-service-mgmt.php +++ b/datamodel/itop-service-mgmt-1.0.0/main.itop-service-mgmt.php @@ -14,14 +14,4 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -$oServiceManagementGroup = new MenuGroup('ServiceManagement', 60 /* fRank */); -$iRank = 0; -new TemplateMenuNode('Service:Overview', dirname(__FILE__).'/overview.html', $oServiceManagementGroup->GetIndex() /* oParent */, $iRank++ /* fRank */); -new OQLMenuNode('ProviderContract', 'SELECT ProviderContract', $oServiceManagementGroup->GetIndex(), $iRank++,true /* bsearch */); -new OQLMenuNode('CustomerContract', 'SELECT CustomerContract', $oServiceManagementGroup->GetIndex(), $iRank++,true /* bsearch */); -new OQLMenuNode('Service', 'SELECT Service', $oServiceManagementGroup->GetIndex(), $iRank++,true /* bsearch */); -new OQLMenuNode('ServiceSubcategory', 'SELECT ServiceSubcategory', $oServiceManagementGroup->GetIndex(), $iRank++,true /* bsearch */); -new OQLMenuNode('SLA', 'SELECT SLA', $oServiceManagementGroup->GetIndex(), $iRank++,true /* bsearch */); -new OQLMenuNode('SLT', 'SELECT SLT', $oServiceManagementGroup->GetIndex(), $iRank++,true /* bsearch */); - ?> diff --git a/setup/compiler.class.inc.php b/setup/compiler.class.inc.php index 0bb393a1b..774d4bbda 100644 --- a/setup/compiler.class.inc.php +++ b/setup/compiler.class.inc.php @@ -171,16 +171,29 @@ EOF; EOF; file_put_contents($sResultFile, $sMenusHeader, FILE_APPEND); + // Preliminary: determine parent menus not defined within the current module + $aMenusToLoad = array(); foreach($oMenus as $oMenu) { + if ($oParent = $this->GetOptionalElement($oMenu, 'parent')) + { + $aMenusToLoad[] = $oParent->GetAttribute('value'); + } + // Note: the order matters: the parents must be defined BEFORE + $aMenusToLoad[] = $oMenu->GetAttribute('id'); + } + $aMenusToLoad = array_unique($aMenusToLoad); + foreach($aMenusToLoad as $sMenuId) + { + $oMenu = $this->oFactory->GetMenu($sMenuId); try { $this->CompileMenu($oMenu, $sResultFile, $sRelativeDir, $oP); } catch (ssDOMFormatException $e) { - $sClass = $oClass->getAttribute("name"); - throw new Exception("Failed to process class '$sClass', from '$sModuleRootDir': ".$e->getMessage()); + $sMenu = $oMenu->getAttribute("name"); + throw new Exception("Failed to process menu '$sMenu', from '$sModuleRootDir': ".$e->getMessage()); } } } @@ -868,20 +881,33 @@ EOF; $sNewMenu = "new MenuGroup('$sMenuId', $fRank);"; } } - $sIndent = ' '; - $sPHPMenu = "\$__comp_menus__['$sMenuId'] = $sNewMenu"; + + $sIndent = ''; + $aPHPMenu = array("\$__comp_menus__['$sMenuId'] = $sNewMenu"); + if ($oAutoReload = $this->GetOptionalElement($oMenu, 'auto_reload')) + { + $sAutoReload = addslashes($oAutoReload->GetAttribute("value")); + $aPHPMenu[] = "\$__comp_menus__['$sMenuId']->SetParameters(array('auto_reload' => '$sAutoReload'));"; + } $oAdminOnly = $this->GetOptionalElement($oMenu, 'enable_admin_only'); if ($oAdminOnly && $oAdminOnly->GetAttribute('value') == '1') { $sPHP = $sIndent."if (UserRights::IsAdministrator())\n"; $sPHP .= $sIndent."{\n"; - $sPHP .= $sIndent." $sPHPMenu\n"; + foreach($aPHPMenu as $sPHPLine) + { + $sPHP .= $sIndent." $sPHPLine\n"; + } $sPHP .= $sIndent."}\n"; } else { - $sPHP = $sIndent."$sPHPMenu\n"; + $sPHP = ''; + foreach($aPHPMenu as $sPHPLine) + { + $sPHP .= $sIndent.$sPHPLine."\n"; + } } file_put_contents($sResFile, $sPHP, FILE_APPEND); diff --git a/setup/modelfactory.class.inc.php b/setup/modelfactory.class.inc.php index bf9058900..a8b24d8a2 100644 --- a/setup/modelfactory.class.inc.php +++ b/setup/modelfactory.class.inc.php @@ -1159,6 +1159,31 @@ EOF return $this->_priv_GetNodes($sXPath, $this->oMenus); } + /** + * Get a menu, given its is id + * @param string $sModuleName + * @param bool $bFlattenLayers + * @throws Exception + */ + public function GetMenu($sMenuId, $bFlattenLayers = true) + { + if (!array_key_exists($sMenuId, self::$aLoadedMenus)) + { + return null; + } + $oMenuNode = self::$aLoadedMenus[$sMenuId]; + if ($bFlattenLayers) + { + $sOperation = $oMenuNode->getAttribute('_operation'); + if ($sOperation == 'removed') + { + $oMenuNode = null; + } + } + return $oMenuNode; + } + + public function ApplyChanges() { $oNodes = $this->ListChanges();