From f1af3d5c5f453bc19c1d568bcaf1fc47c7a97983 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eric=20Espi=C3=A9?= Date: Mon, 22 Jun 2026 17:12:57 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B09711=20-=20Block=20user=20from=20going?= =?UTF-8?q?=20back=20to=20the=20setup=20(#944)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DataFeatureRemovalController.php | 12 +--- .../templates/AnalysisResult.html.twig | 18 ++--- .../templates/Features.html.twig | 1 + setup/setuputils.class.inc.php | 27 +++++++ setup/wizardsteps/AbstractWizStepInstall.php | 71 ++++++++++--------- setup/wizardsteps/WizStepDataAudit.php | 14 ++-- setup/wizardsteps/WizStepInstall.php | 15 ++-- setup/wizardsteps/WizStepSummary.php | 15 ++-- 8 files changed, 97 insertions(+), 76 deletions(-) diff --git a/datamodels/2.x/combodo-data-feature-removal/src/Controller/DataFeatureRemovalController.php b/datamodels/2.x/combodo-data-feature-removal/src/Controller/DataFeatureRemovalController.php index a58e2377a..1bbe4f019 100644 --- a/datamodels/2.x/combodo-data-feature-removal/src/Controller/DataFeatureRemovalController.php +++ b/datamodels/2.x/combodo-data-feature-removal/src/Controller/DataFeatureRemovalController.php @@ -99,9 +99,9 @@ class DataFeatureRemovalController extends Controller 'removed_extensions' => '[]', 'extensions_not_uninstallable' => '[]', 'copy_setup_files' => 1, - 'force-uninstall' => "", + 'force-uninstall' => '', 'use_symbolic_links' => MFCompiler::UseSymbolicLinks() ? 'on' : '', - 'return_button_label' => '', + 'return_application' => '', 'target_env' => ITOP_DEFAULT_ENV, ]; @@ -111,10 +111,6 @@ class DataFeatureRemovalController extends Controller } $aParams['aHiddenInputs'] = $aHiddenInputs; - if ($aHiddenInputs['return_button_label'] !== '') { - $aParams['sReturnButtonURL'] = utils::GetAbsoluteUrlModulePage('itsm-designer-connector', 'launch.php'); - } - $aAddedExtensions = json_decode($aHiddenInputs['added_extensions'], true); $aRemovedExtensions = json_decode($aHiddenInputs['removed_extensions'], true); @@ -186,10 +182,6 @@ class DataFeatureRemovalController extends Controller $aParams['aSetupParams']["_params[$sInputName]"] = $sInputValue; } - if ($aHiddenInputs['return_button_label'] !== '') { - $aParams['sReturnButtonURL'] = utils::GetAbsoluteUrlModulePage('itsm-designer-connector', 'launch.php'); - } - [$aParams['aDeletionPlanSummary'], $aParams['iQueryCount'], $aParams['bDeletionPossible']] = $this->GetDeletionPlanSummaryTable($aGetRemovedClasses); [$aParams['aDeletionExecutionSummary'], $aParams['bHasDeletionExecution']] = $this->GetExecutionSummaryTable(); $aParams['bDeletionNeeded'] = ($aParams['iQueryCount'] > 0); diff --git a/datamodels/2.x/combodo-data-feature-removal/templates/AnalysisResult.html.twig b/datamodels/2.x/combodo-data-feature-removal/templates/AnalysisResult.html.twig index d2a2dc5ca..9d5bb1c64 100644 --- a/datamodels/2.x/combodo-data-feature-removal/templates/AnalysisResult.html.twig +++ b/datamodels/2.x/combodo-data-feature-removal/templates/AnalysisResult.html.twig @@ -87,15 +87,11 @@ {% endif %} {% endif %} - {% if aHiddenInputs.return_button_label != '' %} - {% UIButton ForAlternativeSecondaryAction { sLabel:aHiddenInputs.return_button_label, OnClickJsCode: 'window.location.href="' ~ sReturnButtonURL ~ '"'} %} - {% else %} - {% UIForm Standard {} %} - {% UIInput ForHidden { sName:'transaction_id', sValue:sTransactionId} %} - {% UIInput ForHidden { sName:'operation', sValue:'Main'} %} - {% UIToolbar ForButton {} %} - {% UIButton ForPrimaryAction {sLabel:'UI:Button:BackToMain'|dict_s, sName:'btn_back', sId:'btn_back', bIsSubmit:true} %} - {% EndUIToolbar %} - {% EndUIForm %} - {% endif %} + {% UIForm Standard {} %} + {% UIInput ForHidden { sName:'transaction_id', sValue:sTransactionId} %} + {% UIInput ForHidden { sName:'operation', sValue:'Main'} %} + {% UIToolbar ForButton {} %} + {% UIButton ForPrimaryAction {sLabel:'UI:Button:BackToMain'|dict_s, sName:'btn_back', sId:'btn_back', bIsSubmit:true} %} + {% EndUIToolbar %} + {% EndUIForm %} {% EndUIPanel %} diff --git a/datamodels/2.x/combodo-data-feature-removal/templates/Features.html.twig b/datamodels/2.x/combodo-data-feature-removal/templates/Features.html.twig index a2c2c84f1..47c959843 100644 --- a/datamodels/2.x/combodo-data-feature-removal/templates/Features.html.twig +++ b/datamodels/2.x/combodo-data-feature-removal/templates/Features.html.twig @@ -5,6 +5,7 @@ {% UIForm Standard {} %} {% UIInput ForHidden {sName:'operation', sValue:'AnalysisResult'} %} {% UIInput ForHidden {sName:'transaction_id', sValue:sTransactionId} %} + {% UIInput ForHidden {sName:'return_application', sValue:'itop'} %} {% UIPanel Neutral { sTitle:'DataFeatureRemoval:Features:Title'|dict_s, sSubTitle: '' } %} {% UIMultiColumn Standard {} %} diff --git a/setup/setuputils.class.inc.php b/setup/setuputils.class.inc.php index 20700605e..53c95f0ad 100644 --- a/setup/setuputils.class.inc.php +++ b/setup/setuputils.class.inc.php @@ -2162,6 +2162,33 @@ JS return $aOptionalExtensions; } + + public static function GetBackButtonInfo($sReturnApplication): array + { + $sButtonUrl = ''; + $sButtonLabel = ''; + if ($sReturnApplication !== '') { + switch ($sReturnApplication) { + case 'itop': + $sButtonUrl = utils::GetAbsoluteUrlModulePage('combodo-data-feature-removal', 'index.php'); + $sButtonLabel = 'Back to application'; + break; + case 'designer': + $sButtonUrl = utils::GetAbsoluteUrlModulePage('itsm-designer-connector', 'launch.php'); + $sButtonLabel = 'Back to Designer'; + break; + case 'hub': + $sButtonUrl = utils::GetAbsoluteUrlModulePage('itop-hub-connector', 'launch.php'); + $sButtonLabel = 'Back to hub'; + break; + default: + break; + } + + } + + return [$sButtonLabel, $sButtonUrl]; + } } /** diff --git a/setup/wizardsteps/AbstractWizStepInstall.php b/setup/wizardsteps/AbstractWizStepInstall.php index c5dece5c9..5716ddb3f 100644 --- a/setup/wizardsteps/AbstractWizStepInstall.php +++ b/setup/wizardsteps/AbstractWizStepInstall.php @@ -22,6 +22,7 @@ abstract class AbstractWizStepInstall extends WizardStep { /** * Prepare the parameters to execute the installation asynchronously + * * @return array A big hash array that can be converted to XML or JSON with all the needed parameters */ protected function BuildConfig() @@ -60,50 +61,50 @@ abstract class AbstractWizStepInstall extends WizardStep $sSourceDir = APPROOT.'modules'; } - $aInstallParams = [ - 'mode' => $sMode, - 'optional_steps' => [ + $aInstallParams = [ + 'mode' => $sMode, + 'optional_steps' => [ 'log-parameters' => true, 'migrate-before' => true, - 'migrate-after' => true, - 'setup-audit' => true, + 'migrate-after' => true, + 'setup-audit' => true, // 'backup' => see below ], - 'source_dir' => str_replace(APPROOT, '', $sSourceDir), - 'datamodel_version' => $this->oWizard->GetParameter('datamodel_version'), //TODO: let the installer compute this automatically... + 'source_dir' => str_replace(APPROOT, '', $sSourceDir), + 'datamodel_version' => $this->oWizard->GetParameter('datamodel_version'), //TODO: let the installer compute this automatically... 'previous_configuration_file' => $sPreviousConfigurationFile, - 'extensions_dir' => $this->oWizard->GetParameter('extensions_dir', 'extensions'), - 'target_env' => $this->oWizard->GetParameter('target_env', ITOP_DEFAULT_ENV), - 'workspace_dir' => '', - 'database' => [ - 'server' => $this->oWizard->GetParameter('db_server'), - 'user' => $this->oWizard->GetParameter('db_user'), - 'pwd' => $this->oWizard->GetParameter('db_pwd'), - 'name' => $sDBName, + 'extensions_dir' => $this->oWizard->GetParameter('extensions_dir', 'extensions'), + 'target_env' => $this->oWizard->GetParameter('target_env', ITOP_DEFAULT_ENV), + 'workspace_dir' => '', + 'database' => [ + 'server' => $this->oWizard->GetParameter('db_server'), + 'user' => $this->oWizard->GetParameter('db_user'), + 'pwd' => $this->oWizard->GetParameter('db_pwd'), + 'name' => $sDBName, 'db_tls_enabled' => $this->oWizard->GetParameter('db_tls_enabled'), - 'db_tls_ca' => $this->oWizard->GetParameter('db_tls_ca'), - 'prefix' => $this->oWizard->GetParameter('db_prefix'), + 'db_tls_ca' => $this->oWizard->GetParameter('db_tls_ca'), + 'prefix' => $this->oWizard->GetParameter('db_prefix'), ], - 'url' => $this->oWizard->GetParameter('application_url'), - 'graphviz_path' => $this->oWizard->GetParameter('graphviz_path'), - 'admin_account' => [ - 'user' => $this->oWizard->GetParameter('admin_user'), - 'pwd' => $this->oWizard->GetParameter('admin_pwd'), + 'url' => $this->oWizard->GetParameter('application_url'), + 'graphviz_path' => $this->oWizard->GetParameter('graphviz_path'), + 'admin_account' => [ + 'user' => $this->oWizard->GetParameter('admin_user'), + 'pwd' => $this->oWizard->GetParameter('admin_pwd'), 'language' => $this->oWizard->GetParameter('admin_language'), ], - 'language' => $this->oWizard->GetParameter('default_language'), - 'selected_modules' => $aSelectedModules, - 'selected_extensions' => $aSelectedExtensions, - 'sample_data' => $this->oWizard->GetParameter('sample_data', '') === 'yes', - 'old_addon' => $this->oWizard->GetParameter('old_addon', false), // whether or not to use the "old" userrights profile addon - 'options' => json_decode($this->oWizard->GetParameter('misc_options', '[]'), true), - 'mysql_bindir' => $this->oWizard->GetParameter('mysql_bindir'), - 'use_symbolic_links' => $this->oWizard->GetParameter('use_symbolic_links', MFCompiler::UseSymbolicLinks()), + 'language' => $this->oWizard->GetParameter('default_language'), + 'selected_modules' => $aSelectedModules, + 'selected_extensions' => $aSelectedExtensions, + 'sample_data' => $this->oWizard->GetParameter('sample_data', '') === 'yes', + 'old_addon' => $this->oWizard->GetParameter('old_addon', false), // whether or not to use the "old" userrights profile addon + 'options' => json_decode($this->oWizard->GetParameter('misc_options', '[]'), true), + 'mysql_bindir' => $this->oWizard->GetParameter('mysql_bindir'), + 'use_symbolic_links' => $this->oWizard->GetParameter('use_symbolic_links', MFCompiler::UseSymbolicLinks()), ]; if ($sBackupDestination != '') { - $aInstallParams['optional_steps']['backup'] = [ - 'destination' => $sBackupDestination, + $aInstallParams['optional_steps']['backup'] = [ + 'destination' => $sBackupDestination, 'configuration_file' => $sPreviousConfigurationFile, ]; } @@ -115,4 +116,10 @@ abstract class AbstractWizStepInstall extends WizardStep return $aInstallParams; } + public function GetBackButtonInfo(): array + { + $sReturnApplication = $this->oWizard->GetParameter('return_application', ''); + + return SetupUtils::GetBackButtonInfo($sReturnApplication); + } } diff --git a/setup/wizardsteps/WizStepDataAudit.php b/setup/wizardsteps/WizStepDataAudit.php index 1bc480e9c..5a5c12d53 100644 --- a/setup/wizardsteps/WizStepDataAudit.php +++ b/setup/wizardsteps/WizStepDataAudit.php @@ -108,7 +108,7 @@ JS); 'removed_extensions' => '[]', 'extensions_not_uninstallable' => '[]', 'copy_setup_files' => 1, - 'return_button_label' => '', + 'return_application' => '', 'target_env' => ITOP_DEFAULT_ENV, 'force-uninstall' => "", 'use_symbolic_links' => "", @@ -130,14 +130,12 @@ INPUT; HTML ); - $sButtonLabel = $this->oWizard->GetParameter('return_button_label', ''); - if ($sButtonLabel !== '') { - $sButtonLabel = utils::HtmlEntities($sButtonLabel); - $sButtonUrl = utils::GetAbsoluteUrlModulePage('itsm-designer-connector', 'launch.php'); + [$sButtonLabel, $sButtonUrl] = $this->GetBackButtonInfo(); + if ($sButtonUrl !== '') { $sButtonUrl = utils::HtmlEntities($sButtonUrl); $oPage->add_ready_script( <<'); +$('.ibo-setup--wizard--buttons-container tr td:nth-child(1)').after(''); JS ); } @@ -182,7 +180,9 @@ JS public function JSCanMoveBackward() { - if ($this->oWizard->GetParameter('return_button_label', '') !== '') { + $sReturnApplication = $this->oWizard->GetParameter('return_application', ''); + [$sReturnLabel] = SetupUtils::GetBackButtonInfo($sReturnApplication); + if ($sReturnLabel !== '') { return 'return false;'; } diff --git a/setup/wizardsteps/WizStepInstall.php b/setup/wizardsteps/WizStepInstall.php index 83907077a..9c3955c3a 100644 --- a/setup/wizardsteps/WizStepInstall.php +++ b/setup/wizardsteps/WizStepInstall.php @@ -56,9 +56,9 @@ class WizStepInstall extends AbstractWizStepInstall public function CanMoveBackward() { - $sLabel = $this->oWizard->GetParameter('return_button_label', ''); - SetupLog::Info(__METHOD__.": return_button_label [$sLabel]"); - return $sLabel === ''; + $sApplication = $this->oWizard->GetParameter('return_application', ''); + + return $sApplication === ''; } public function UpdateWizardStateAndGetNextStep($bMoveForward = true): WizardState @@ -115,13 +115,12 @@ JS); public function PostFormDisplay(SetupPage $oPage) { - $sButtonLabel = $this->oWizard->GetParameter('return_button_label', ''); - SetupLog::Info(__METHOD__.": return_button_label [$sButtonLabel]"); - if ($sButtonLabel !== '') { - $sButtonUrl = utils::GetAbsoluteUrlModulePage('itsm-designer-connector', 'launch.php'); + [$sButtonLabel, $sButtonUrl] = $this->GetBackButtonInfo(); + if ($sButtonUrl !== '') { + $sButtonUrl = utils::HtmlEntities($sButtonUrl); $oPage->add_ready_script( <<'); +$('.ibo-setup--wizard--buttons-container tr td:nth-child(1)').after(''); JS ); } diff --git a/setup/wizardsteps/WizStepSummary.php b/setup/wizardsteps/WizStepSummary.php index 0678b913b..02c15d532 100644 --- a/setup/wizardsteps/WizStepSummary.php +++ b/setup/wizardsteps/WizStepSummary.php @@ -59,10 +59,9 @@ class WizStepSummary extends AbstractWizStepInstall public function CanMoveBackward() { - $sLabel = $this->oWizard->GetParameter('return_button_label', ''); - SetupLog::Info(__METHOD__.": return_button_label [$sLabel]"); + $sApplication = $this->oWizard->GetParameter('return_application', ''); - return $sLabel === ''; + return $sApplication === ''; } public function UpdateWizardStateAndGetNextStep($bMoveForward = true): WizardState @@ -249,12 +248,12 @@ JS public function PostFormDisplay(SetupPage $oPage) { - $sButtonLabel = $this->oWizard->GetParameter('return_button_label', ''); - if ($sButtonLabel !== '') { - $sButtonUrl = utils::GetAbsoluteUrlModulePage('itsm-designer-connector', 'launch.php'); + [$sButtonLabel, $sButtonUrl] = $this->GetBackButtonInfo(); + if ($sButtonUrl !== '') { + $sButtonUrl = utils::HtmlEntities($sButtonUrl); $oPage->add_ready_script( <<'); +$('.ibo-setup--wizard--buttons-container tr td:nth-child(1)').after(''); JS ); } @@ -275,7 +274,7 @@ JS */ public function JSCanMoveBackward() { - if ($this->oWizard->GetParameter('return_button_label', '') === '') { + if ($this->oWizard->GetParameter('return_application', '') === '') { return 'return true;'; }