Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions setup/wizardsteps.class.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -1397,9 +1397,50 @@ public function ProcessParams($bMoveForward = true)
if (class_exists('CreateITILProfilesInstaller')) {
$this->oWizard->SetParameter('old_addon', true);
}

$aExtensionsAdded = [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the 2 arrays could contain html lines instead of extension codes. afterwhile you could use implode. code would be simpler.

$aExtensionsRemoved = [];
$aExtensionsNotUninstallable = [];
foreach ($this->oExtensionsMap->GetAllExtensionsWithPreviouslyInstalled() as $oExtension) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you extract all changes in a separate function? and cover it with tests?

/* @var \iTopExtension $oExtension */
$bSelected = in_array($oExtension->sCode, $aExtensions);
if ($oExtension->bInstalled && !$bSelected) {
$aExtensionsRemoved[$oExtension->sCode] = $oExtension->sLabel;
} elseif (!$oExtension->bInstalled && $bSelected) {
$aExtensionsAdded[$oExtension->sCode] = $oExtension->sLabel;
}
if (!$oExtension->CanBeUninstalled()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to add uninstallable extensions when added. please move this 3 lines above.

$aExtensionsNotUninstallable[$oExtension->sCode] = true;
}
}

$sExtensionsAdded = '<ul><li>No extension added.</li></ul>';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this variable is initialized with a useless value when below array count >0.

if (count($aExtensionsAdded) > 0) {
$sExtensionsAdded = '<ul>';
foreach ($aExtensionsAdded as $sExtensionCode) {
$sExtensionsAdded .= '<li>'.$sExtensionCode.'</li>';
}
$sExtensionsAdded .= '</ul>';
}

$sExtensionsRemoved = '<ul><li>No extension removed.</li></ul>';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same remark. this variable is initialized with a useless value when below array count >0.

if (count($aExtensionsRemoved) > 0) {
$sExtensionsRemoved = '<ul>';
foreach ($aExtensionsRemoved as $sCode => $sExtensionCode) {
$sForcedUninstall = '';
if (isset($aExtensionsNotUninstallable[$sCode])) {
$sForcedUninstall = ' (forced uninstallation)';
}
$sExtensionsRemoved .= '<li>'.$sExtensionCode.$sForcedUninstall.'</li>';
}
$sExtensionsRemoved .= '</ul>';
}

$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', $sExtensionsAdded);
$this->oWizard->SetParameter('extensions_removed', $sExtensionsRemoved);
return ['class' => 'WizStepSummary', 'state' => ''];
}

Expand Down Expand Up @@ -2217,6 +2258,14 @@ public function Display(WebPage $oPage)

$oPage->add('<fieldset id="summary"><legend>Installation Parameters</legend>');
$oPage->add('<div id="params_summary">');

$oPage->add('<div class="closed"><span class="title ibo-setup-summary-title">Extensions to be installed</span>');
$oPage->add($this->oWizard->GetParameter('extensions_added'));
$oPage->add('</div>');
$oPage->add('<div class="closed"><span class="title ibo-setup-summary-title">Extensions to be uninstalled</span>');
$oPage->add($this->oWizard->GetParameter('extensions_removed'));
$oPage->add('</div>');

$oPage->add('<div class="closed"><span class="title ibo-setup-summary-title">Database Parameters</span><ul>');
$oPage->add('<li>Server Name: '.$aInstallParams['database']['server'].'</li>');
$oPage->add('<li>DB User Name: '.$aInstallParams['database']['user'].'</li>');
Expand Down