From 1241592fee11a9ce11569aa502fea03bfa8a7378 Mon Sep 17 00:00:00 2001 From: Romain Quetiez Date: Thu, 5 Apr 2012 09:16:38 +0000 Subject: [PATCH] Compiler: added the flag enable_admin_only for the menus SVN:trunk[1944] --- setup/compiler.class.inc.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/setup/compiler.class.inc.php b/setup/compiler.class.inc.php index 7c85e3f4d..0bb393a1b 100644 --- a/setup/compiler.class.inc.php +++ b/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); }