mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-18 23:08:46 +02:00
N°9567 - Extension Mgmt : Run setup
This commit is contained in:
@@ -357,6 +357,9 @@ class ModuleDiscovery
|
||||
{
|
||||
$sDirectory = $sRootDir.'/'.$sRelDir;
|
||||
|
||||
if (!is_dir(utils::RealPath($sDirectory, APPROOT))) {
|
||||
throw new Exception('Data directory ('.$sDirectory.') Does not exist or is outside iTop.');
|
||||
}
|
||||
if ($hDir = opendir($sDirectory)) {
|
||||
// This is the correct way to loop over the directory. (according to the documentation)
|
||||
while (($sFile = readdir($hDir)) !== false) {
|
||||
|
||||
@@ -1576,11 +1576,13 @@ JS
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function AnalyzeInstallation($oWizard, $bAbortOnMissingDependency = false, $aModulesToLoad = null)
|
||||
public static function AnalyzeInstallation($oWizard, $bAbortOnMissingDependency = false, $aModulesToLoad = null, Config $oConfig = null)
|
||||
{
|
||||
require_once(APPROOT.'/setup/moduleinstaller.class.inc.php');
|
||||
|
||||
$oConfig = self::GetConfig($oWizard);
|
||||
if (is_null($oConfig)) {
|
||||
$oConfig = self::GetConfig($oWizard);
|
||||
}
|
||||
|
||||
$aDirsToScan = [$oWizard->GetParameter('source_dir', '')];
|
||||
|
||||
|
||||
@@ -296,7 +296,7 @@ on the page's parameters
|
||||
|
||||
$sOperation = utils::ReadParam('operation');
|
||||
$this->aParameters = utils::ReadParam('_params', [], false, 'raw_data');
|
||||
$this->aSteps = json_decode(utils::ReadParam('_steps', '[]', false, 'raw_data'), true /* bAssoc */);
|
||||
$this->SetSteps(json_decode(utils::ReadParam('_steps', '[]', false, 'raw_data'), true));
|
||||
|
||||
switch ($sOperation) {
|
||||
case 'next':
|
||||
@@ -371,6 +371,11 @@ on the page's parameters
|
||||
return $sOutput;
|
||||
}
|
||||
|
||||
public function SetSteps(array $aSteps): void
|
||||
{
|
||||
$this->aSteps = $aSteps;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sCurrentStepClass
|
||||
* @param string $sCurrentState
|
||||
|
||||
@@ -100,39 +100,29 @@ JS);
|
||||
{
|
||||
$sApplicationUrl = utils::GetAbsoluteUrlModulePage('combodo-data-feature-removal', 'index.php');
|
||||
|
||||
$aRemovedExtensions = json_decode($this->oWizard->GetParameter('removed_extensions', '[]'), true);
|
||||
$aHiddenRemovedExtensionInputs = '';
|
||||
if (!is_array($aRemovedExtensions)) {
|
||||
IssueLog::Warning('Posted removed_extensions is not an array');
|
||||
$aRemovedExtensions = [];
|
||||
}
|
||||
foreach ($aRemovedExtensions as $sExtCode => $sExtLabel) {
|
||||
$sSafeExtCode = utils::HtmlEntities($sExtCode);
|
||||
$aHiddenRemovedExtensionInputs .= <<<INPUT
|
||||
<input type="hidden" name="aRemovedExtensions[$sSafeExtCode]" value="$sExtLabel"/>
|
||||
$aParams = [
|
||||
'selected_modules',
|
||||
'selected_extensions',
|
||||
'display_choices',
|
||||
'added_extensions',
|
||||
'removed_extensions',
|
||||
'extensions_not_uninstallable',
|
||||
];
|
||||
$aHiddenInputs = '';
|
||||
foreach ($aParams as $sParamName) {
|
||||
$sElements = $this->oWizard->GetParameter($sParamName, '[]');
|
||||
$aHiddenInputs .= <<<INPUT
|
||||
<input type="hidden" name="$sParamName" value="$sElements"/>
|
||||
INPUT;
|
||||
}
|
||||
|
||||
$aAddedExtensions = json_decode($this->oWizard->GetParameter('extensions_added', "[]"), true);
|
||||
$aHiddenAddedExtensionInputs = "";
|
||||
if (!is_array($aAddedExtensions)) {
|
||||
IssueLog::Warning('Posted extensions_added is not an array');
|
||||
$aAddedExtensions = [];
|
||||
}
|
||||
foreach ($aAddedExtensions as $sExtCode => $sExtLabel) {
|
||||
$sSafeExtCode = utils::HtmlEntities($sExtCode);
|
||||
$aHiddenAddedExtensionInputs .= <<<INPUT
|
||||
<input type="hidden" name="aAddedExtensions[$sSafeExtCode]" value="$sExtLabel"/>
|
||||
INPUT;
|
||||
}
|
||||
$sUID = Session::Get('setup_token');
|
||||
$oPage->add(
|
||||
<<<HTML
|
||||
<form id="data-feature-removal" class="ibo-setup--wizard ibo-is-hidden" method="post" action="$sApplicationUrl">
|
||||
<input type="hidden" name="operation" value="AnalysisResult"/>
|
||||
<input type="hidden" name="setup_token" value="$sUID"/>
|
||||
$aHiddenRemovedExtensionInputs
|
||||
$aHiddenAddedExtensionInputs
|
||||
$aHiddenInputs
|
||||
</form>
|
||||
HTML
|
||||
);
|
||||
|
||||
@@ -5,8 +5,29 @@
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
class WizStepLandingBeforeAudit extends WizardStep
|
||||
class WizStepLandingBeforeAudit extends WizStepModulesChoice
|
||||
{
|
||||
public function __construct(WizardController $oWizard, $sCurrentState)
|
||||
{
|
||||
$oProductionEnv = new RunTimeEnvironment();
|
||||
$sBuildConfigFile = APPCONF.$oProductionEnv->GetBuildEnv().'/'.ITOP_CONFIG_FILE;
|
||||
$this->oConfig = new Config($sBuildConfigFile);
|
||||
|
||||
$oWizard->SetParameter('previous_version_dir', APPROOT);
|
||||
$oWizard->SetParameter('install_mode', 'upgrade');
|
||||
$oWizard->SetParameter('source_dir', APPROOT.$this->oConfig->Get('source_dir'));
|
||||
$oWizard->SetParameter('graphviz_path', $this->oConfig->Get('graphviz_path'));
|
||||
$oWizard->SetParameter('application_url', $this->oConfig->Get('app_root_url'));
|
||||
$oWizard->SetParameter('datamodel_version', ITOP_CORE_VERSION);
|
||||
$oWizard->SetParameter('upgrade_type', 'use-compatible');
|
||||
|
||||
$oWizard->SaveParameter('use_symbolic_links', MFCompiler::UseSymbolicLinks());
|
||||
$oWizard->SaveParameter('force-uninstall', '');
|
||||
|
||||
// should be done at the end
|
||||
parent::__construct($oWizard, $sCurrentState, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@@ -17,15 +38,54 @@ class WizStepLandingBeforeAudit extends WizardStep
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function UpdateWizardStateAndGetNextStep(bool $bMoveForward = true): WizardState
|
||||
public function UpdateWizardStateAndGetNextStep($bMoveForward = true): WizardState
|
||||
{
|
||||
$this->oWizard->SetParameter('selected_components', '[{"_0":"_0","_1":"_1","_2":"_2","_3":"_3","_4":"_4"},{"_0":"_0"},{"_0":"_0","_0_0":"_0_0"},{"_0":"_0"},{"_0":"_0","_1":"_1"},{"_0":"_0","_1":"_1"}]');
|
||||
$aSteps = json_decode(
|
||||
'[
|
||||
{"class":"WizStepWelcome","state":""},
|
||||
{"class":"WizStepInstallOrUpgrade","state":""},
|
||||
{"class":"WizStepDetectedInfo","state":""},
|
||||
{"class":"WizStepUpgradeMiscParams","state":""},
|
||||
{"class":"WizStepModulesChoice","state":"start_upgrade"},
|
||||
{"class":"WizStepModulesChoice","state":"1"},
|
||||
{"class":"WizStepModulesChoice","state":"2"},
|
||||
{"class":"WizStepModulesChoice","state":"3"}]',
|
||||
true
|
||||
);
|
||||
$this->oWizard->SetSteps($aSteps);
|
||||
$this->aSteps = $aSteps;
|
||||
|
||||
$this->sCurrentState = count($aSteps) - 1;
|
||||
//parent::UpdateWizardStateAndGetNextStep(true);
|
||||
|
||||
$oProductionEnv = new RunTimeEnvironment();
|
||||
$sBuildConfigFile = APPCONF.$oProductionEnv->GetBuildEnv().'/'.ITOP_CONFIG_FILE;
|
||||
@chmod($sBuildConfigFile, 0770); // In case it exists: RWX for owner and group, nothing for others
|
||||
|
||||
$oConfig = new Config($sBuildConfigFile);
|
||||
$this->oWizard->SetParameter('db_server', $oConfig->Get('db_host'));
|
||||
$this->oWizard->SetParameter('db_user', $oConfig->Get('db_user'));
|
||||
$this->oWizard->SetParameter('db_pwd', $oConfig->Get('db_pwd'));
|
||||
$this->oWizard->SetParameter('db_name', $oConfig->Get('db_name'));
|
||||
$this->oWizard->SetParameter('db_prefix', $oConfig->Get('db_subname'));
|
||||
$this->oWizard->SetParameter('db_tls_enabled', $oConfig->Get('db_tls.enabled'));
|
||||
$this->oWizard->SetParameter('db_tls_ca', $oConfig->Get('db_tls.ca') ?? '');
|
||||
|
||||
$this->oWizard->SaveParameter('selected_modules', []);
|
||||
$this->oWizard->SaveParameter('selected_extensions', []);
|
||||
$this->oWizard->SaveParameter('display_choices', []);
|
||||
$this->oWizard->SaveParameter('added_extensions', []);
|
||||
$this->oWizard->SaveParameter('removed_extensions', []);
|
||||
$this->oWizard->SaveParameter('extensions_not_uninstallable', []);
|
||||
|
||||
return new WizardState(WizStepDataAudit::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function GetTitle()
|
||||
public function GetTitle(): string
|
||||
{
|
||||
return 'Before checking compatibility';
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ class WizStepModulesChoice extends AbstractWizStepInstall
|
||||
*/
|
||||
protected iTopExtensionsMap $oExtensionsMap;
|
||||
|
||||
private ?array $aSteps = null;
|
||||
protected ?array $aSteps = null;
|
||||
|
||||
protected PhpExpressionEvaluator $oPhpExpressionEvaluator;
|
||||
|
||||
@@ -51,7 +51,7 @@ class WizStepModulesChoice extends AbstractWizStepInstall
|
||||
private array $aAnalyzeInstallationModules = [];
|
||||
private ?MissingDependencyException $oMissingDependencyException = null;
|
||||
|
||||
public function __construct(WizardController $oWizard, $sCurrentState)
|
||||
public function __construct(WizardController $oWizard, $sCurrentState, bool $bOverWriteConfig = true)
|
||||
{
|
||||
parent::__construct($oWizard, $sCurrentState);
|
||||
$this->bChoicesFromDatabase = false;
|
||||
@@ -69,8 +69,10 @@ class WizStepModulesChoice extends AbstractWizStepInstall
|
||||
if ($sConfigPath !== null) {
|
||||
$this->oConfig = new Config($sConfigPath);
|
||||
|
||||
$aParamValues = $oWizard->GetParamForConfigArray();
|
||||
$this->oConfig->UpdateFromParams($aParamValues);
|
||||
if ($bOverWriteConfig) {
|
||||
$aParamValues = $oWizard->GetParamForConfigArray();
|
||||
$this->oConfig->UpdateFromParams($aParamValues);
|
||||
}
|
||||
|
||||
$this->oExtensionsMap->LoadChoicesFromDatabase($this->oConfig);
|
||||
$this->bChoicesFromDatabase = true;
|
||||
@@ -78,7 +80,7 @@ class WizStepModulesChoice extends AbstractWizStepInstall
|
||||
|
||||
// Sanity check (not stopper, to let developers go further...)
|
||||
try {
|
||||
$this->aAnalyzeInstallationModules = SetupUtils::AnalyzeInstallation($this->oWizard, true);
|
||||
$this->aAnalyzeInstallationModules = SetupUtils::AnalyzeInstallation($this->oWizard, true, null, $this->oConfig);
|
||||
} catch (MissingDependencyException $e) {
|
||||
$this->oMissingDependencyException = $e;
|
||||
$this->aAnalyzeInstallationModules = SetupUtils::AnalyzeInstallation($this->oWizard);
|
||||
@@ -192,7 +194,7 @@ class WizStepModulesChoice extends AbstractWizStepInstall
|
||||
$this->oWizard->SetParameter('selected_modules', json_encode(array_keys($aModules)));
|
||||
$this->oWizard->SetParameter('selected_extensions', json_encode($aExtensions));
|
||||
$this->oWizard->SetParameter('display_choices', $sDisplayChoices);
|
||||
$this->oWizard->SetParameter('extensions_added', json_encode($aExtensionsAdded));
|
||||
$this->oWizard->SetParameter('added_extensions', json_encode($aExtensionsAdded));
|
||||
$this->oWizard->SetParameter('removed_extensions', json_encode($aExtensionsRemoved));
|
||||
$this->oWizard->SetParameter('extensions_not_uninstallable', json_encode(array_keys($aExtensionsNotUninstallable)));
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
*/
|
||||
use Combodo\iTop\Application\WebPage\WebPage;
|
||||
|
||||
/**
|
||||
* Summary of the installation tasks
|
||||
@@ -84,7 +83,7 @@ class WizStepSummary extends AbstractWizStepInstall
|
||||
$oPage->add('<div id="params_summary">');
|
||||
|
||||
$oPage->add('<div class="closed"><a class="title ibo-setup-summary-title" href="#" aria-label="Extensions to be installed">Extensions to be installed</a>');
|
||||
$aExtensionsAdded = json_decode($this->oWizard->GetParameter('extensions_added'), true);
|
||||
$aExtensionsAdded = json_decode($this->oWizard->GetParameter('added_extensions'), true);
|
||||
|
||||
if (count($aExtensionsAdded) > 0) {
|
||||
$sExtensionsAdded = '<ul>';
|
||||
|
||||
Reference in New Issue
Block a user