mirror of
https://github.com/Combodo/iTop.git
synced 2026-07-01 04:06:37 +02:00
Compare commits
1 Commits
develop
...
feature/97
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be37b12f4e |
@@ -614,6 +614,13 @@ class LogChannels
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public const SECURITY = 'Security';
|
||||
|
||||
/**
|
||||
* For Session parameters
|
||||
*
|
||||
* @Since 3.3.0
|
||||
*/
|
||||
public const SESSION_PARAMETERS = 'SessionParameters';
|
||||
}
|
||||
|
||||
abstract class LogAPI
|
||||
|
||||
@@ -19,6 +19,7 @@ use Combodo\iTop\DataFeatureRemoval\Helper\DataFeatureRemovalLog;
|
||||
use Combodo\iTop\DataFeatureRemoval\Service\DataCleanupService;
|
||||
use Combodo\iTop\DataFeatureRemoval\Service\DataFeatureRemoverExtensionService;
|
||||
use Combodo\iTop\DataFeatureRemoval\Service\StaticDeletionPlan;
|
||||
use Combodo\iTop\Service\Session\SessionParameters;
|
||||
use Combodo\iTop\Setup\FeatureRemoval\DryRemovalRuntimeEnvironment;
|
||||
use Combodo\iTop\Setup\FeatureRemoval\SetupAudit;
|
||||
use ContextTag;
|
||||
@@ -180,7 +181,7 @@ class DataFeatureRemovalController extends Controller
|
||||
];
|
||||
|
||||
foreach ($aHiddenInputs as $sInputName => $sInputValue) {
|
||||
$aParams['aSetupParams']["_params[$sInputName]"] = $sInputValue;
|
||||
$aParams['aSetupParams'][$sInputName] = $sInputValue;
|
||||
}
|
||||
|
||||
[$aParams['aDeletionPlanSummary'], $aParams['iQueryCount'], $aParams['bDeletionPossible']] = $this->GetDeletionPlanSummaryTable($aGetRemovedClasses);
|
||||
@@ -189,6 +190,9 @@ class DataFeatureRemovalController extends Controller
|
||||
Session::Set('aDeletionExecutionSummary', serialize($this->aDeletionExecutionSummary));
|
||||
|
||||
if (!$aParams['bDeletionNeeded']) {
|
||||
// Erase session setup parameters
|
||||
SetupUtils::EraseSetupToken();
|
||||
(new SessionParameters(SetupUtils::SESSION_PARAMETERS_NAME))->Erase();
|
||||
SetupUtils::CreateSetupToken();
|
||||
}
|
||||
|
||||
|
||||
@@ -14,10 +14,7 @@ if (PHP_VERSION_ID < 50600) {
|
||||
echo $err;
|
||||
}
|
||||
}
|
||||
trigger_error(
|
||||
$err,
|
||||
E_USER_ERROR
|
||||
);
|
||||
throw new RuntimeException($err);
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
@@ -137,7 +137,6 @@ return array(
|
||||
'Combodo\\iTop\\Application\\Helper\\FormHelper' => $baseDir . '/sources/Application/Helper/FormHelper.php',
|
||||
'Combodo\\iTop\\Application\\Helper\\ImportHelper' => $baseDir . '/sources/Application/Helper/ImportHelper.php',
|
||||
'Combodo\\iTop\\Application\\Helper\\SearchHelper' => $baseDir . '/sources/Application/Helper/SearchHelper.php',
|
||||
'Combodo\\iTop\\Application\\Helper\\Session' => $baseDir . '/sources/Application/Helper/Session.php',
|
||||
'Combodo\\iTop\\Application\\Helper\\SynchroReplicaHelper' => $baseDir . '/sources/Application/Helper/SynchroReplicaHelper.php',
|
||||
'Combodo\\iTop\\Application\\Helper\\WebResourcesHelper' => $baseDir . '/sources/Application/Helper/WebResourcesHelper.php',
|
||||
'Combodo\\iTop\\Application\\Newsroom\\iTopNewsroomProvider' => $baseDir . '/sources/Application/Newsroom/iTopNewsroomProvider.php',
|
||||
@@ -640,6 +639,8 @@ return array(
|
||||
'Combodo\\iTop\\Service\\Router\\Exception\\RouteNotFoundException' => $baseDir . '/sources/Service/Router/Exception/RouteNotFoundException.php',
|
||||
'Combodo\\iTop\\Service\\Router\\Exception\\RouterException' => $baseDir . '/sources/Service/Router/Exception/RouterException.php',
|
||||
'Combodo\\iTop\\Service\\Router\\Router' => $baseDir . '/sources/Service/Router/Router.php',
|
||||
'Combodo\\iTop\\Service\\Session\\Session' => $baseDir . '/sources/Service/Session/Session.php',
|
||||
'Combodo\\iTop\\Service\\Session\\SessionParameters' => $baseDir . '/sources/Service/Session/SessionParameters.php',
|
||||
'Combodo\\iTop\\Service\\Startup\\StartupService' => $baseDir . '/sources/Service/Startup/StartupService.php',
|
||||
'Combodo\\iTop\\Service\\SummaryCard\\SummaryCardService' => $baseDir . '/sources/Service/SummaryCard/SummaryCardService.php',
|
||||
'Combodo\\iTop\\Service\\TemporaryObjects\\TemporaryObjectConfig' => $baseDir . '/sources/Service/TemporaryObjects/TemporaryObjectConfig.php',
|
||||
@@ -1423,6 +1424,7 @@ return array(
|
||||
'ReportValue' => $baseDir . '/core/bulkchange.class.inc.php',
|
||||
'RestDelete' => $baseDir . '/core/restservices.class.inc.php',
|
||||
'RestResult' => $baseDir . '/application/applicationextension/rest/RestResult.php',
|
||||
'RestResultWithObjectSets' => $baseDir . '/core/restservices.class.inc.php',
|
||||
'RestResultWithObjects' => $baseDir . '/core/restservices.class.inc.php',
|
||||
'RestResultWithRelations' => $baseDir . '/core/restservices.class.inc.php',
|
||||
'RestUtils' => $baseDir . '/application/applicationextension/rest/RestUtils.php',
|
||||
|
||||
@@ -538,7 +538,6 @@ class ComposerStaticInitfc0e9e9dea11dcbb6272414776c30685
|
||||
'Combodo\\iTop\\Application\\Helper\\FormHelper' => __DIR__ . '/../..' . '/sources/Application/Helper/FormHelper.php',
|
||||
'Combodo\\iTop\\Application\\Helper\\ImportHelper' => __DIR__ . '/../..' . '/sources/Application/Helper/ImportHelper.php',
|
||||
'Combodo\\iTop\\Application\\Helper\\SearchHelper' => __DIR__ . '/../..' . '/sources/Application/Helper/SearchHelper.php',
|
||||
'Combodo\\iTop\\Application\\Helper\\Session' => __DIR__ . '/../..' . '/sources/Application/Helper/Session.php',
|
||||
'Combodo\\iTop\\Application\\Helper\\SynchroReplicaHelper' => __DIR__ . '/../..' . '/sources/Application/Helper/SynchroReplicaHelper.php',
|
||||
'Combodo\\iTop\\Application\\Helper\\WebResourcesHelper' => __DIR__ . '/../..' . '/sources/Application/Helper/WebResourcesHelper.php',
|
||||
'Combodo\\iTop\\Application\\Newsroom\\iTopNewsroomProvider' => __DIR__ . '/../..' . '/sources/Application/Newsroom/iTopNewsroomProvider.php',
|
||||
@@ -1041,6 +1040,8 @@ class ComposerStaticInitfc0e9e9dea11dcbb6272414776c30685
|
||||
'Combodo\\iTop\\Service\\Router\\Exception\\RouteNotFoundException' => __DIR__ . '/../..' . '/sources/Service/Router/Exception/RouteNotFoundException.php',
|
||||
'Combodo\\iTop\\Service\\Router\\Exception\\RouterException' => __DIR__ . '/../..' . '/sources/Service/Router/Exception/RouterException.php',
|
||||
'Combodo\\iTop\\Service\\Router\\Router' => __DIR__ . '/../..' . '/sources/Service/Router/Router.php',
|
||||
'Combodo\\iTop\\Service\\Session\\Session' => __DIR__ . '/../..' . '/sources/Service/Session/Session.php',
|
||||
'Combodo\\iTop\\Service\\Session\\SessionParameters' => __DIR__ . '/../..' . '/sources/Service/Session/SessionParameters.php',
|
||||
'Combodo\\iTop\\Service\\Startup\\StartupService' => __DIR__ . '/../..' . '/sources/Service/Startup/StartupService.php',
|
||||
'Combodo\\iTop\\Service\\SummaryCard\\SummaryCardService' => __DIR__ . '/../..' . '/sources/Service/SummaryCard/SummaryCardService.php',
|
||||
'Combodo\\iTop\\Service\\TemporaryObjects\\TemporaryObjectConfig' => __DIR__ . '/../..' . '/sources/Service/TemporaryObjects/TemporaryObjectConfig.php',
|
||||
@@ -1824,6 +1825,7 @@ class ComposerStaticInitfc0e9e9dea11dcbb6272414776c30685
|
||||
'ReportValue' => __DIR__ . '/../..' . '/core/bulkchange.class.inc.php',
|
||||
'RestDelete' => __DIR__ . '/../..' . '/core/restservices.class.inc.php',
|
||||
'RestResult' => __DIR__ . '/../..' . '/application/applicationextension/rest/RestResult.php',
|
||||
'RestResultWithObjectSets' => __DIR__ . '/../..' . '/core/restservices.class.inc.php',
|
||||
'RestResultWithObjects' => __DIR__ . '/../..' . '/core/restservices.class.inc.php',
|
||||
'RestResultWithRelations' => __DIR__ . '/../..' . '/core/restservices.class.inc.php',
|
||||
'RestUtils' => __DIR__ . '/../..' . '/application/applicationextension/rest/RestUtils.php',
|
||||
|
||||
@@ -36,8 +36,7 @@ if ($issues) {
|
||||
echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
|
||||
}
|
||||
}
|
||||
trigger_error(
|
||||
'Composer detected issues in your platform: ' . implode(' ', $issues),
|
||||
E_USER_ERROR
|
||||
throw new \RuntimeException(
|
||||
'Composer detected issues in your platform: ' . implode(' ', $issues)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -103,6 +103,9 @@ class CheckResult
|
||||
*/
|
||||
class SetupUtils
|
||||
{
|
||||
// Name of the parameter array in session for setup
|
||||
public const SESSION_PARAMETERS_NAME = 'setup_params';
|
||||
|
||||
// -- Minimum versions (requirements : forbids installation if not met)
|
||||
public const PHP_MIN_VERSION = '8.2.0';
|
||||
public const MYSQL_MIN_VERSION = '5.7.0'; // 5.6 is no longer supported
|
||||
|
||||
@@ -1,21 +1,11 @@
|
||||
<?php
|
||||
|
||||
// Copyright (C) 2010-2024 Combodo SAS
|
||||
//
|
||||
// This file is part of iTop.
|
||||
//
|
||||
// iTop is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// iTop is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with iTop. If not, see <http://www.gnu.org/licenses/>
|
||||
/**
|
||||
* @copyright Copyright (C) 2010-2026 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
use Combodo\iTop\Service\Session\SessionParameters;
|
||||
|
||||
require_once(APPROOT.'setup/setuputils.class.inc.php');
|
||||
require_once(APPROOT.'setup/parameters.class.inc.php');
|
||||
@@ -26,14 +16,12 @@ require_once(APPROOT.'setup/extensionsmap.class.inc.php');
|
||||
/**
|
||||
* Engine for displaying the various pages of a "wizard"
|
||||
* Each "step" of the wizard must be implemented as
|
||||
* separate class derived from WizardStep. each 'step' can also have its own
|
||||
* separate classes derived from WizardStep. Each 'step' can also have its own
|
||||
* internal 'state' for developing complex wizards.
|
||||
* The WizardController provides the "<< Back" feature by storing a stack
|
||||
* of the previous screens. The WizardController also maintains from page
|
||||
* to page a list of "parameters" to be dispayed/edited by each of the steps.
|
||||
*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
class WizardController
|
||||
@@ -41,37 +29,42 @@ class WizardController
|
||||
protected $aWizardSteps;
|
||||
protected $sInitialStepClass;
|
||||
protected $sInitialState;
|
||||
protected $aParameters;
|
||||
protected SessionParameters $oSessionParameters;
|
||||
|
||||
/**
|
||||
* Initiailization of the wizard controller
|
||||
* Initialization of the wizard controller
|
||||
* @param string $sInitialStepClass Class of the initial step/page of the wizard
|
||||
* @param string $sInitialState Initial state of the initial page (if this class manages states)
|
||||
*/
|
||||
public function __construct($sInitialStepClass, $sInitialState = '')
|
||||
public function __construct(string $sInitialStepClass, string $sInitialState = '')
|
||||
{
|
||||
$this->sInitialStepClass = $sInitialStepClass;
|
||||
$this->sInitialState = $sInitialState;
|
||||
$this->aParameters = [];
|
||||
$this->aWizardSteps = [];
|
||||
$this->oSessionParameters = new SessionParameters(SetupUtils::SESSION_PARAMETERS_NAME);
|
||||
$this->oSessionParameters->LogParameters();
|
||||
$this->aWizardSteps = $this->GetParameter('_steps', []);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pushes information about the current step onto the stack
|
||||
* @param array $aStepInfo Array('class' => , 'state' => )
|
||||
*/
|
||||
protected function PushStep($aStepInfo)
|
||||
protected function PushStep(array $aStepInfo): void
|
||||
{
|
||||
array_push($this->aWizardSteps, $aStepInfo);
|
||||
$this->aWizardSteps[] = $aStepInfo;
|
||||
$this->SetParameter('_steps', $this->aWizardSteps);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes information about the previous step from the stack
|
||||
* @return array{'class': string, 'state': string}
|
||||
*/
|
||||
protected function PopStep()
|
||||
protected function PopStep(): array
|
||||
{
|
||||
return array_pop($this->aWizardSteps);
|
||||
$aStep = array_pop($this->aWizardSteps);
|
||||
$this->SetParameter('_steps', $this->aWizardSteps);
|
||||
|
||||
return $aStep;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,13 +72,9 @@ class WizardController
|
||||
* @param string $sParamCode The code identifying this parameter
|
||||
* @param mixed $defaultValue The default value of the parameter in case it was not set
|
||||
*/
|
||||
public function GetParameter($sParamCode, $defaultValue = '')
|
||||
public function GetParameter(string $sParamCode, mixed $defaultValue = ''): mixed
|
||||
{
|
||||
if (array_key_exists($sParamCode, $this->aParameters)) {
|
||||
return $this->aParameters[$sParamCode];
|
||||
}
|
||||
|
||||
return $defaultValue;
|
||||
return $this->oSessionParameters->GetParameter($sParamCode, $defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,9 +104,9 @@ class WizardController
|
||||
* @param string $sParamCode The code identifying this parameter
|
||||
* @param mixed $value The value to store
|
||||
*/
|
||||
public function SetParameter($sParamCode, $value)
|
||||
public function SetParameter(string $sParamCode, mixed $value): void
|
||||
{
|
||||
$this->aParameters[$sParamCode] = $value;
|
||||
$this->oSessionParameters->SetParameter($sParamCode, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,17 +115,30 @@ class WizardController
|
||||
* @param mixed $defaultValue The default value for the parameter
|
||||
* @param string $sSanitizationFilter A 'sanitization' fitler. Default is 'raw_data', which means no filtering
|
||||
*/
|
||||
public function SaveParameter($sParamCode, $defaultValue, $sSanitizationFilter = 'raw_data')
|
||||
public function SaveParameter(string $sParamCode, mixed $defaultValue, string $sSanitizationFilter = 'raw_data'): void
|
||||
{
|
||||
$value = utils::ReadParam($sParamCode, $defaultValue, false, $sSanitizationFilter);
|
||||
$this->aParameters[$sParamCode] = $value;
|
||||
$this->oSessionParameters->SetParameterFromParams($sParamCode, $defaultValue, $sSanitizationFilter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the value of the page's parameter in a "persistent" parameter in the wizard's context
|
||||
* @param string $sParamCode The code identifying this parameter
|
||||
* @param mixed $defaultValue The default value for the parameter
|
||||
* @param string $sSanitizationFilter A 'sanitization' fitler. Default is 'raw_data', which means no filtering
|
||||
*/
|
||||
public function SavePostedParameter(string $sParamCode, mixed $defaultValue = '', string $sSanitizationFilter = 'raw_data'): void
|
||||
{
|
||||
$this->oSessionParameters->SetParameterFromPostedParams($sParamCode, $defaultValue, $sSanitizationFilter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the wizard by displaying it in its initial state
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function Start()
|
||||
public function Start(): void
|
||||
{
|
||||
$this->EraseParameters();
|
||||
$sCurrentStepClass = $this->sInitialStepClass;
|
||||
$oStep = $this->GetWizardStep($sCurrentStepClass, $this->sInitialState);
|
||||
$this->DisplayStep($oStep);
|
||||
@@ -145,7 +147,7 @@ class WizardController
|
||||
* Progress towards the next step of the wizard
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function Next()
|
||||
protected function Next(): void
|
||||
{
|
||||
$sCurrentStepClass = utils::ReadParam('_class', $this->sInitialStepClass);
|
||||
$sCurrentState = utils::ReadParam('_state', $this->sInitialState);
|
||||
@@ -169,8 +171,10 @@ class WizardController
|
||||
|
||||
/**
|
||||
* Move one step back
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected function Back()
|
||||
protected function Back(): void
|
||||
{
|
||||
// let the current step save its parameters
|
||||
$sCurrentStepClass = utils::ReadParam('_class', $this->sInitialStepClass);
|
||||
@@ -208,11 +212,7 @@ class WizardController
|
||||
// to store the parameters
|
||||
$oPage->add('<input type="hidden" id="_class" name="_class" value="'.get_class($oStep).'"/>');
|
||||
$oPage->add('<input type="hidden" id="_state" name="_state" value="'.$oStep->GetState().'"/>');
|
||||
foreach ($this->aParameters as $sCode => $value) {
|
||||
$oPage->add('<input type="hidden" name="_params['.$sCode.']" value="'.utils::EscapeHtml($value).'"/>');
|
||||
}
|
||||
|
||||
$oPage->add('<input type="hidden" name="_steps" value="'.utils::EscapeHtml(json_encode($this->aWizardSteps)).'"/>');
|
||||
// $oPage->add('<input type="hidden" name="_steps" value="'.utils::EscapeHtml(json_encode($this->aWizardSteps)).'"/>');
|
||||
$oPage->add('<table style="width:100%;" class="ibo-setup--wizard--buttons-container"><tr>');
|
||||
if (count($this->aWizardSteps) > 0) {
|
||||
if ($oStep->CanMoveBackward()) {
|
||||
@@ -267,7 +267,7 @@ EOF
|
||||
* Make the wizard run: 'Start', 'Next' or 'Back' depending WizardUpdateButtons();
|
||||
* on the page's parameters
|
||||
*/
|
||||
public function Run()
|
||||
public function Run(): void
|
||||
{
|
||||
/**
|
||||
* @since 3.2.0 Add the ContextTag init
|
||||
@@ -276,8 +276,8 @@ EOF
|
||||
$oContextTag = new ContextTag(ContextTag::TAG_SETUP);
|
||||
|
||||
$sOperation = utils::ReadParam('operation');
|
||||
$this->aParameters = utils::ReadParam('_params', [], false, 'raw_data');
|
||||
$this->SetWizardSteps(json_decode(utils::ReadParam('_steps', '[]', false, 'raw_data'), true));
|
||||
// $this->aParameters = utils::ReadParam('_params', [], false, 'raw_data');
|
||||
// $this->SetWizardSteps(json_decode(utils::ReadParam('_steps', '[]', false, 'raw_data'), true));
|
||||
|
||||
switch ($sOperation) {
|
||||
case 'next':
|
||||
@@ -293,65 +293,6 @@ EOF
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides information about the structure/workflow of the wizard by listing
|
||||
* the possible list of 'steps' and their dependencies
|
||||
* @param string $sStep Name of the class to start from (used for recursion)
|
||||
* @param array $aAllSteps List of steps (used for recursion)
|
||||
*/
|
||||
public function DumpStructure($sStep = '', $aAllSteps = null)
|
||||
{
|
||||
if ($aAllSteps == null) {
|
||||
$aAllSteps = [];
|
||||
}
|
||||
if ($sStep == '') {
|
||||
$sStep = $this->sInitialStepClass;
|
||||
}
|
||||
|
||||
$oStep = $this->GetWizardStep($sStep);
|
||||
$aAllSteps[$sStep] = $oStep->GetPossibleSteps();
|
||||
foreach ($aAllSteps[$sStep] as $sNextStep) {
|
||||
if (!array_key_exists($sNextStep, $aAllSteps)) {
|
||||
$aAllSteps = $this->DumpStructure($sNextStep, $aAllSteps);
|
||||
}
|
||||
}
|
||||
|
||||
return $aAllSteps;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dump the wizard's structure as a string suitable to produce a chart
|
||||
* using graphviz's "dot" program
|
||||
* @return string The 'dot' formatted output
|
||||
*/
|
||||
public function DumpStructureAsDot()
|
||||
{
|
||||
$aAllSteps = $this->DumpStructure();
|
||||
$sOutput = "digraph finite_state_machine {\n";
|
||||
//$sOutput .= "\trankdir=LR;";
|
||||
$sOutput .= "\tsize=\"10,12\"\n";
|
||||
|
||||
$aDeadEnds = [$this->sInitialStepClass];
|
||||
foreach ($aAllSteps as $sStep => $aNextSteps) {
|
||||
if (count($aNextSteps) == 0) {
|
||||
$aDeadEnds[] = $sStep;
|
||||
}
|
||||
}
|
||||
$sOutput .= "\tnode [shape = doublecircle]; ".implode(' ', $aDeadEnds).";\n";
|
||||
$sOutput .= "\tnode [shape = box];\n";
|
||||
foreach ($aAllSteps as $sStep => $aNextSteps) {
|
||||
$oStep = $this->GetWizardStep($sStep);
|
||||
$sOutput .= "\t$sStep [ label = \"".$oStep->GetTitle()."\"];\n";
|
||||
if (count($aNextSteps) > 0) {
|
||||
foreach ($aNextSteps as $sNextStep) {
|
||||
$sOutput .= "\t$sStep -> $sNextStep;\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
$sOutput .= "}\n";
|
||||
return $sOutput;
|
||||
}
|
||||
|
||||
public function SetWizardSteps(array $aWizardSteps): void
|
||||
{
|
||||
$this->aWizardSteps = $aWizardSteps;
|
||||
@@ -371,4 +312,9 @@ EOF
|
||||
}
|
||||
return new $sCurrentStepClass($this, $sCurrentState);
|
||||
}
|
||||
|
||||
public function EraseParameters()
|
||||
{
|
||||
$this->oSessionParameters->Erase();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
*/
|
||||
|
||||
use Combodo\iTop\Application\WebPage\WebPage;
|
||||
use Combodo\iTop\Service\Session\SessionParameters;
|
||||
|
||||
/**
|
||||
* Summary of the installation tasks
|
||||
@@ -132,6 +133,7 @@ class WizStepDone extends WizardStep
|
||||
|
||||
if (false === $bHasBackup) {
|
||||
SetupUtils::EraseSetupToken();
|
||||
$this->oWizard->EraseParameters();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,6 +154,7 @@ class WizStepDone extends WizardStep
|
||||
public function AsyncAction(WebPage $oPage, $sCode, $aParameters)
|
||||
{
|
||||
SetupUtils::EraseSetupToken();
|
||||
$this->oWizard->EraseParameters();
|
||||
// For security reasons: add the extension now so that this action can be used to read *only* .tar.gz files from the disk...
|
||||
$sBackupFile = $aParameters['backup'].'.tar.gz';
|
||||
if (file_exists($sBackupFile)) {
|
||||
|
||||
@@ -61,6 +61,17 @@ class WizStepLandingBeforeAudit extends WizStepModulesChoice
|
||||
$this->oWizard->SetParameter('selected_extensions', json_encode($aExtensionsFromDatabase));
|
||||
$adModulesFromDatabase = ModuleInstallationRepository::GetInstance()->ReadComputeInstalledModules($oConfig);
|
||||
$this->oWizard->SetParameter('selected_modules', json_encode(array_keys($adModulesFromDatabase)));
|
||||
} else {
|
||||
$this->oWizard->SavePostedParameter('selected_modules');
|
||||
$this->oWizard->SavePostedParameter('selected_extensions');
|
||||
$this->oWizard->SavePostedParameter('added_extensions');
|
||||
$this->oWizard->SavePostedParameter('removed_extensions');
|
||||
$this->oWizard->SavePostedParameter('extensions_not_uninstallable');
|
||||
$this->oWizard->SavePostedParameter('copy_setup_files');
|
||||
$this->oWizard->SavePostedParameter('force-uninstall');
|
||||
$this->oWizard->SavePostedParameter('use_symbolic_links');
|
||||
$this->oWizard->SavePostedParameter('return_application');
|
||||
$this->oWizard->SavePostedParameter('target_env');
|
||||
}
|
||||
|
||||
$aWizardSteps = $this->GetWizardSteps();
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
*/
|
||||
|
||||
use Combodo\iTop\Service\Session\SessionParameters;
|
||||
|
||||
/**
|
||||
* First step of the iTop Installation Wizard: Welcome screen, requirements
|
||||
*/
|
||||
|
||||
@@ -187,15 +187,6 @@ abstract class WizardStep
|
||||
return 'return true;';
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells whether this step of the wizard requires that the configuration file be writable
|
||||
* @return bool True if the wizard will possibly need to modify the configuration at some point
|
||||
*/
|
||||
public function RequiresWritableConfig()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overload this function to implement asynchronous action(s) (AJAX)
|
||||
* @param string $sCode The code of the action (if several actions need to be distinguished)
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2026 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
namespace Combodo\iTop\Application\Helper;
|
||||
namespace Combodo\iTop\Service\Session;
|
||||
|
||||
use Combodo\iTop\SessionTracker\SessionHandler;
|
||||
|
||||
@@ -19,9 +19,9 @@ use Combodo\iTop\SessionTracker\SessionHandler;
|
||||
class Session
|
||||
{
|
||||
/** @var int|null */
|
||||
public static $iSessionId = null;
|
||||
public static bool|int|null $iSessionId = null;
|
||||
/** @var bool */
|
||||
public static $bAllowCLI = false;
|
||||
public static bool $bAllowCLI = false;
|
||||
|
||||
public static function Start()
|
||||
{
|
||||
@@ -47,7 +47,7 @@ class Session
|
||||
self::$iSessionId = session_id();
|
||||
}
|
||||
|
||||
public static function RegenerateId($bDeleteOldSession = false)
|
||||
public static function RegenerateId($bDeleteOldSession = false): void
|
||||
{
|
||||
if (session_status() === PHP_SESSION_DISABLED || headers_sent()) {
|
||||
return;
|
||||
@@ -61,7 +61,7 @@ class Session
|
||||
self::$iSessionId = session_id();
|
||||
}
|
||||
|
||||
public static function WriteClose()
|
||||
public static function WriteClose(): void
|
||||
{
|
||||
if (session_status() === PHP_SESSION_DISABLED) {
|
||||
return;
|
||||
@@ -76,7 +76,7 @@ class Session
|
||||
* @param string|array $key key to access to the session variable. To access to $_SESSION['a']['b'] $key must be ['a', 'b']
|
||||
* @param $value
|
||||
*/
|
||||
public static function Set($key, $value)
|
||||
public static function Set($key, $value): void
|
||||
{
|
||||
if (!isset($_SESSION) || self::Get($key) == $value) {
|
||||
return;
|
||||
@@ -103,7 +103,7 @@ class Session
|
||||
/**
|
||||
* @param string|array $key key to access to the session variable. To access to $_SESSION['a']['b'] $key must be ['a', 'b']
|
||||
*/
|
||||
public static function Unset($key)
|
||||
public static function Unset($key): void
|
||||
{
|
||||
if (self::IsSet($key)) {
|
||||
$aSession = $_SESSION;
|
||||
@@ -137,7 +137,7 @@ class Session
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function Get($key, $default = null)
|
||||
public static function Get($key, $default = null): mixed
|
||||
{
|
||||
if (isset($_SESSION)) {
|
||||
$aSession = $_SESSION;
|
||||
@@ -189,7 +189,7 @@ class Session
|
||||
/**
|
||||
* @return bool|string
|
||||
*/
|
||||
public static function GetLog()
|
||||
public static function GetLog(): string
|
||||
{
|
||||
return print_r($_SESSION, true);
|
||||
}
|
||||
96
sources/Service/Session/SessionParameters.php
Normal file
96
sources/Service/Session/SessionParameters.php
Normal file
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2026 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
namespace Combodo\iTop\Service\Session;
|
||||
|
||||
use IssueLog;
|
||||
use LogChannels;
|
||||
use utils;
|
||||
|
||||
class SessionParameters
|
||||
{
|
||||
private string $sSessionArrayName;
|
||||
private array $aParameters;
|
||||
|
||||
public function __construct(string $sParamsName)
|
||||
{
|
||||
$this->sSessionArrayName = $sParamsName;
|
||||
$this->aParameters = Session::Get($this->sSessionArrayName, []);
|
||||
IssueLog::Enable(APPROOT.'log/error.log');
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a "persistent" parameter from the wizard's context
|
||||
* @param string $sParamCode The code identifying this parameter
|
||||
* @param mixed $defaultValue The default value of the parameter in case it was not set
|
||||
*/
|
||||
public function GetParameter(string $sParamCode, mixed $defaultValue = '')
|
||||
{
|
||||
if (array_key_exists($sParamCode, $this->aParameters)) {
|
||||
return $this->aParameters[$sParamCode];
|
||||
}
|
||||
|
||||
return $defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores a "persistent" parameter in the wizard's context
|
||||
*
|
||||
* @param string $sParamCode The code identifying this parameter
|
||||
* @param mixed $value The value to store
|
||||
*/
|
||||
public function SetParameter($sParamCode, $value): void
|
||||
{
|
||||
$this->aParameters[$sParamCode] = $value;
|
||||
$this->Save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the value of the page's parameter in a "persistent" parameter in the wizard's context
|
||||
* @param string $sParamCode The code identifying this parameter
|
||||
* @param mixed $defaultValue The default value for the parameter
|
||||
* @param string $sSanitizationFilter A 'sanitization' fitler. Default is 'raw_data', which means no filtering
|
||||
*/
|
||||
public function SetParameterFromPostedParams(string $sParamCode, mixed $defaultValue, string $sSanitizationFilter = 'raw_data'): void
|
||||
{
|
||||
$value = utils::ReadPostedParam($sParamCode, $defaultValue, $sSanitizationFilter);
|
||||
$this->aParameters[$sParamCode] = $value;
|
||||
$this->Save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the value of the page's parameter in a "persistent" parameter in the wizard's context
|
||||
* @param string $sParamCode The code identifying this parameter
|
||||
* @param mixed $defaultValue The default value for the parameter
|
||||
* @param string $sSanitizationFilter A 'sanitization' fitler. Default is 'raw_data', which means no filtering
|
||||
*/
|
||||
public function SetParameterFromParams(string $sParamCode, mixed $defaultValue, string $sSanitizationFilter = 'raw_data'): void
|
||||
{
|
||||
$value = utils::ReadParam($sParamCode, $defaultValue, false, $sSanitizationFilter);
|
||||
$this->aParameters[$sParamCode] = $value;
|
||||
$this->Save();
|
||||
}
|
||||
|
||||
private function Save(): void
|
||||
{
|
||||
Session::Set($this->sSessionArrayName, $this->aParameters);
|
||||
}
|
||||
|
||||
public function Erase(): void
|
||||
{
|
||||
$this->aParameters = [];
|
||||
$this->Save();
|
||||
$this->LogParameters();
|
||||
}
|
||||
|
||||
public function LogParameters(): void
|
||||
{
|
||||
IssueLog::Debug('---------------------------------', LogChannels::SESSION_PARAMETERS);
|
||||
IssueLog::Debug(json_encode(Session::Get($this->sSessionArrayName, []), JSON_PRETTY_PRINT), LogChannels::SESSION_PARAMETERS);
|
||||
IssueLog::Debug('---------------------------------', LogChannels::SESSION_PARAMETERS);
|
||||
}
|
||||
}
|
||||
@@ -121,3 +121,6 @@ class_alias(\Combodo\iTop\PropertyType\ValueType\Leaf\ValueTypeText::class, 'Com
|
||||
class_alias(\Combodo\iTop\PropertyType\Serializer\XMLFormat\XMLFormatCSV::class, 'Combodo-XMLFormat-CSV');
|
||||
class_alias(\Combodo\iTop\PropertyType\Serializer\XMLFormat\XMLFormatValueAsId::class, 'Combodo-XMLFormat-ValueAsId');
|
||||
class_alias(\Combodo\iTop\PropertyType\Serializer\XMLFormat\XMLFormatFlatArray::class, 'Combodo-XMLFormat-FlatArray');
|
||||
|
||||
// Moved classes
|
||||
class_alias(\Combodo\iTop\Service\Session\Session::class, '\Combodo\iTop\Application\Helper\Session');
|
||||
|
||||
Reference in New Issue
Block a user