bChoicesFromDatabase = false; $this->oExtensionsMap = new iTopExtensionsMap(); $sPreviousSourceDir = $this->oWizard->GetParameter('previous_version_dir', ''); $sConfigPath = null; if (($sPreviousSourceDir !== '') && is_readable($sPreviousSourceDir.'/conf/production/config-itop.php')) { $sConfigPath = $sPreviousSourceDir.'/conf/production/config-itop.php'; } elseif (is_readable(utils::GetConfigFilePath('production'))) { $sConfigPath = utils::GetConfigFilePath('production'); } // only called if the config file exists : we are updating a previous installation ! // WARNING : we can't load this config directly, as it might be from another directory with a different approot_url (N°2684) if ($sConfigPath !== null) { $this->oConfig = new Config($sConfigPath); $aParamValues = $oWizard->GetParamForConfigArray(); $this->oConfig->UpdateFromParams($aParamValues); $this->oExtensionsMap->LoadChoicesFromDatabase($this->oConfig); $this->bChoicesFromDatabase = true; } // Sanity check (not stopper, to let developers go further...) try { $this->aAnalyzeInstallationModules = SetupUtils::AnalyzeInstallation($this->oWizard, true); } catch (MissingDependencyException $e) { $this->oMissingDependencyException = $e; $this->aAnalyzeInstallationModules = SetupUtils::AnalyzeInstallation($this->oWizard); } } public function GetTitle(): string { $aStepInfo = $this->GetStepInfo(); return $aStepInfo['title'] ?? 'Modules selection'; } public function GetPossibleSteps() { return [WizStepModulesChoice::class, WizStepDataAudit::class, WizStepSummary::class]; } public function GetAddedAndRemovedExtensions($aSelectedExtensions) { $aExtensionsAdded = []; $aExtensionsRemoved = []; $aExtensionsNotUninstallable = []; foreach ($this->oExtensionsMap->GetAllExtensionsWithPreviouslyInstalled() as $oExtension) { /* @var \iTopExtension $oExtension */ $bSelected = in_array($oExtension->sCode, $aSelectedExtensions); if ($oExtension->bInstalled && !$bSelected) { $aExtensionsRemoved[$oExtension->sCode] = $oExtension->sLabel; if (!$oExtension->CanBeUninstalled()) { $aExtensionsNotUninstallable[$oExtension->sCode] = true; } } elseif (!$oExtension->bInstalled && $bSelected) { $aExtensionsAdded[$oExtension->sCode] = $oExtension->sLabel; } } return [$aExtensionsAdded, $aExtensionsRemoved, $aExtensionsNotUninstallable]; } public function IsDataAuditEnabled(): bool { $sPath = APPROOT.'env-production'; if (!is_dir($sPath)) { SetupLog::Info("Reinstallation of an iTop from a backup (No env-production found). Setup data audit disabled"); return false; } return true; } public function UpdateWizardStateAndGetNextStep($bMoveForward = true): WizardState { // Accumulates the selected modules: $index = $this->GetStepIndex(); // use json_encode:decode to store a hash array: step_id => array(input_name => selected_input_id) $aSelectedChoices = json_decode($this->oWizard->GetParameter('selected_components', '{}'), true); $aSelected = utils::ReadParam('choice', []); $aSelectedChoices[$index] = $aSelected; $this->oWizard->SetParameter('selected_components', json_encode($aSelectedChoices)); if ($this->GetStepInfo($index) == null) { throw new Exception('Internal error: invalid step "'.$index.'" for the choice of modules.'); } elseif ($bMoveForward) { if ($this->GetStepInfo(1 + $index) != null) { return new WizardState(WizStepModulesChoice::class, (1 + $index)); } else { // Exiting this step of the wizard, let's convert the selection into a list of modules $aModules = []; $aExtensions = []; $sDisplayChoices = '
".print_r($aScores, true)."
".print_r($aDefaults, true)."