mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 10:38:45 +02:00
Manage interdependencies between modules, in the setup
SVN:trunk[552]
This commit is contained in:
@@ -13,7 +13,7 @@ SetupWebPage::AddModule(
|
||||
//
|
||||
'dependencies' => array(
|
||||
'itop-config-mgmt/1.0.0',
|
||||
'itop-ticket/1.0.0',
|
||||
'itop-tickets/1.0.0',
|
||||
),
|
||||
'mandatory' => false,
|
||||
'visible' => true,
|
||||
|
||||
@@ -22,9 +22,4 @@
|
||||
<contact_id>4</contact_id>
|
||||
<role>Support Specialist</role>
|
||||
</lnkCIToContact>
|
||||
<lnkCIToContact alias="lnkCIToContact" id="3">
|
||||
<ci_id>8</ci_id>
|
||||
<contact_id>6</contact_id>
|
||||
<role>Datacenter Network Engineer</role>
|
||||
</lnkCIToContact>
|
||||
</Set>
|
||||
@@ -20,16 +20,6 @@
|
||||
<first_name>Victor</first_name>
|
||||
<employee_id>20100001</employee_id>
|
||||
</Person>
|
||||
<Person alias="Contact" id="1">
|
||||
<name>My last name</name>
|
||||
<status>active</status>
|
||||
<org_id>1</org_id>
|
||||
<email>my.email@foo.org</email>
|
||||
<phone></phone>
|
||||
<location_id>0</location_id>
|
||||
<first_name></first_name>
|
||||
<employee_id></employee_id>
|
||||
</Person>
|
||||
<Person alias="Contact" id="5">
|
||||
<name>Verne</name>
|
||||
<status>active</status>
|
||||
|
||||
@@ -14,6 +14,7 @@ SetupWebPage::AddModule(
|
||||
'dependencies' => array(
|
||||
'itop-config-mgmt/1.0.0',
|
||||
'itop-tickets/1.0.0',
|
||||
'itop-incident-mgmt/1.0.0',
|
||||
),
|
||||
'mandatory' => false,
|
||||
'visible' => true,
|
||||
|
||||
@@ -14,6 +14,7 @@ SetupWebPage::AddModule(
|
||||
'dependencies' => array(
|
||||
'itop-config-mgmt/1.0.0',
|
||||
'itop-tickets/1.0.0',
|
||||
'itop-incident-mgmt/1.0.0',
|
||||
),
|
||||
'mandatory' => false,
|
||||
'visible' => true,
|
||||
|
||||
@@ -12,7 +12,7 @@ SetupWebPage::AddModule(
|
||||
// Setup
|
||||
//
|
||||
'dependencies' => array(
|
||||
//'itop-service-mgmt/1.0.0',
|
||||
'itop-config-mgmt/1.0.0',
|
||||
),
|
||||
'mandatory' => false,
|
||||
'visible' => true,
|
||||
|
||||
@@ -12,6 +12,7 @@ SetupWebPage::AddModule(
|
||||
// Setup
|
||||
//
|
||||
'dependencies' => array(
|
||||
'itop-config-mgmt/1.0.0',
|
||||
),
|
||||
'mandatory' => true,
|
||||
'visible' => true,
|
||||
|
||||
@@ -538,7 +538,7 @@ function GetAvailableModules(SetupWebpage $oP)
|
||||
{
|
||||
clearstatcache();
|
||||
ListModuleFiles('../modules/', $oP);
|
||||
return SetupWebPage::GetModules();
|
||||
return $oP->GetModules();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -756,6 +756,7 @@ function ModulesSelection(SetupWebPage $oP, $aParamValues, $iCurrentStep, $oConf
|
||||
$sRedStar = '<span class="hilite">*</span>';
|
||||
$oP->set_title("Selection of the iTop Modules\n");
|
||||
$oP->add("<h2>Customize your iTop installation to fit your needs</h2>\n");
|
||||
$aAvailableModules = GetAvailableModules($oP);
|
||||
|
||||
// Form goes here
|
||||
$oP->add("<fieldset><legend>Select the iTop modules you want to install:</legend>\n");
|
||||
@@ -768,7 +769,6 @@ function ModulesSelection(SetupWebPage $oP, $aParamValues, $iCurrentStep, $oConf
|
||||
// Make sure it gets initialized as an array
|
||||
$aSelectedModules = array();
|
||||
}
|
||||
$aAvailableModules = GetAvailableModules($oP);
|
||||
foreach($aAvailableModules as $sModuleId => $aModule)
|
||||
{
|
||||
$sModuleLabel = $aModule['label'];
|
||||
|
||||
@@ -283,9 +283,54 @@ table.formTable {
|
||||
}
|
||||
}
|
||||
}
|
||||
public static function GetModules()
|
||||
public function GetModules()
|
||||
{
|
||||
return self::$m_aModules;
|
||||
// Order the modules to take into account their inter-dependencies
|
||||
$aDependencies = array();
|
||||
foreach(self::$m_aModules as $sId => $aModule)
|
||||
{
|
||||
$aDependencies[$sId] = $aModule['dependencies'];
|
||||
}
|
||||
$aOrderedModules = array();
|
||||
$iLoopCount = 1;
|
||||
while(($iLoopCount < count(self::$m_aModules)) && (count($aDependencies) > 0) )
|
||||
{
|
||||
foreach($aDependencies as $sId => $aRemainingDeps)
|
||||
{
|
||||
$bDependenciesSolved = true;
|
||||
foreach($aRemainingDeps as $sDepId)
|
||||
{
|
||||
if (!in_array($sDepId, $aOrderedModules))
|
||||
{
|
||||
$bDependenciesSolved = false;
|
||||
}
|
||||
}
|
||||
if ($bDependenciesSolved)
|
||||
{
|
||||
$aOrderedModules[] = $sId;
|
||||
unset($aDependencies[$sId]);
|
||||
}
|
||||
}
|
||||
$iLoopCount++;
|
||||
}
|
||||
if (count($aDependencies) >0)
|
||||
{
|
||||
$sHtml = "<ul><b>Warning: the following modules have unmet dependencies, and have been ignored:</b>\n";
|
||||
foreach($aDependencies as $sId => $aDeps)
|
||||
{
|
||||
$aModule = self::$m_aModules[$sId];
|
||||
$sHtml.= "<li>{$aModule['label']} (id: $sId), depends on: ".implode(', ', $aDeps)."</li>";
|
||||
}
|
||||
$sHtml .= "</ul>\n";
|
||||
$this->warning($sHtml);
|
||||
}
|
||||
// Return the ordered list, so that the dependencies are met...
|
||||
$aResult = array();
|
||||
foreach($aOrderedModules as $sId)
|
||||
{
|
||||
$aResult[$sId] = self::$m_aModules[$sId];
|
||||
}
|
||||
return $aResult;
|
||||
}
|
||||
|
||||
} // End of class
|
||||
|
||||
Reference in New Issue
Block a user