Jelajahi Sumber

Compiler: discard empty menu groups

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@2090 a333f486-631f-4898-b8df-5754b55c2be0
romainq 13 tahun lalu
induk
melakukan
dfaff8dbe0
1 mengubah file dengan 10 tambahan dan 1 penghapusan
  1. 10 1
      setup/compiler.class.inc.php

+ 10 - 1
setup/compiler.class.inc.php

@@ -122,13 +122,14 @@ class MFCompiler
 EOF;
 				// Preliminary: determine parent menus not defined within the current module
 				$aMenusToLoad = array();
-
+				$aParentMenus = array();
 				foreach($aMenusByModule[$sModuleName] as $sMenuId)
 				{
 					$oMenuNode = $aMenuNodes[$sMenuId];
 					if ($sParent = $oMenuNode->GetChildText('parent', null))
 					{
 						$aMenusToLoad[] = $sParent;
+						$aParentMenus[] = $sParent;
 					}
 					// Note: the order matters: the parents must be defined BEFORE
 					$aMenusToLoad[] = $sMenuId;
@@ -137,6 +138,14 @@ EOF;
 				foreach($aMenusToLoad as $sMenuId)
 				{
 					$oMenuNode = $aMenuNodes[$sMenuId];
+					if ($oMenuNode->getAttribute("xsi:type") == 'MenuGroup')
+					{
+						if (!in_array($oMenuNode->getAttribute("id"), $aParentMenus))
+						{
+							// Discard empty menu groups
+							continue;
+						}
+					}
 					try
 					{
 						$sCompiledCode .= $this->CompileMenu($oMenuNode, $sRelativeDir, $oP);