Files
iTop/setup/wizardsteps/WizStepLandingBeforeAudit.php
2026-05-29 17:22:59 +02:00

100 lines
3.4 KiB
PHP

<?php
/*
* @copyright Copyright (C) 2010-2026 Combodo SAS
* @license http://opensource.org/licenses/AGPL-3.0
*/
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
*/
public function Display(SetupPage $oPage): void
{
}
/**
* @inheritDoc
*/
public function UpdateWizardStateAndGetNextStep($bMoveForward = true): WizardState
{
$oRuntimeEnv = new RunTimeEnvironment();
$sBuildConfigFile = APPCONF.$oRuntimeEnv->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->SetParameter('display_choices', '[]');
$this->oWizard->SetParameter('extensions_not_uninstallable', '[]');
if ($this->oWizard->GetParameter('skip_wizard', false)) {
$oExtensionMap = new iTopExtensionsMap($oRuntimeEnv->GetBuildEnv());
$aExtensionsFromDatabase = $oExtensionMap->GetChoicesFromDatabase($oConfig);
$this->oWizard->SetParameter('selected_extensions', json_encode($aExtensionsFromDatabase));
$adModulesFromDatabase = ModuleInstallationRepository::GetInstance()->ReadComputeInstalledModules($oConfig);
$this->oWizard->SetParameter('selected_modules', json_encode(array_keys($adModulesFromDatabase)));
}
$aWizardSteps = $this->GetWizardSteps();
$this->oWizard->SetWizardSteps($aWizardSteps);
$this->sCurrentState = count($aWizardSteps) - 1;
$aSelectedComponents = $this->GetSelectedComponents($this->aSteps, $this->oWizard->GetParameter('selected_extensions'));
$this->oWizard->SetParameter('selected_components', json_encode($aSelectedComponents));
return new WizardState(WizStepDataAudit::class);
}
/**
* @inheritDoc
*/
public function GetTitle(): string
{
return 'Before checking compatibility';
}
public function GetPossibleSteps()
{
return [WizStepDataAudit::class];
}
public function GetNextButtonLabel()
{
return 'Next';
}
public function CanComeBack()
{
return false;
}
}