Prechádzať zdrojové kódy

Compiler: added the flag enable_admin_only for the menus

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1944 a333f486-631f-4898-b8df-5754b55c2be0
romainq 13 rokov pred
rodič
commit
45640aa2f4
1 zmenil súbory, kde vykonal 15 pridanie a 1 odobranie
  1. 15 1
      setup/compiler.class.inc.php

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

@@ -868,7 +868,21 @@ EOF;
 				$sNewMenu = "new MenuGroup('$sMenuId', $fRank);";
 			}
 		}
-		$sPHP = "\$__comp_menus__['$sMenuId'] = $sNewMenu\n";
+		$sIndent = '  ';
+		$sPHPMenu = "\$__comp_menus__['$sMenuId'] = $sNewMenu";
+
+		$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";
+			$sPHP .= $sIndent."}\n";
+		}
+		else
+		{
+			$sPHP = $sIndent."$sPHPMenu\n";
+		}
 
 		file_put_contents($sResFile, $sPHP, FILE_APPEND);
 	}