mirror of
https://github.com/Combodo/iTop.git
synced 2026-03-16 14:34:12 +01:00
N°1975 - Fix: Change Menu rights to "Admin only" leads in crash test
This commit is contained in:
@@ -78,6 +78,7 @@ EOF;
|
||||
}
|
||||
EOF;
|
||||
|
||||
SetupUtils::builddir(dirname($sFilePath));
|
||||
file_put_contents($sFilePath, $content);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user