N°8190 - Userrights management should not be overridable anymore

This commit is contained in:
Anne-Cath
2025-08-26 09:17:51 +02:00
parent f03b008ebf
commit 20393b55b9
5 changed files with 13 additions and 38 deletions

View File

@@ -2017,10 +2017,7 @@ class Config
$bLoadConfig = false;
}
$this->m_aAddons = array(
// Default AddOn, always present can be moved to an official iTop Module later if needed
'user rights' => 'addons/userrights/userrightsprofile.class.inc.php',
);
$this->m_aAddons = [];
foreach ($this->m_aSettings as $sPropCode => $aSettingInfo)
{
@@ -2148,19 +2145,13 @@ class Config
array('file' => $sConfigFile, 'expected' => '$MySettings'));
}
if (!array_key_exists('addons', $MyModules))
{
throw new ConfigException('Missing item in configuration file',
array('file' => $sConfigFile, 'expected' => '$MyModules[\'addons\']'));
}
if (!array_key_exists('user rights', $MyModules['addons']))
if (!array_key_exists('addons', $MyModules) || !array_key_exists('user rights', $MyModules['addons']))
{
// Add one, by default
$MyModules['addons']['user rights'] = '/addons/userrights/userrightsnull.class.inc.php';
$MyModules['addons']['user rights'] = 'addons/userrights/userrightsprofile.class.inc.php';
$this->m_aAddons = $MyModules['addons'];
}
$this->m_aAddons = $MyModules['addons'];
foreach ($MySettings as $sPropCode => $rawvalue)
{
if ($this->IsProperty($sPropCode))
@@ -2266,7 +2257,11 @@ class Config
public function GetAddons()
{
return $this->m_aAddons;
// if (array_key_exists("user rights", $this->m_aAddons)) {
return $this->m_aAddons;
/* } else {
return array_merge($this->m_aAddons,['user rights' => 'addons/userrights/userrightsprofile.class.inc.php']);
}*/
}
public function SetAddons($aAddons)
@@ -2702,15 +2697,6 @@ class Config
{
fwrite($hFile, "\t'addons' => {$aParserValue['value']},\n");
}
else
{
fwrite($hFile, "\t'addons' => array (\n");
foreach ($this->m_aAddons as $sKey => $sFile)
{
fwrite($hFile, "\t\t'$sKey' => '$sFile',\n");
}
fwrite($hFile, "\t),\n");
}
fwrite($hFile, ");\n");
fwrite($hFile, '?'.'>'); // Avoid perturbing the syntax highlighting !

View File

@@ -701,9 +701,7 @@ class ApplicationInstaller
if ($bOldAddon)
{
// Old version of the add-on for backward compatibility with pre-2.0 data models
$oConfig->SetAddons(array(
'user rights' => 'addons/userrights/userrightsprofile.db.class.inc.php',
));
$oConfig->SetAddons([]);
}
$oProductionEnv = new RunTimeEnvironment($sTargetEnvironment);
@@ -904,9 +902,7 @@ class ApplicationInstaller
if ($bOldAddon)
{
// Old version of the add-on for backward compatibility with pre-2.0 data models
$oConfig->SetAddons(array(
'user rights' => 'addons/userrights/userrightsprofile.db.class.inc.php',
));
$oConfig->SetAddons([]);
}
$oProductionEnv = new RunTimeEnvironment($sTargetEnvironment);
@@ -973,9 +969,7 @@ class ApplicationInstaller
if ($bOldAddon)
{
// Old version of the add-on for backward compatibility with pre-2.0 data models
$oConfig->SetAddons(array(
'user rights' => 'addons/userrights/userrightsprofile.db.class.inc.php',
));
$oConfig->SetAddons([]);
}
$oProductionEnv = new RunTimeEnvironment($sTargetEnvironment);
@@ -1054,9 +1048,7 @@ class ApplicationInstaller
if ($bOldAddon)
{
// Old version of the add-on for backward compatibility with pre-2.0 data models
$oConfig->SetAddons(array(
'user rights' => 'addons/userrights/userrightsprofile.db.class.inc.php',
));
$oConfig->SetAddons([]);
}
// Record which modules are installed...

View File

@@ -187,7 +187,6 @@ CONF;
//add few dynamic configurations in MyModules section
$expected_line = <<< CONF
'addons' => array(
'user rights' => 'addons/userrights/userrightsprofile.class.inc.php',
'user rights2' => '\$_SERVER[\\'TEST\\']'
),
CONF;

View File

@@ -32,6 +32,5 @@ $MyModuleSettings = array(
*
*/
$MyModules = array(
'addons' => array('user rights' => 'addons/userrights/userrightsprofile.class.inc.php'),
);
?>

View File

@@ -32,6 +32,5 @@ $MyModuleSettings = array(
*
*/
$MyModules = array(
'addons' => array('user rights' => 'addons/userrights/userrightsprofile.class.inc.php'),
);
?>