oWizard->GetParameter('mode', 'install'); if ($sMode == 'install') { return 'Ready to install'; } else { return 'Ready to upgrade'; } } public function GetPossibleSteps() { return [WizStepInstall::class]; } /** * Returns the label for the " Next >> " button * @return string The label for the button */ public function GetNextButtonLabel() { return 'Install'; } public function CanMoveForward() { if ($this->CheckDependencies()) { return true; } else { return false; } } public function UpdateWizardStateAndGetNextStep($bMoveForward = true): WizardState { $this->oWizard->SaveParameter('db_backup', false); $this->oWizard->SaveParameter('db_backup_path', ''); return new WizardState(WizStepInstall::class); } public function Display(WebPage $oPage) { $aInstallParams = $this->BuildConfig(); $sMode = $aInstallParams['mode']; $sDestination = ITOP_APPLICATION.(($sMode == 'install') ? ' version '.ITOP_VERSION.' is about to be installed ' : ' is about to be upgraded '); $sDBDescription = ' existing database '.$aInstallParams['database']['name'].''; if (($sMode == 'install') && ($this->oWizard->GetParameter('create_db') == 'yes')) { $sDBDescription = ' new database '.$aInstallParams['database']['name'].''; } $sDestination .= 'into the '.$sDBDescription.' on the server '.$aInstallParams['database']['server'].'.'; $oPage->add('

'.$sDestination.'

'); $oPage->add('
Installation Parameters'); $oPage->add('
'); $oPage->add('
Extensions to be installed'); $aExtensionsAdded = json_decode($this->oWizard->GetParameter('extensions_added'), true); if (count($aExtensionsAdded) > 0) { $sExtensionsAdded = '
    '; foreach ($aExtensionsAdded as $sExtensionCode => $sLabel) { $sExtensionsAdded .= '
  • '.$sLabel.'
  • '; } $sExtensionsAdded .= '
'; } else { $sExtensionsAdded = '
  • No extension added.
'; } $oPage->add($sExtensionsAdded); $oPage->add('
'); $oPage->add('
Extensions to be uninstalled'); $aExtensionsRemoved = json_decode($this->oWizard->GetParameter('removed_extensions'), true) ?? []; $aExtensionsNotUninstallable = json_decode($this->oWizard->GetParameter('extensions_not_uninstallable')); if (count($aExtensionsRemoved) > 0) { $sExtensionsRemoved = '
    '; foreach ($aExtensionsRemoved as $sExtensionCode => $sLabel) { if (in_array($sExtensionCode, $aExtensionsNotUninstallable)) { $sExtensionsRemoved .= '
  • '.$sLabel.' (forced uninstallation)
  • '; } else { $sExtensionsRemoved .= '
  • '.$sLabel.'
  • '; } } $sExtensionsRemoved .= '
'; } else { $sExtensionsRemoved = '
  • No extension removed.
'; } $oPage->add($sExtensionsRemoved); $oPage->add('
'); $oPage->add('
Database Parameters
    '); $oPage->add('
  • Server Name: '.$aInstallParams['database']['server'].'
  • '); $oPage->add('
  • DB User Name: '.$aInstallParams['database']['user'].'
  • '); $oPage->add('
  • DB user password: ***
  • '); if (($sMode == 'install') && ($this->oWizard->GetParameter('create_db') == 'yes')) { $oPage->add('
  • Database Name: '.$aInstallParams['database']['name'].' (will be created)
  • '); } else { $oPage->add('
  • Database Name: '.$aInstallParams['database']['name'].'
  • '); } if ($aInstallParams['database']['prefix'] != '') { $oPage->add('
  • Prefix for the '.ITOP_APPLICATION.' tables: '.$aInstallParams['database']['prefix'].'
  • '); } else { $oPage->add('
  • Prefix for the '.ITOP_APPLICATION.' tables: none
  • '); } $oPage->add('
'); $oPage->add('
Data Model Configuration'); $oPage->add($this->oWizard->GetParameter('display_choices')); $oPage->add('
'); $oPage->add('
Other Parameters
    '); if ($sMode == 'install') { $oPage->add('
  • Default language: '.$aInstallParams['language'].'
  • '); } $oPage->add('
  • URL to access the application: '.$aInstallParams['url'].'
  • '); $oPage->add('
  • Graphviz\' dot path: '.$aInstallParams['graphviz_path'].'
  • '); if ($aInstallParams['sample_data']) { $oPage->add('
  • Sample data will be loaded into the database.
  • '); } if ($aInstallParams['old_addon']) { $oPage->add('
  • Compatibility mode: Using the version 1.2 of the UserRightsProfiles add-on.
  • '); } $oPage->add('
'); if ($sMode == 'install') { $oPage->add('
Administrator Account
    '); $oPage->add('
  • Login: '.$aInstallParams['admin_account']['user'].'
  • '); $oPage->add('
  • Password: '.$aInstallParams['admin_account']['pwd'].'
  • '); $oPage->add('
  • Language: '.$aInstallParams['admin_account']['language'].'
  • '); $oPage->add('
'); } $aMiscOptions = $aInstallParams['options']; if (count($aMiscOptions) > 0) { $oPage->add('
Miscellaneous Options
    '); foreach ($aMiscOptions as $sKey => $sValue) { $oPage->add('
  • '.$sKey.': '.$sValue.'
  • '); } $oPage->add('
'); } if (isset($aMiscOptions['generate_config'])) { $oDoc = new DOMDocument('1.0', 'UTF-8'); $oDoc->preserveWhiteSpace = false; $oDoc->formatOutput = true; $oParams = new PHPParameters(); $oParams->LoadFromHash($aInstallParams); $oParams->ToXML($oDoc, null, 'installation'); $sXML = $oDoc->saveXML(); $oPage->add('
XML Config file
    ');
    			$oPage->add(utils::EscapeHtml($sXML));
    			$oPage->add('
'); } $oPage->add('
'); // params_summary $oPage->add('
'); if (!$this->CheckDependencies()) { $oPage->error($this->sDependencyIssue); } $bDBBackup = $this->oWizard->GetParameter('db_backup', false); $sDBBackupPath = $this->oWizard->GetParameter('db_backup_path', ''); $sMySQLBinDir = $this->oWizard->GetParameter('mysql_bindir', null); if ($sMode != 'install') { $sDBBackupPath = utils::GetDataPath().'backups/manual/setup-'.date('Y-m-d_H_i'); $aPreviousInstance = SetupUtils::GetPreviousInstance(APPROOT); if ($aPreviousInstance['found']) { $sMySQLBinDir = $aPreviousInstance['mysql_bindir']; $this->oWizard->SaveParameter('mysql_bindir', $aPreviousInstance['mysql_bindir']); } } $aBackupChecks = SetupUtils::CheckBackupPrerequisites($sDBBackupPath, $sMySQLBinDir); $bCanBackup = true; $sMySQLDumpMessage = ''; foreach ($aBackupChecks as $oCheck) { switch ($oCheck->iSeverity) { case CheckResult::ERROR: $bCanBackup = false; $sMySQLDumpMessage .= '
Error:'.$oCheck->sLabel.'
'; break; case CheckResult::TRACE: SetupLog::Ok($oCheck->sLabel); break; default: $sMySQLDumpMessage .= '
Success:'.$oCheck->sLabel.'
'; break; } } $sChecked = ($bCanBackup && $bDBBackup) ? ' checked ' : ''; $sDisabled = $bCanBackup ? '' : ' disabled '; $oPage->add('
'); $oPage->add(''); $oPage->add('
Save the backup to:
'); $fFreeSpace = SetupUtils::CheckDiskSpace($sDBBackupPath); $sMessage = ''; if ($fFreeSpace !== false) { $sMessage .= SetupUtils::HumanReadableSize($fFreeSpace).' free in '.dirname($sDBBackupPath); } $oPage->add($sMySQLDumpMessage.''.$sMessage.''); $sAuthentToken = $this->oWizard->GetParameter('authent', ''); $oPage->add(''); $oPage->add_ready_script( <<