From a89bca4626b350951e01efffa8c491eb3bbeda65 Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 20 Feb 2019 14:57:39 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B01975=20-=20Fix:=20Change=20Menu=20rights?= =?UTF-8?q?=20to=20"Admin=20only"=20leads=20in=20crash=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/expressioncache.class.inc.php | 1 + setup/compiler.class.inc.php | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/core/expressioncache.class.inc.php b/core/expressioncache.class.inc.php index d15d477c1..37814442f 100644 --- a/core/expressioncache.class.inc.php +++ b/core/expressioncache.class.inc.php @@ -78,6 +78,7 @@ EOF; } EOF; + SetupUtils::builddir(dirname($sFilePath)); file_put_contents($sFilePath, $content); } } diff --git a/setup/compiler.class.inc.php b/setup/compiler.class.inc.php index c7f1477c2..13d75c8cb 100644 --- a/setup/compiler.class.inc.php +++ b/setup/compiler.class.inc.php @@ -333,8 +333,9 @@ EOF; $aMenusToLoad[] = $sMenuId; } $aMenusToLoad = array_unique($aMenusToLoad); - $aMenusForAll = array(); - $aMenusForAdmins = array(); + $aMenuLinesForAll = array(); + $aMenuLinesForAdmins = array(); + $aAdminMenus = array(); foreach($aMenusToLoad as $sMenuId) { $oMenuNode = $aMenuNodes[$sMenuId]; @@ -365,25 +366,27 @@ EOF; { throw new Exception("Failed to process menu '$sMenuId', from '$sModuleRootDir': ".$e->getMessage()); } - if ($oMenuNode->GetChildText('enable_admin_only') == '1') + $sParent = $oMenuNode->GetChildText('parent', null); + if (($oMenuNode->GetChildText('enable_admin_only') == '1') || isset($aAdminMenus[$sParent])) { - $aMenusForAdmins = array_merge($aMenusForAdmins, $aMenuLines); + $aMenuLinesForAdmins = array_merge($aMenuLinesForAdmins, $aMenuLines); + $aAdminMenus[$oMenuNode->getAttribute("id")] = true; } else { - $aMenusForAll = array_merge($aMenusForAll, $aMenuLines); + $aMenuLinesForAll = array_merge($aMenuLinesForAll, $aMenuLines); } } $sIndent = "\t\t"; - foreach ($aMenusForAll as $sPHPLine) + foreach ($aMenuLinesForAll as $sPHPLine) { $sCompiledCode .= $sIndent.$sPHPLine."\n"; } - if (count($aMenusForAdmins) > 0) + if (count($aMenuLinesForAdmins) > 0) { $sCompiledCode .= $sIndent."if (UserRights::IsAdministrator())\n"; $sCompiledCode .= $sIndent."{\n"; - foreach ($aMenusForAdmins as $sPHPLine) + foreach ($aMenuLinesForAdmins as $sPHPLine) { $sCompiledCode .= $sIndent."\t".$sPHPLine."\n"; }