mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-12 23:14:18 +01:00
N°4789 - Parse datamodel module.xxx.php files instead of interpreting them (#746)
* N°4789 - Parse datamodel module.xxx.php files instead of interpreting them - refactoring all in a dedicated service first * N°4789 - fix broken setup + tests * N°4789 - replace legacy eval by module file parsing * N°4789 - handle constants and if conditional structures * N°4789 - compute boolean expressions * N°4789 - make autoselect and dependencies work as well * cleanup * N°4789 - fix BeforeWritingConfig calls during setup * N°4789 - refactor and split in ModuleDiscoveryEvaluationService + handle ModuleInstallerAPI methods calls during setup * N°4789 - PR review changes with Romain * PR review + code cleanup + added usecases and test cover * temp evaluation work * replace eval by iTop custom evaluation classes * move PhpParser/Evaluation classes in a specific namespave + composer dumpautoload * fix broken setup * fix broken setup * complete Evaluators list + autoload * cleanup useless testing resources * cleanup + replace last eval call in VariableEvaluator * fix few Evaluators code * enhance nikic evaluators + test with/without nikic lib * Evaluator fixes/enhancements + tests * bump to nikic fork temporarly * bump nikic-parser fork + use only nikic fork evaluation + cleanup itop redondant evaluators * review with Romain: use distinct whitelists in setup time/runtime + move ModuleFileParser internal logic into ModuleFileReader * PhpExpressionEvaluator used via constructor and not as a service * dumpautoload again after rebase
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -19,6 +19,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
use Combodo\iTop\PhpParser\Evaluation\PhpExpressionEvaluator;
|
||||
|
||||
require_once(APPROOT.'setup/modulediscovery/ModuleFileReader.php');
|
||||
|
||||
class MissingDependencyException extends CoreException
|
||||
{
|
||||
/**
|
||||
@@ -91,6 +95,9 @@ class ModuleDiscovery
|
||||
|
||||
// ModulePath is used by AddModule to get the path of the module being included (in ListModuleFiles)
|
||||
protected static $m_sModulePath = null;
|
||||
|
||||
private static PhpExpressionEvaluator $oPhpExpressionEvaluator;
|
||||
|
||||
protected static function SetModulePath($sModulePath)
|
||||
{
|
||||
self::$m_sModulePath = $sModulePath;
|
||||
@@ -105,6 +112,9 @@ class ModuleDiscovery
|
||||
*/
|
||||
public static function AddModule($sFilePath, $sId, $aArgs)
|
||||
{
|
||||
if (is_null($aArgs)||! is_array($aArgs)){
|
||||
throw new ModuleFileReaderException("Error parsing module file args", 0, null, $sFilePath);
|
||||
}
|
||||
if (!array_key_exists('itop_version', $aArgs))
|
||||
{
|
||||
// Assume 1.0.2
|
||||
@@ -115,7 +125,7 @@ class ModuleDiscovery
|
||||
if (!array_key_exists($sArgName, $aArgs))
|
||||
{
|
||||
throw new Exception("Module '$sId': missing argument '$sArgName'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$aArgs['root_dir'] = dirname($sFilePath);
|
||||
@@ -218,7 +228,7 @@ class ModuleDiscovery
|
||||
* @param array $aModulesToLoad List of modules to search for, defaults to all if omitted
|
||||
* @return array
|
||||
* @throws \MissingDependencyException
|
||||
*/
|
||||
*/
|
||||
public static function OrderModulesByDependencies($aModules, $bAbortOnMissingDependency = false, $aModulesToLoad = null)
|
||||
{
|
||||
// Order the modules to take into account their inter-dependencies
|
||||
@@ -303,6 +313,15 @@ class ModuleDiscovery
|
||||
return $aModules;
|
||||
}
|
||||
|
||||
private static function GetPhpExpressionEvaluator(): PhpExpressionEvaluator
|
||||
{
|
||||
if (!isset(static::$oPhpExpressionEvaluator)) {
|
||||
static::$oPhpExpressionEvaluator = new PhpExpressionEvaluator([], RunTimeEnvironment::STATIC_CALL_AUTOSELECT_WHITELIST);
|
||||
}
|
||||
|
||||
return static::$oPhpExpressionEvaluator;
|
||||
}
|
||||
|
||||
protected static function DependencyIsResolved($sDepString, $aOrderedModules, $aSelectedModules)
|
||||
{
|
||||
$bResult = false;
|
||||
@@ -349,19 +368,19 @@ class ModuleDiscovery
|
||||
if (version_compare($sCurrentVersion, $sExpectedVersion, $sOperator))
|
||||
{
|
||||
$aReplacements[$sModuleId] = '(true)'; // Add parentheses to protect against invalid condition causing
|
||||
// a function call that results in a runtime fatal error
|
||||
// a function call that results in a runtime fatal error
|
||||
}
|
||||
else
|
||||
{
|
||||
$aReplacements[$sModuleId] = '(false)'; // Add parentheses to protect against invalid condition causing
|
||||
// a function call that results in a runtime fatal error
|
||||
// a function call that results in a runtime fatal error
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// module is not present
|
||||
$aReplacements[$sModuleId] = '(false)'; // Add parentheses to protect against invalid condition causing
|
||||
// a function call that results in a runtime fatal error
|
||||
// a function call that results in a runtime fatal error
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -385,10 +404,10 @@ class ModuleDiscovery
|
||||
else
|
||||
{
|
||||
$sBooleanExpr = str_replace(array_keys($aReplacements), array_values($aReplacements), $sDepString);
|
||||
$bOk = @eval('$bResult = '.$sBooleanExpr.'; return true;');
|
||||
if ($bOk == false)
|
||||
{
|
||||
SetupLog::Warning("Eval of '$sBooleanExpr' returned false");
|
||||
try{
|
||||
$bResult = self::GetPhpExpressionEvaluator()->ParseAndEvaluateBooleanExpression($sBooleanExpr);
|
||||
} catch(ModuleFileReaderException $e){
|
||||
//logged already
|
||||
echo "Failed to parse the boolean Expression = '$sBooleanExpr'<br/>";
|
||||
}
|
||||
}
|
||||
@@ -496,42 +515,12 @@ class ModuleDiscovery
|
||||
else if (preg_match('/^module\.(.*).php$/i', $sFile, $aMatches))
|
||||
{
|
||||
self::SetModulePath($sRelDir);
|
||||
try
|
||||
{
|
||||
$sModuleFileContents = file_get_contents($sDirectory.'/'.$sFile);
|
||||
$sModuleFileContents = str_replace(array('<?php', '?>'), '', $sModuleFileContents);
|
||||
$sModuleFileContents = str_replace('__FILE__', "'".addslashes($sDirectory.'/'.$sFile)."'", $sModuleFileContents);
|
||||
preg_match_all('/class ([A-Za-z0-9_]+) extends ([A-Za-z0-9_]+)/', $sModuleFileContents, $aMatches);
|
||||
//print_r($aMatches);
|
||||
$idx = 0;
|
||||
foreach($aMatches[1] as $sClassName)
|
||||
{
|
||||
if (class_exists($sClassName))
|
||||
{
|
||||
// rename the class inside the code to prevent a "duplicate class" declaration
|
||||
// and change its parent class as well so that nobody will find it and try to execute it
|
||||
$sModuleFileContents = str_replace($sClassName.' extends '.$aMatches[2][$idx], $sClassName.'_'.($iDummyClassIndex++).' extends DummyHandler', $sModuleFileContents);
|
||||
}
|
||||
$idx++;
|
||||
}
|
||||
$bRet = eval($sModuleFileContents);
|
||||
|
||||
if ($bRet === false)
|
||||
{
|
||||
SetupLog::Warning("Eval of $sRelDir/$sFile returned false");
|
||||
}
|
||||
|
||||
//echo "<p>Done.</p>\n";
|
||||
}
|
||||
catch(ParseError $e)
|
||||
{
|
||||
// PHP 7
|
||||
SetupLog::Warning("Eval of $sRelDir/$sFile caused an exception: ".$e->getMessage()." at line ".$e->getLine());
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
// Continue...
|
||||
SetupLog::Warning("Eval of $sRelDir/$sFile caused an exception: ".$e->getMessage());
|
||||
$sModuleFilePath = $sDirectory.'/'.$sFile;
|
||||
try {
|
||||
$aModuleInfo = ModuleFileReader::GetInstance()->ReadModuleFileInformation($sDirectory.'/'.$sFile);
|
||||
SetupWebPage::AddModule($sModuleFilePath, $aModuleInfo[1], $aModuleInfo[2]);
|
||||
} catch(ModuleFileReaderException $e){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
302
setup/modulediscovery/ModuleFileReader.php
Normal file
302
setup/modulediscovery/ModuleFileReader.php
Normal file
@@ -0,0 +1,302 @@
|
||||
<?php
|
||||
|
||||
use Combodo\iTop\PhpParser\Evaluation\PhpExpressionEvaluator;
|
||||
|
||||
require_once __DIR__ . '/ModuleFileReaderException.php';
|
||||
require_once APPROOT . 'sources/PhpParser/Evaluation/PhpExpressionEvaluator.php';
|
||||
|
||||
class ModuleFileReader {
|
||||
private static ModuleFileReader $oInstance;
|
||||
private static int $iDummyClassIndex = 0;
|
||||
|
||||
private PhpExpressionEvaluator $oPhpExpressionEvaluator;
|
||||
|
||||
const FUNC_CALL_WHITELIST=[
|
||||
"function_exists",
|
||||
"class_exists",
|
||||
"method_exists"
|
||||
];
|
||||
|
||||
const STATIC_CALLWHITELIST=[
|
||||
"utils::GetItopVersionWikiSyntax"
|
||||
];
|
||||
|
||||
protected function __construct() {
|
||||
$this->oPhpExpressionEvaluator = new PhpExpressionEvaluator(static::FUNC_CALL_WHITELIST, static::STATIC_CALLWHITELIST);
|
||||
}
|
||||
|
||||
final public static function GetInstance(): ModuleFileReader {
|
||||
if (!isset(static::$oInstance)) {
|
||||
static::$oInstance = new static();
|
||||
}
|
||||
|
||||
return static::$oInstance;
|
||||
}
|
||||
|
||||
final public static function SetInstance(?ModuleFileReader $oInstance): void {
|
||||
static::$oInstance = $oInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the information from a module file (module.xxx.php)
|
||||
* @param string $sModuleFile
|
||||
* @return array
|
||||
* @throws ModuleFileReaderException
|
||||
*/
|
||||
public function ReadModuleFileInformation(string $sModuleFilePath) : array
|
||||
{
|
||||
try
|
||||
{
|
||||
$oParser = (new \PhpParser\ParserFactory())->createForNewestSupportedVersion();
|
||||
$aNodes = $oParser->parse(file_get_contents($sModuleFilePath));
|
||||
}
|
||||
catch (PhpParser\Error $e) {
|
||||
throw new \ModuleFileReaderException($e->getMessage(), 0, $e, $sModuleFilePath);
|
||||
}
|
||||
|
||||
try {
|
||||
foreach ($aNodes as $sKey => $oNode) {
|
||||
if ($oNode instanceof \PhpParser\Node\Stmt\Expression) {
|
||||
$aModuleInfo = $this->GetModuleInformationFromAddModuleCall($sModuleFilePath, $oNode);
|
||||
if (! is_null($aModuleInfo)){
|
||||
$this->CompleteModuleInfoWithFilePath($aModuleInfo);
|
||||
return $aModuleInfo;
|
||||
}
|
||||
}
|
||||
|
||||
if ($oNode instanceof PhpParser\Node\Stmt\If_) {
|
||||
$aModuleInfo = $this->GetModuleInformationFromIf($sModuleFilePath, $oNode);
|
||||
if (! is_null($aModuleInfo)){
|
||||
$this->CompleteModuleInfoWithFilePath($aModuleInfo);
|
||||
return $aModuleInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(ModuleFileReaderException $e) {
|
||||
// Continue...
|
||||
throw $e;
|
||||
} catch(Exception $e) {
|
||||
// Continue...
|
||||
throw new ModuleFileReaderException("Eval of $sModuleFilePath caused an exception: ".$e->getMessage(), 0, $e, $sModuleFilePath);
|
||||
}
|
||||
|
||||
throw new ModuleFileReaderException("No proper call to SetupWebPage::AddModule found in module file", 0, null, $sModuleFilePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the information from a module file (module.xxx.php)
|
||||
* Warning: this method is using eval() function to load the ModuleInstallerAPI classes.
|
||||
* Current method is never called at design/runtime. It is acceptable to use it during setup only.
|
||||
* @param string $sModuleFile
|
||||
* @return array
|
||||
* @throws ModuleFileReaderException
|
||||
*/
|
||||
public function ReadModuleFileInformationUnsafe(string $sModuleFilePath) : array
|
||||
{
|
||||
$aModuleInfo = []; // will be filled by the "eval" line below...
|
||||
try
|
||||
{
|
||||
$aMatches = [];
|
||||
$sModuleFileContents = file_get_contents($sModuleFilePath);
|
||||
$sModuleFileContents = str_replace(['<?php', '?>'], '', $sModuleFileContents);
|
||||
$sModuleFileContents = str_replace('__FILE__', "'".addslashes($sModuleFilePath)."'", $sModuleFileContents);
|
||||
preg_match_all('/class ([A-Za-z0-9_]+) extends ([A-Za-z0-9_]+)/', $sModuleFileContents, $aMatches);
|
||||
//print_r($aMatches);
|
||||
$idx = 0;
|
||||
foreach($aMatches[1] as $sClassName)
|
||||
{
|
||||
if (class_exists($sClassName))
|
||||
{
|
||||
// rename any class declaration inside the code to prevent a "duplicate class" declaration
|
||||
// and change its parent class as well so that nobody will find it and try to execute it
|
||||
// Note: don't use the same naming scheme as ModuleDiscovery otherwise you 'll have the duplicate class error again !!
|
||||
$sModuleFileContents = str_replace($sClassName.' extends '.$aMatches[2][$idx], $sClassName.'_Ext_'.(ModuleFileReader::$iDummyClassIndex++).' extends DummyHandler', $sModuleFileContents);
|
||||
}
|
||||
$idx++;
|
||||
}
|
||||
// Replace the main function call by an assignment to a variable, as an array...
|
||||
$sModuleFileContents = str_replace(['SetupWebPage::AddModule', 'ModuleDiscovery::AddModule'], '$aModuleInfo = array', $sModuleFileContents);
|
||||
eval($sModuleFileContents); // Assigns $aModuleInfo
|
||||
|
||||
if (count($aModuleInfo) === 0)
|
||||
{
|
||||
throw new ModuleFileReaderException("Eval of $sModuleFilePath did not return the expected information...");
|
||||
}
|
||||
|
||||
$this->CompleteModuleInfoWithFilePath($aModuleInfo);
|
||||
}
|
||||
catch(ModuleFileReaderException $e)
|
||||
{
|
||||
// Continue...
|
||||
throw $e;
|
||||
}
|
||||
catch(ParseError $e)
|
||||
{
|
||||
// Continue...
|
||||
throw new ModuleFileReaderException("Eval of $sModuleFilePath caused a parse error: ".$e->getMessage()." at line ".$e->getLine());
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
// Continue...
|
||||
throw new ModuleFileReaderException("Eval of $sModuleFilePath caused an exception: ".$e->getMessage(), 0, $e);
|
||||
}
|
||||
return $aModuleInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Internal trick: additional path is added into the module info structure to handle ModuleInstallerAPI execution during setup
|
||||
* @param array &$aModuleInfo
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function CompleteModuleInfoWithFilePath(array &$aModuleInfo)
|
||||
{
|
||||
if (count($aModuleInfo)==3) {
|
||||
$aModuleInfo[2]['module_file_path'] = $aModuleInfo[0];
|
||||
}
|
||||
}
|
||||
|
||||
public function GetAndCheckModuleInstallerClass($aModuleInfo) : ?string
|
||||
{
|
||||
if (! isset($aModuleInfo['installer'])){
|
||||
return null;
|
||||
}
|
||||
|
||||
$sModuleInstallerClass = $aModuleInfo['installer'];
|
||||
if (!class_exists($sModuleInstallerClass)) {
|
||||
$sModuleFilePath = $aModuleInfo['module_file_path'];
|
||||
$this->ReadModuleFileInformationUnsafe($sModuleFilePath);
|
||||
}
|
||||
|
||||
if (!class_exists($sModuleInstallerClass))
|
||||
{
|
||||
throw new CoreException("Wrong installer class: '$sModuleInstallerClass' is not a PHP class - Module: ".$aModuleInfo['label']);
|
||||
}
|
||||
if (!is_subclass_of($sModuleInstallerClass, 'ModuleInstallerAPI'))
|
||||
{
|
||||
throw new CoreException("Wrong installer class: '$sModuleInstallerClass' is not derived from 'ModuleInstallerAPI' - Module: ".$aModuleInfo['label']);
|
||||
}
|
||||
|
||||
return $sModuleInstallerClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sModuleFilePath
|
||||
* @param \PhpParser\Node\Expr\Assign $oAssignation
|
||||
*
|
||||
* @return array|null
|
||||
* @throws \ModuleFileReaderException
|
||||
*/
|
||||
private function GetModuleInformationFromAddModuleCall(string $sModuleFilePath, \PhpParser\Node\Stmt\Expression $oExpression) : ?array
|
||||
{
|
||||
/** @var Assign $oAssignation */
|
||||
$oAssignation = $oExpression->expr;
|
||||
if (false === ($oAssignation instanceof PhpParser\Node\Expr\StaticCall)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/** @var PhpParser\Node\Expr\StaticCall $oAssignation */
|
||||
|
||||
if ("SetupWebPage" !== $oAssignation?->class?->name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ("AddModule" !== $oAssignation?->name?->name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$aArgs = $oAssignation?->args;
|
||||
if (count($aArgs) != 3) {
|
||||
throw new ModuleFileReaderException("Not enough parameters when calling SetupWebPage::AddModule", 0, null, $sModuleFilePath);
|
||||
}
|
||||
|
||||
$oModuleId = $aArgs[1];
|
||||
if (false === ($oModuleId instanceof PhpParser\Node\Arg)) {
|
||||
throw new ModuleFileReaderException("2nd parameter to SetupWebPage::AddModule call issue: " . get_class($oModuleId), 0, null, $sModuleFilePath);
|
||||
}
|
||||
|
||||
/** @var PhpParser\Node\Arg $oModuleId */
|
||||
if (false === ($oModuleId->value instanceof PhpParser\Node\Scalar\String_)) {
|
||||
throw new ModuleFileReaderException("2nd parameter to SetupWebPage::AddModule not a string: " . get_class($oModuleId->value), 0, null, $sModuleFilePath);
|
||||
}
|
||||
|
||||
$sModuleId = $this->oPhpExpressionEvaluator->EvaluateExpression($oModuleId->value);
|
||||
|
||||
$oModuleConfigInfo = $aArgs[2];
|
||||
if (false === ($oModuleConfigInfo instanceof PhpParser\Node\Arg)) {
|
||||
throw new ModuleFileReaderException("3rd parameter to SetupWebPage::AddModule call issue: " . get_class($oModuleConfigInfo), 0, null, $sModuleFilePath);
|
||||
}
|
||||
|
||||
/** @var PhpParser\Node\Arg $oModuleConfigInfo */
|
||||
if (false === ($oModuleConfigInfo->value instanceof PhpParser\Node\Expr\Array_)) {
|
||||
throw new ModuleFileReaderException("3rd parameter to SetupWebPage::AddModule not an array: " . get_class($oModuleConfigInfo->value), 0, null, $sModuleFilePath);
|
||||
}
|
||||
|
||||
$aModuleConfig = $this->oPhpExpressionEvaluator->EvaluateExpression($oModuleConfigInfo->value);
|
||||
|
||||
if (! is_array($aModuleConfig)){
|
||||
throw new ModuleFileReaderException("3rd parameter to SetupWebPage::AddModule not an array: " . get_class($oModuleConfigInfo->value), 0, null, $sModuleFilePath);
|
||||
}
|
||||
|
||||
return [
|
||||
$sModuleFilePath,
|
||||
$sModuleId,
|
||||
$aModuleConfig,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sModuleFilePath
|
||||
* @param \PhpParser\Node\Stmt\If_ $oNode
|
||||
*
|
||||
* @return array|null
|
||||
* @throws \ModuleFileReaderException
|
||||
*/
|
||||
private function GetModuleInformationFromIf(string $sModuleFilePath, \PhpParser\Node\Stmt\If_ $oNode) : ?array
|
||||
{
|
||||
$bCondition = $this->oPhpExpressionEvaluator->EvaluateExpression($oNode->cond);
|
||||
if ($bCondition) {
|
||||
foreach ($oNode->stmts as $oSubNode) {
|
||||
if ($oSubNode instanceof \PhpParser\Node\Stmt\Expression) {
|
||||
$aModuleConfig = $this->GetModuleInformationFromAddModuleCall($sModuleFilePath, $oSubNode);
|
||||
if (!is_null($aModuleConfig)) {
|
||||
return $aModuleConfig;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (! is_null($oNode->elseifs)) {
|
||||
foreach ($oNode->elseifs as $oElseIfSubNode) {
|
||||
/** @var \PhpParser\Node\Stmt\ElseIf_ $oElseIfSubNode */
|
||||
$bCondition = $this->oPhpExpressionEvaluator->EvaluateExpression($oElseIfSubNode->cond);
|
||||
if ($bCondition) {
|
||||
return $this->GetModuleConfigurationFromStatement($sModuleFilePath, $oElseIfSubNode->stmts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! is_null($oNode->else)) {
|
||||
return $this->GetModuleConfigurationFromStatement($sModuleFilePath, $oNode->else->stmts);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private function GetModuleConfigurationFromStatement(string $sModuleFilePath, array $aStmts) : ?array
|
||||
{
|
||||
foreach ($aStmts as $oSubNode) {
|
||||
if ($oSubNode instanceof \PhpParser\Node\Stmt\Expression) {
|
||||
$aModuleConfig = $this->GetModuleInformationFromAddModuleCall($sModuleFilePath, $oSubNode);
|
||||
if (!is_null($aModuleConfig)) {
|
||||
return $aModuleConfig;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
23
setup/modulediscovery/ModuleFileReaderException.php
Normal file
23
setup/modulediscovery/ModuleFileReaderException.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
class ModuleFileReaderException extends Exception
|
||||
{
|
||||
/**
|
||||
* ModuleFileReaderException constructor.
|
||||
*
|
||||
* @param string $sMessage
|
||||
* @param int $iHttpCode
|
||||
* @param Exception|null $oPrevious
|
||||
*/
|
||||
public function __construct($sMessage, $iHttpCode = 0, Exception $oPrevious = null, $sModuleFile = null)
|
||||
{
|
||||
$e = new \Exception("");
|
||||
|
||||
$aContext = ['previous' => $oPrevious?->getMessage(), 'stack' => $e->getTraceAsString()];
|
||||
if (!is_null($sModuleFile)) {
|
||||
$aContext['module_file'] = $sModuleFile;
|
||||
}
|
||||
SetupLog::Warning($sMessage, null, $aContext);
|
||||
parent::__construct($sMessage, $iHttpCode, $oPrevious);
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,8 @@
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
use Combodo\iTop\PhpParser\Evaluation\PhpExpressionEvaluator;
|
||||
|
||||
require_once APPROOT."setup/modulediscovery.class.inc.php";
|
||||
require_once APPROOT.'setup/modelfactory.class.inc.php';
|
||||
require_once APPROOT.'setup/compiler.class.inc.php';
|
||||
@@ -39,6 +41,10 @@ define ('DATAMODEL_MODULE', 'datamodel'); // Convention to store the version of
|
||||
|
||||
class RunTimeEnvironment
|
||||
{
|
||||
const STATIC_CALL_AUTOSELECT_WHITELIST=[
|
||||
"SetupInfo::ModuleIsSelected"
|
||||
];
|
||||
|
||||
/**
|
||||
* The name of the environment that the caller wants to build
|
||||
* @var string sFinalEnv
|
||||
@@ -202,10 +208,10 @@ class RunTimeEnvironment
|
||||
if (!in_array($sModuleAppVersion, array('1.0.0', '1.0.1', '1.0.2')))
|
||||
{
|
||||
// This module is NOT compatible with the current version
|
||||
$aModuleInfo['install'] = array(
|
||||
'flag' => MODULE_ACTION_IMPOSSIBLE,
|
||||
'message' => 'the module is not compatible with the current version of the application'
|
||||
);
|
||||
$aModuleInfo['install'] = array(
|
||||
'flag' => MODULE_ACTION_IMPOSSIBLE,
|
||||
'message' => 'the module is not compatible with the current version of the application'
|
||||
);
|
||||
}
|
||||
elseif ($aModuleInfo['mandatory'])
|
||||
{
|
||||
@@ -448,6 +454,8 @@ class RunTimeEnvironment
|
||||
}
|
||||
}
|
||||
|
||||
$oPhpExpressionEvaluator = new PhpExpressionEvaluator([], RunTimeEnvironment::STATIC_CALL_AUTOSELECT_WHITELIST);
|
||||
|
||||
// Now process the 'AutoSelect' modules
|
||||
do
|
||||
{
|
||||
@@ -457,20 +465,16 @@ class RunTimeEnvironment
|
||||
{
|
||||
if (!array_key_exists($oModule->GetName(), $aRet) && $oModule->IsAutoSelect())
|
||||
{
|
||||
try
|
||||
{
|
||||
$bSelected = false;
|
||||
SetupInfo::SetSelectedModules($aRet);
|
||||
eval('$bSelected = ('.$oModule->GetAutoSelect().');');
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
$bSelected = false;
|
||||
}
|
||||
if ($bSelected)
|
||||
{
|
||||
$aRet[$oModule->GetName()] = $oModule; // store the Id of the selected module
|
||||
$bModuleAdded = true;
|
||||
SetupInfo::SetSelectedModules($aRet);
|
||||
try{
|
||||
$bSelected = $oPhpExpressionEvaluator->ParseAndEvaluateBooleanExpression($oModule->GetAutoSelect());
|
||||
if ($bSelected)
|
||||
{
|
||||
$aRet[$oModule->GetName()] = $oModule; // store the Id of the selected module
|
||||
$bModuleAdded = true;
|
||||
}
|
||||
} catch(ModuleFileReaderException $e){
|
||||
//do nothing. logged already
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -977,8 +981,8 @@ class RunTimeEnvironment
|
||||
$this->CommitDir(
|
||||
APPROOT.'env-'.$this->sTargetEnv,
|
||||
APPROOT.'env-'.$this->sFinalEnv,
|
||||
true,
|
||||
false
|
||||
true,
|
||||
false
|
||||
);
|
||||
|
||||
// Move the config file
|
||||
@@ -1045,7 +1049,7 @@ class RunTimeEnvironment
|
||||
* @param $sSource
|
||||
* @param $sDest
|
||||
* @param boolean $bSourceMustExist
|
||||
* @param boolean $bRemoveSource If true $sSource will be removed, otherwise $sSource will just be emptied
|
||||
* @param boolean $bRemoveSource If true $sSource will be removed, otherwise $sSource will just be emptied
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function CommitDir($sSource, $sDest, $bSourceMustExist = true, $bRemoveSource = true)
|
||||
@@ -1080,41 +1084,59 @@ class RunTimeEnvironment
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call the given handler method for all selected modules having an installation handler
|
||||
* @param array[] $aAvailableModules
|
||||
* @param string[] $aSelectedModules
|
||||
* @param string $sHandlerName
|
||||
* @throws CoreException
|
||||
*/
|
||||
/**
|
||||
* Call the given handler method for all selected modules having an installation handler
|
||||
* @param array[] $aAvailableModules
|
||||
* @param string[] $aSelectedModules
|
||||
* @param string $sHandlerName
|
||||
* @throws CoreException
|
||||
*/
|
||||
public function CallInstallerHandlers($aAvailableModules, $aSelectedModules, $sHandlerName)
|
||||
{
|
||||
foreach($aAvailableModules as $sModuleId => $aModule)
|
||||
{
|
||||
if (($sModuleId != ROOT_MODULE) && in_array($sModuleId, $aSelectedModules) &&
|
||||
isset($aAvailableModules[$sModuleId]['installer']) )
|
||||
{
|
||||
$sModuleInstallerClass = $aAvailableModules[$sModuleId]['installer'];
|
||||
SetupLog::Info("Calling Module Handler: $sModuleInstallerClass::$sHandlerName(oConfig, {$aModule['version_db']}, {$aModule['version_code']})");
|
||||
$aCallSpec = array($sModuleInstallerClass, $sHandlerName);
|
||||
if (is_callable($aCallSpec))
|
||||
{
|
||||
try {
|
||||
call_user_func_array($aCallSpec, array(MetaModel::GetConfig(), $aModule['version_db'], $aModule['version_code']));
|
||||
} catch (Exception $e) {
|
||||
$sErrorMessage = "Module $sModuleId : error when calling module installer class $sModuleInstallerClass for $sHandlerName handler";
|
||||
$aExceptionContextData = [
|
||||
'ModulelId' => $sModuleId,
|
||||
'ModuleInstallerClass' => $sModuleInstallerClass,
|
||||
'ModuleInstallerHandler' => $sHandlerName,
|
||||
'ExceptionClass' => get_class($e),
|
||||
'ExceptionMessage' => $e->getMessage(),
|
||||
];
|
||||
throw new CoreException($sErrorMessage, $aExceptionContextData, '', $e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach($aAvailableModules as $sModuleId => $aModule)
|
||||
{
|
||||
if (($sModuleId != ROOT_MODULE) && in_array($sModuleId, $aSelectedModules))
|
||||
{
|
||||
$aArgs = [MetaModel::GetConfig(), $aModule['version_db'], $aModule['version_code']];
|
||||
RunTimeEnvironment::CallInstallerHandler($aAvailableModules[$sModuleId], $sHandlerName, $aArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call the given handler method for all selected modules having an installation handler
|
||||
*
|
||||
* @param array $aModuleInfo
|
||||
* @param string $sHandlerName
|
||||
* @param array $aArgs
|
||||
*
|
||||
* @throws CoreException
|
||||
*/
|
||||
public static function CallInstallerHandler(array $aModuleInfo, $sHandlerName, array $aArgs)
|
||||
{
|
||||
$sModuleInstallerClass = ModuleFileReader::GetInstance()->GetAndCheckModuleInstallerClass($aModuleInfo);
|
||||
if (is_null($sModuleInstallerClass)){
|
||||
return;
|
||||
}
|
||||
|
||||
SetupLog::Info("Calling Module Handler: $sModuleInstallerClass::$sHandlerName", null, $aArgs);
|
||||
$aCallSpec = [$sModuleInstallerClass, $sHandlerName];
|
||||
if (is_callable($aCallSpec))
|
||||
{
|
||||
try {
|
||||
call_user_func_array($aCallSpec, $aArgs);
|
||||
} catch (Exception $e) {
|
||||
$sErrorMessage = "Module $sModuleId : error when calling module installer class $sModuleInstallerClass for $sHandlerName handler";
|
||||
$aExceptionContextData = [
|
||||
'ModulelId' => $sModuleId,
|
||||
'ModuleInstallerClass' => $sModuleInstallerClass,
|
||||
'ModuleInstallerHandler' => $sHandlerName,
|
||||
'ExceptionClass' => get_class($e),
|
||||
'ExceptionMessage' => $e->getMessage(),
|
||||
];
|
||||
throw new CoreException($sErrorMessage, $aExceptionContextData, '', $e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1143,64 +1165,64 @@ class RunTimeEnvironment
|
||||
if ($aModule['version_db'] != '') {
|
||||
// Simulate the load of the previously loaded XML files to get the mapping of the keys
|
||||
if ($bSampleData) {
|
||||
$aPreviouslyLoadedFiles = static::MergeWithRelativeDir($aPreviouslyLoadedFiles, $sRelativePath, $aAvailableModules[$sModuleId]['data.struct']);
|
||||
$aPreviouslyLoadedFiles = static::MergeWithRelativeDir($aPreviouslyLoadedFiles, $sRelativePath, $aAvailableModules[$sModuleId]['data.sample']);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Load only structural data
|
||||
$aPreviouslyLoadedFiles = static::MergeWithRelativeDir($aPreviouslyLoadedFiles, $sRelativePath, $aAvailableModules[$sModuleId]['data.struct']);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($bSampleData)
|
||||
{
|
||||
$aFiles = static::MergeWithRelativeDir($aFiles, $sRelativePath, $aAvailableModules[$sModuleId]['data.struct']);
|
||||
$aFiles = static::MergeWithRelativeDir($aFiles, $sRelativePath, $aAvailableModules[$sModuleId]['data.sample']);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Load only structural data
|
||||
$aFiles = static::MergeWithRelativeDir($aFiles, $sRelativePath, $aAvailableModules[$sModuleId]['data.struct']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$aPreviouslyLoadedFiles = static::MergeWithRelativeDir($aPreviouslyLoadedFiles, $sRelativePath, $aAvailableModules[$sModuleId]['data.struct']);
|
||||
$aPreviouslyLoadedFiles = static::MergeWithRelativeDir($aPreviouslyLoadedFiles, $sRelativePath, $aAvailableModules[$sModuleId]['data.sample']);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Load only structural data
|
||||
$aPreviouslyLoadedFiles = static::MergeWithRelativeDir($aPreviouslyLoadedFiles, $sRelativePath, $aAvailableModules[$sModuleId]['data.struct']);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($bSampleData)
|
||||
{
|
||||
$aFiles = static::MergeWithRelativeDir($aFiles, $sRelativePath, $aAvailableModules[$sModuleId]['data.struct']);
|
||||
$aFiles = static::MergeWithRelativeDir($aFiles, $sRelativePath, $aAvailableModules[$sModuleId]['data.sample']);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Load only structural data
|
||||
$aFiles = static::MergeWithRelativeDir($aFiles, $sRelativePath, $aAvailableModules[$sModuleId]['data.struct']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Simulate the load of the previously loaded files, in order to initialize
|
||||
// the mapping between the identifiers in the XML and the actual identifiers
|
||||
// in the current database
|
||||
foreach($aPreviouslyLoadedFiles as $sFileRelativePath)
|
||||
{
|
||||
$sFileName = APPROOT.$sFileRelativePath;
|
||||
SetupLog::Info("Loading file: $sFileName (just to get the keys mapping)");
|
||||
if (empty($sFileName) || !file_exists($sFileName))
|
||||
{
|
||||
throw(new Exception("File $sFileName does not exist"));
|
||||
}
|
||||
// Simulate the load of the previously loaded files, in order to initialize
|
||||
// the mapping between the identifiers in the XML and the actual identifiers
|
||||
// in the current database
|
||||
foreach($aPreviouslyLoadedFiles as $sFileRelativePath)
|
||||
{
|
||||
$sFileName = APPROOT.$sFileRelativePath;
|
||||
SetupLog::Info("Loading file: $sFileName (just to get the keys mapping)");
|
||||
if (empty($sFileName) || !file_exists($sFileName))
|
||||
{
|
||||
throw(new Exception("File $sFileName does not exist"));
|
||||
}
|
||||
|
||||
$oDataLoader->LoadFile($sFileName, true);
|
||||
$sResult = sprintf("loading of %s done.", basename($sFileName));
|
||||
SetupLog::Info($sResult);
|
||||
}
|
||||
$oDataLoader->LoadFile($sFileName, true);
|
||||
$sResult = sprintf("loading of %s done.", basename($sFileName));
|
||||
SetupLog::Info($sResult);
|
||||
}
|
||||
|
||||
foreach($aFiles as $sFileRelativePath)
|
||||
{
|
||||
$sFileName = APPROOT.$sFileRelativePath;
|
||||
SetupLog::Info("Loading file: $sFileName");
|
||||
if (empty($sFileName) || !file_exists($sFileName))
|
||||
{
|
||||
throw(new Exception("File $sFileName does not exist"));
|
||||
}
|
||||
foreach($aFiles as $sFileRelativePath)
|
||||
{
|
||||
$sFileName = APPROOT.$sFileRelativePath;
|
||||
SetupLog::Info("Loading file: $sFileName");
|
||||
if (empty($sFileName) || !file_exists($sFileName))
|
||||
{
|
||||
throw(new Exception("File $sFileName does not exist"));
|
||||
}
|
||||
|
||||
$oDataLoader->LoadFile($sFileName);
|
||||
$sResult = sprintf("loading of %s done.", basename($sFileName));
|
||||
SetupLog::Info($sResult);
|
||||
}
|
||||
$oDataLoader->LoadFile($sFileName);
|
||||
$sResult = sprintf("loading of %s done.", basename($sFileName));
|
||||
SetupLog::Info($sResult);
|
||||
}
|
||||
|
||||
$oDataLoader->EndSession();
|
||||
$oDataLoader->EndSession();
|
||||
SetupLog::Info("ending data load session");
|
||||
}
|
||||
|
||||
@@ -1213,12 +1235,12 @@ class RunTimeEnvironment
|
||||
*/
|
||||
protected static function MergeWithRelativeDir($aSourceArray, $sBaseDir, $aFilesToMerge)
|
||||
{
|
||||
$aToMerge = array();
|
||||
foreach($aFilesToMerge as $sFile)
|
||||
{
|
||||
$aToMerge[] = $sBaseDir.'/'.$sFile;
|
||||
}
|
||||
return array_merge($aSourceArray, $aToMerge);
|
||||
$aToMerge = array();
|
||||
foreach($aFilesToMerge as $sFile)
|
||||
{
|
||||
$aToMerge[] = $sBaseDir.'/'.$sFile;
|
||||
}
|
||||
return array_merge($aSourceArray, $aToMerge);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1227,40 +1249,40 @@ class RunTimeEnvironment
|
||||
* @throws Exception
|
||||
* @return string
|
||||
*/
|
||||
public function CheckMetaModel()
|
||||
{
|
||||
$iCount = 0;
|
||||
$fStart = microtime(true);
|
||||
foreach(MetaModel::GetClasses() as $sClass)
|
||||
{
|
||||
if (false == MetaModel::HasTable($sClass) && MetaModel::IsAbstract($sClass))
|
||||
{
|
||||
//if a class is not persisted and is abstract, the code below would crash. Needed by the class AbstractRessource. This is tolerable to skip this because we check the setup process integrity, not the datamodel integrity.
|
||||
continue;
|
||||
}
|
||||
public function CheckMetaModel()
|
||||
{
|
||||
$iCount = 0;
|
||||
$fStart = microtime(true);
|
||||
foreach(MetaModel::GetClasses() as $sClass)
|
||||
{
|
||||
if (false == MetaModel::HasTable($sClass) && MetaModel::IsAbstract($sClass))
|
||||
{
|
||||
//if a class is not persisted and is abstract, the code below would crash. Needed by the class AbstractRessource. This is tolerable to skip this because we check the setup process integrity, not the datamodel integrity.
|
||||
continue;
|
||||
}
|
||||
|
||||
$oSearch = new DBObjectSearch($sClass);
|
||||
$oSearch->SetShowObsoleteData(false);
|
||||
$oSQLQuery = $oSearch->GetSQLQueryStructure(null, false);
|
||||
$sViewName = MetaModel::DBGetView($sClass);
|
||||
if (strlen($sViewName) > 64)
|
||||
{
|
||||
throw new Exception("Class name too long for class: '$sClass'. The name of the corresponding view ($sViewName) would exceed MySQL's limit for the name of a table (64 characters).");
|
||||
}
|
||||
$sTableName = MetaModel::DBGetTable($sClass);
|
||||
if (strlen($sTableName) > 64)
|
||||
{
|
||||
throw new Exception("Table name too long for class: '$sClass'. The name of the corresponding MySQL table ($sTableName) would exceed MySQL's limit for the name of a table (64 characters).");
|
||||
}
|
||||
$iTableCount = $oSQLQuery->CountTables();
|
||||
if ($iTableCount > 61)
|
||||
{
|
||||
throw new Exception("Class requiring too many tables: '$sClass'. The structure of the class ($sClass) would require a query with more than 61 JOINS (MySQL's limitation).");
|
||||
}
|
||||
$iCount++;
|
||||
}
|
||||
$fDuration = microtime(true) - $fStart;
|
||||
$oSearch = new DBObjectSearch($sClass);
|
||||
$oSearch->SetShowObsoleteData(false);
|
||||
$oSQLQuery = $oSearch->GetSQLQueryStructure(null, false);
|
||||
$sViewName = MetaModel::DBGetView($sClass);
|
||||
if (strlen($sViewName) > 64)
|
||||
{
|
||||
throw new Exception("Class name too long for class: '$sClass'. The name of the corresponding view ($sViewName) would exceed MySQL's limit for the name of a table (64 characters).");
|
||||
}
|
||||
$sTableName = MetaModel::DBGetTable($sClass);
|
||||
if (strlen($sTableName) > 64)
|
||||
{
|
||||
throw new Exception("Table name too long for class: '$sClass'. The name of the corresponding MySQL table ($sTableName) would exceed MySQL's limit for the name of a table (64 characters).");
|
||||
}
|
||||
$iTableCount = $oSQLQuery->CountTables();
|
||||
if ($iTableCount > 61)
|
||||
{
|
||||
throw new Exception("Class requiring too many tables: '$sClass'. The structure of the class ($sClass) would require a query with more than 61 JOINS (MySQL's limitation).");
|
||||
}
|
||||
$iCount++;
|
||||
}
|
||||
$fDuration = microtime(true) - $fStart;
|
||||
|
||||
return sprintf("Checked %d classes in %.1f ms. No error found.\n", $iCount, $fDuration*1000.0);
|
||||
}
|
||||
return sprintf("Checked %d classes in %.1f ms. No error found.\n", $iCount, $fDuration*1000.0);
|
||||
}
|
||||
} // End of class
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Combodo\iTop\PhpParser\Evaluation\PhpExpressionEvaluator;
|
||||
|
||||
require_once(APPROOT.'/application/utils.inc.php');
|
||||
require_once(APPROOT.'/setup/setuppage.class.inc.php');
|
||||
require_once(APPROOT.'/setup/wizardcontroller.class.inc.php');
|
||||
@@ -266,19 +268,22 @@ class InstallationFileService {
|
||||
}
|
||||
|
||||
public function ProcessAutoSelectModules() : void {
|
||||
$oPhpExpressionEvaluator = new PhpExpressionEvaluator([], RunTimeEnvironment::STATIC_CALL_AUTOSELECT_WHITELIST);
|
||||
|
||||
foreach($this->GetAutoSelectModules() as $sModuleId => $aModule)
|
||||
{
|
||||
try {
|
||||
$bSelected = false;
|
||||
SetupInfo::SetSelectedModules($this->aSelectedModules);
|
||||
eval('$bSelected = ('.$aModule['auto_select'].');');
|
||||
|
||||
$bSelected = $oPhpExpressionEvaluator->ParseAndEvaluateBooleanExpression($aModule['auto_select']);
|
||||
if ($bSelected)
|
||||
{
|
||||
// Modules in data/production-modules/ are considered as mandatory and always installed
|
||||
$this->aSelectedModules[$sModuleId] = true;
|
||||
}
|
||||
}
|
||||
catch (Exception $e) {
|
||||
catch (ModuleFileReaderException $e) {
|
||||
//logged already
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
*/
|
||||
|
||||
use Combodo\iTop\Application\WebPage\WebPage;
|
||||
use Combodo\iTop\PhpParser\Evaluation\PhpExpressionEvaluator;
|
||||
|
||||
require_once(APPROOT.'setup/setuputils.class.inc.php');
|
||||
require_once(APPROOT.'setup/parameters.class.inc.php');
|
||||
@@ -90,7 +91,7 @@ class WizStepWelcome extends WizardStep
|
||||
|
||||
$oPage->add("<!--[if lt IE 11]><div id=\"old_ie\"></div><![endif]-->");
|
||||
$oPage->add_ready_script(
|
||||
<<<EOF
|
||||
<<<EOF
|
||||
if ($('#old_ie').length > 0)
|
||||
{
|
||||
alert("Internet Explorer version 10 or older is NOT supported! (Check that IE is not running in compatibility mode)");
|
||||
@@ -144,7 +145,7 @@ EOF
|
||||
$sH2Class = 'text-valid';
|
||||
}
|
||||
$oPage->add(
|
||||
<<<HTML
|
||||
<<<HTML
|
||||
<h2 class="message">Prerequisites validation: <span class="$sH2Class">$sTitle</span></h2>
|
||||
<div id="details" $sStyle>
|
||||
HTML
|
||||
@@ -271,12 +272,12 @@ class WizStepInstallOrUpgrade extends WizardStep
|
||||
}
|
||||
$oPage->add('<div class="setup-content-title">What do you want to do?</div>');
|
||||
$sChecked = ($sInstallMode == 'install') ? ' checked ' : '';
|
||||
$oPage->p('<input id="radio_install" type="radio" name="install_mode" value="install" '.$sChecked.'/><label for="radio_install"> Install a new '.ITOP_APPLICATION.'</label>');
|
||||
$oPage->p('<input id="radio_install" type="radio" name="install_mode" value="install" '.$sChecked.'/><label for="radio_install"> Install a new '.ITOP_APPLICATION.'</label>');
|
||||
$sChecked = ($sInstallMode == 'upgrade') ? ' checked ' : '';
|
||||
$sDisabled = (($sInstallMode == 'install') && (empty($sPreviousVersionDir))) ? ' disabled' : '';
|
||||
$oPage->p('<input id="radio_update" type="radio" name="install_mode" value="upgrade" '.$sChecked.$sDisabled.'/><label for="radio_update"> Upgrade an existing '.ITOP_APPLICATION.' instance</label>');
|
||||
$oPage->p('<input id="radio_update" type="radio" name="install_mode" value="upgrade" '.$sChecked.$sDisabled.'/><label for="radio_update"> Upgrade an existing '.ITOP_APPLICATION.' instance</label>');
|
||||
|
||||
$sUpgradeDir = utils::HtmlEntities($sPreviousVersionDir);
|
||||
$sUpgradeDir = utils::HtmlEntities($sPreviousVersionDir);
|
||||
$oPage->add(<<<HTML
|
||||
<div id="upgrade_info"'.$sUpgradeInfoStyle.'>
|
||||
<div class="setup-disk-location--input--container">Location on the disk:<input id="previous_version_dir_display" type="text" value="$sUpgradeDir" class="ibo-input" disabled>
|
||||
@@ -319,7 +320,7 @@ HTML
|
||||
$oPage->add('<input type="hidden" id="authent_token" value="'.$sAuthentToken.'"/>');
|
||||
//$oPage->add('</fieldset>');
|
||||
$oPage->add_ready_script(
|
||||
<<<JS
|
||||
<<<JS
|
||||
$("#radio_update").on('change', function() { if (this.checked ) { $('#upgrade_info').show(); WizardUpdateButtons(); } else { $('#upgrade_info').hide(); } });
|
||||
$("#radio_install").on('change', function() { if (this.checked ) { $('#upgrade_info').hide(); WizardUpdateButtons(); } else { $('#upgrade_info').show(); } });
|
||||
$("#db_backup_path").on('change keyup', function() { WizardAsyncAction('check_backup', { db_backup_path: $('#db_backup_path').val() }); });
|
||||
@@ -350,12 +351,12 @@ JS
|
||||
$("#db_pwd").trigger('change'); // Forces check of the DB connection
|
||||
EOF
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'check_db':
|
||||
SetupUtils:: AsyncCheckDB($oPage, $aParameters);
|
||||
break;
|
||||
SetupUtils:: AsyncCheckDB($oPage, $aParameters);
|
||||
break;
|
||||
|
||||
case 'check_backup':
|
||||
$sDBBackupPath = $aParameters['db_backup_path'];
|
||||
@@ -372,9 +373,9 @@ EOF
|
||||
<<<EOF
|
||||
$("#backup_info").html('');
|
||||
EOF
|
||||
);
|
||||
}
|
||||
break;
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -385,7 +386,7 @@ EOF
|
||||
public function JSCanMoveForward()
|
||||
{
|
||||
return
|
||||
<<<EOF
|
||||
<<<EOF
|
||||
if ($("#radio_install").prop("checked"))
|
||||
{
|
||||
ValidateField("db_name", false);
|
||||
@@ -403,7 +404,7 @@ EOF
|
||||
return bRet;
|
||||
}
|
||||
EOF
|
||||
;
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -436,19 +437,19 @@ class WizStepDetectedInfo extends WizardStep
|
||||
switch ($sUpgradeType)
|
||||
{
|
||||
case 'keep-previous':
|
||||
$sSourceDir = utils::ReadParam('relative_source_dir', '', false, 'raw_data');
|
||||
$this->oWizard->SetParameter('source_dir', $this->oWizard->GetParameter('previous_version_dir').'/'.$sSourceDir);
|
||||
$this->oWizard->SetParameter('datamodel_version', utils::ReadParam('datamodel_previous_version', '', false, 'raw_data'));
|
||||
break;
|
||||
$sSourceDir = utils::ReadParam('relative_source_dir', '', false, 'raw_data');
|
||||
$this->oWizard->SetParameter('source_dir', $this->oWizard->GetParameter('previous_version_dir').'/'.$sSourceDir);
|
||||
$this->oWizard->SetParameter('datamodel_version', utils::ReadParam('datamodel_previous_version', '', false, 'raw_data'));
|
||||
break;
|
||||
|
||||
case 'use-compatible':
|
||||
$sDataModelPath = utils::ReadParam('datamodel_path', '', false, 'raw_data');
|
||||
$this->oWizard->SetParameter('source_dir', $sDataModelPath);
|
||||
$this->oWizard->SaveParameter('datamodel_version', '');
|
||||
break;
|
||||
$sDataModelPath = utils::ReadParam('datamodel_path', '', false, 'raw_data');
|
||||
$this->oWizard->SetParameter('source_dir', $sDataModelPath);
|
||||
$this->oWizard->SaveParameter('datamodel_version', '');
|
||||
break;
|
||||
|
||||
default:
|
||||
// Do nothing, maybe the user pressed the Back button
|
||||
// Do nothing, maybe the user pressed the Back button
|
||||
}
|
||||
if ($bDisplayLicense)
|
||||
{
|
||||
@@ -469,7 +470,7 @@ class WizStepDetectedInfo extends WizardStep
|
||||
public function Display(WebPage $oPage)
|
||||
{
|
||||
$oPage->add_style(
|
||||
<<<EOF
|
||||
<<<EOF
|
||||
#changes_summary {
|
||||
max-height: 200px;
|
||||
overflow: auto;
|
||||
@@ -604,9 +605,9 @@ EOF
|
||||
// No changes detected... or no way to tell because of the lack of a manifest or previous source dir
|
||||
// Use the "compatible" datamodel as-is.
|
||||
$sCompatibleDMDirToDisplay = utils::HtmlEntities($sCompatibleDMDir);
|
||||
$sUpgradeDMVersionToDisplay = utils::HtmlEntities($sUpgradeDMVersion);
|
||||
$sUpgradeDMVersionToDisplay = utils::HtmlEntities($sUpgradeDMVersion);
|
||||
$oPage->add(
|
||||
<<<HTML
|
||||
<<<HTML
|
||||
<div class="message message-valid">The datamodel will be upgraded from version $sInstalledDataModelVersion to version $sUpgradeDMVersion.</div>
|
||||
<input type="hidden" name="upgrade_type" value="use-compatible">
|
||||
<input type="hidden" name="datamodel_path" value="$sCompatibleDMDirToDisplay">
|
||||
@@ -617,7 +618,7 @@ HTML
|
||||
}
|
||||
|
||||
$oPage->add_ready_script(
|
||||
<<<EOF
|
||||
<<<EOF
|
||||
$("#changes_summary .title").on('click', function() { $(this).parent().toggleClass('closed'); } );
|
||||
$('input[name=upgrade_type]').on('click change', function() { WizardUpdateButtons(); });
|
||||
EOF
|
||||
@@ -650,13 +651,13 @@ EOF
|
||||
public function JSCanMoveForward()
|
||||
{
|
||||
return
|
||||
<<<EOF
|
||||
<<<EOF
|
||||
if ($("#radio_upgrade_keep").length == 0) return true;
|
||||
|
||||
bRet = ($('input[name=upgrade_type]:checked').length > 0);
|
||||
return bRet;
|
||||
EOF
|
||||
;
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -695,55 +696,55 @@ class WizStepLicense extends WizardStep
|
||||
return (($sMode === 'install') && SetupUtils::IsConnectableToITopHub($aModules));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WebPage $oPage
|
||||
*/
|
||||
public function Display(WebPage $oPage)
|
||||
{
|
||||
$aLicenses = SetupUtils::GetLicenses();
|
||||
$oPage->add_style(
|
||||
<<<CSS
|
||||
/**
|
||||
* @param WebPage $oPage
|
||||
*/
|
||||
public function Display(WebPage $oPage)
|
||||
{
|
||||
$aLicenses = SetupUtils::GetLicenses();
|
||||
$oPage->add_style(
|
||||
<<<CSS
|
||||
fieldset ul {
|
||||
max-height: min(30em, 40vh); /* Allow usage of the UI up to 150% zoom */
|
||||
overflow: auto;
|
||||
}
|
||||
CSS
|
||||
);
|
||||
);
|
||||
|
||||
$oPage->add('<h2>Licenses agreements for the components of '.ITOP_APPLICATION.'</h2>');
|
||||
$oPage->add_style('div a.no-arrow { background:transparent; padding-left:0;}');
|
||||
$oPage->add_style('.toggle { cursor:pointer; text-decoration:underline; color:#1C94C4; }');
|
||||
$oPage->add('<fieldset>');
|
||||
$oPage->add('<legend>Components of '.ITOP_APPLICATION.'</legend>');
|
||||
$oPage->add('<ul id="ibo-setup-licenses--components-list">');
|
||||
$index = 0;
|
||||
foreach ($aLicenses as $oLicense) {
|
||||
$oPage->add('<li><b>'.$oLicense->product.'</b>, © '.$oLicense->author.' is licensed under the <b>'.$oLicense->license_type.' license</b>. (<span class="toggle" id="toggle_'.$index.'">Details</span>)');
|
||||
$oPage->add('<div id="license_'.$index.'" class="license_text ibo-is-html-content" style="display:none;overflow:auto;max-height:10em;font-size:12px;border:1px #696969 solid;margin-bottom:1em; margin-top:0.5em;padding:0.5em;"><pre>'.$oLicense->text.'</pre></div>');
|
||||
$oPage->add_ready_script('$(".license_text a").attr("target", "_blank").addClass("no-arrow");');
|
||||
$oPage->add_ready_script('$("#toggle_'.$index.'").on("click", function() { $("#license_'.$index.'").toggle(); } );');
|
||||
$index++;
|
||||
}
|
||||
$oPage->add('</ul>');
|
||||
$oPage->add('</fieldset>');
|
||||
$sChecked = ($this->oWizard->GetParameter('accept_license', 'no') == 'yes') ? ' checked ' : '';
|
||||
$oPage->add('<div class="setup-accept-licenses"><input class="check_select" type="checkbox" name="accept_license" id="accept" value="yes" '.$sChecked.'><label for="accept">I accept the terms of the licenses of the '.count($aLicenses).' components mentioned above.</label></div>');
|
||||
if ($this->NeedsGdprConsent()) {
|
||||
$oPage->add('<br>');
|
||||
$oPage->add('<fieldset>');
|
||||
$oPage->add('<legend>European General Data Protection Regulation</legend>');
|
||||
$oPage->add('<div class="ibo-setup-licenses--components-list">'.ITOP_APPLICATION.' software is compliant with the processing of personal data according to the European General Data Protection Regulation (GDPR).<p></p>
|
||||
$oPage->add('<h2>Licenses agreements for the components of '.ITOP_APPLICATION.'</h2>');
|
||||
$oPage->add_style('div a.no-arrow { background:transparent; padding-left:0;}');
|
||||
$oPage->add_style('.toggle { cursor:pointer; text-decoration:underline; color:#1C94C4; }');
|
||||
$oPage->add('<fieldset>');
|
||||
$oPage->add('<legend>Components of '.ITOP_APPLICATION.'</legend>');
|
||||
$oPage->add('<ul id="ibo-setup-licenses--components-list">');
|
||||
$index = 0;
|
||||
foreach ($aLicenses as $oLicense) {
|
||||
$oPage->add('<li><b>'.$oLicense->product.'</b>, © '.$oLicense->author.' is licensed under the <b>'.$oLicense->license_type.' license</b>. (<span class="toggle" id="toggle_'.$index.'">Details</span>)');
|
||||
$oPage->add('<div id="license_'.$index.'" class="license_text ibo-is-html-content" style="display:none;overflow:auto;max-height:10em;font-size:12px;border:1px #696969 solid;margin-bottom:1em; margin-top:0.5em;padding:0.5em;"><pre>'.$oLicense->text.'</pre></div>');
|
||||
$oPage->add_ready_script('$(".license_text a").attr("target", "_blank").addClass("no-arrow");');
|
||||
$oPage->add_ready_script('$("#toggle_'.$index.'").on("click", function() { $("#license_'.$index.'").toggle(); } );');
|
||||
$index++;
|
||||
}
|
||||
$oPage->add('</ul>');
|
||||
$oPage->add('</fieldset>');
|
||||
$sChecked = ($this->oWizard->GetParameter('accept_license', 'no') == 'yes') ? ' checked ' : '';
|
||||
$oPage->add('<div class="setup-accept-licenses"><input class="check_select" type="checkbox" name="accept_license" id="accept" value="yes" '.$sChecked.'><label for="accept">I accept the terms of the licenses of the '.count($aLicenses).' components mentioned above.</label></div>');
|
||||
if ($this->NeedsGdprConsent()) {
|
||||
$oPage->add('<br>');
|
||||
$oPage->add('<fieldset>');
|
||||
$oPage->add('<legend>European General Data Protection Regulation</legend>');
|
||||
$oPage->add('<div class="ibo-setup-licenses--components-list">'.ITOP_APPLICATION.' software is compliant with the processing of personal data according to the European General Data Protection Regulation (GDPR).<p></p>
|
||||
By installing '.ITOP_APPLICATION.' you agree that some information will be collected by Combodo to help you manage your instances and for statistical purposes.
|
||||
This data remains anonymous until it is associated to a user account on iTop Hub.</p>
|
||||
<p>List of collected data available in our <a target="_blank" href="https://www.itophub.io/page/data-privacy">Data privacy section.</a></p><br></div>');
|
||||
$oPage->add('<input type="checkbox" class="check_select" id="rgpd_consent">');
|
||||
$oPage->add('<label for="rgpd_consent"> I accept the processing of my personal data</label>');
|
||||
$oPage->add('</fieldset>');
|
||||
}
|
||||
$oPage->add_ready_script('$(".check_select").on("click change", function() { WizardUpdateButtons(); });');
|
||||
$oPage->add('<input type="checkbox" class="check_select" id="rgpd_consent">');
|
||||
$oPage->add('<label for="rgpd_consent"> I accept the processing of my personal data</label>');
|
||||
$oPage->add('</fieldset>');
|
||||
}
|
||||
$oPage->add_ready_script('$(".check_select").on("click change", function() { WizardUpdateButtons(); });');
|
||||
|
||||
$oPage->add_script(
|
||||
<<<JS
|
||||
$oPage->add_script(
|
||||
<<<JS
|
||||
function isRgpdConsentOk(){
|
||||
let eRgpdConsent = $("#rgpd_consent");
|
||||
if(eRgpdConsent.length){
|
||||
@@ -754,7 +755,7 @@ This data remains anonymous until it is associated to a user account on iTop Hub
|
||||
return true;
|
||||
}
|
||||
JS
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -850,8 +851,8 @@ class WizStepDBParams extends WizardStep
|
||||
switch($sCode)
|
||||
{
|
||||
case 'check_db':
|
||||
SetupUtils:: AsyncCheckDB($oPage, $aParameters);
|
||||
break;
|
||||
SetupUtils:: AsyncCheckDB($oPage, $aParameters);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -862,7 +863,7 @@ class WizStepDBParams extends WizardStep
|
||||
public function JSCanMoveForward()
|
||||
{
|
||||
return
|
||||
<<<EOF
|
||||
<<<EOF
|
||||
if ($("#wiz_form").data("db_connection") === "error") return false;
|
||||
|
||||
var bRet = true;
|
||||
@@ -872,7 +873,7 @@ class WizStepDBParams extends WizardStep
|
||||
|
||||
return bRet;
|
||||
EOF
|
||||
;
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -937,7 +938,7 @@ EOF
|
||||
public function JSCanMoveForward()
|
||||
{
|
||||
return
|
||||
<<<EOF
|
||||
<<<EOF
|
||||
bRet = ($('#admin_user').val() != '');
|
||||
if (!bRet)
|
||||
{
|
||||
@@ -1107,10 +1108,10 @@ EOF
|
||||
default:
|
||||
case CheckResult::ERROR:
|
||||
case CheckResult::WARNING:
|
||||
$sStatus = 'ko';
|
||||
$sErrorExplanation = $oCheck->sLabel;
|
||||
$sMessage = json_encode('<div class="message message-error">'.$sErrorExplanation.'</div>');
|
||||
break;
|
||||
$sStatus = 'ko';
|
||||
$sErrorExplanation = $oCheck->sLabel;
|
||||
$sMessage = json_encode('<div class="message message-error">'.$sErrorExplanation.'</div>');
|
||||
break;
|
||||
}
|
||||
|
||||
if ($oCheck->iSeverity !== CheckResult::TRACE) {
|
||||
@@ -1134,7 +1135,7 @@ JS
|
||||
public function JSCanMoveForward()
|
||||
{
|
||||
return
|
||||
<<<EOF
|
||||
<<<EOF
|
||||
bRet = ($('#application_url').val() != '');
|
||||
if (!bRet)
|
||||
{
|
||||
@@ -1156,7 +1157,7 @@ JS
|
||||
}
|
||||
return bRet;
|
||||
EOF
|
||||
;
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1261,7 +1262,7 @@ EOF
|
||||
JS
|
||||
);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1272,7 +1273,7 @@ JS
|
||||
public function JSCanMoveForward()
|
||||
{
|
||||
return
|
||||
<<<EOF
|
||||
<<<EOF
|
||||
bRet = ($('#application_url').val() != '');
|
||||
if (!bRet)
|
||||
{
|
||||
@@ -1294,7 +1295,7 @@ JS
|
||||
}
|
||||
return bRet;
|
||||
EOF
|
||||
;
|
||||
;
|
||||
}
|
||||
}
|
||||
/**
|
||||
@@ -1311,6 +1312,8 @@ class WizStepModulesChoice extends WizardStep
|
||||
*/
|
||||
protected $oExtensionsMap;
|
||||
|
||||
protected PhpExpressionEvaluator $oPhpExpressionEvaluator;
|
||||
|
||||
/**
|
||||
* Whether we were able to load the choices from the database or not
|
||||
* @var bool
|
||||
@@ -1481,7 +1484,7 @@ class WizStepModulesChoice extends WizardStep
|
||||
$oPage->add('</div>');
|
||||
|
||||
$oPage->add_script(
|
||||
<<<EOF
|
||||
<<<EOF
|
||||
function CheckChoice(sChoiceId)
|
||||
{
|
||||
var oElement = $('#'+sChoiceId);
|
||||
@@ -1530,7 +1533,7 @@ function CheckChoice(sChoiceId)
|
||||
EOF
|
||||
);
|
||||
$oPage->add_ready_script(
|
||||
<<<EOF
|
||||
<<<EOF
|
||||
$('.wiz-choice').on('change', function() { CheckChoice($(this).attr('id')); } );
|
||||
$('.wiz-choice').trigger('change');
|
||||
EOF
|
||||
@@ -1736,6 +1739,15 @@ EOF
|
||||
return $aRetScore;
|
||||
}
|
||||
|
||||
private function GetPhpExpressionEvaluator(): PhpExpressionEvaluator
|
||||
{
|
||||
if (!isset($this->oPhpExpressionEvaluator)) {
|
||||
$this->oPhpExpressionEvaluator = new PhpExpressionEvaluator([], RunTimeEnvironment::STATIC_CALL_AUTOSELECT_WHITELIST);
|
||||
}
|
||||
|
||||
return $this->oPhpExpressionEvaluator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the list of selected "choices" into a list of "modules": take into account the selected and the mandatory modules
|
||||
*
|
||||
@@ -1786,11 +1798,11 @@ EOF
|
||||
if (isset($aInfo['auto_select'])) {
|
||||
// Check the module selection
|
||||
try {
|
||||
$bSelected = false;
|
||||
SetupInfo::SetSelectedModules($aModules);
|
||||
eval('$bSelected = ('.$aInfo['auto_select'].');');
|
||||
$bSelected = $this->GetPhpExpressionEvaluator()->ParseAndEvaluateBooleanExpression($aInfo['auto_select']);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
catch (ModuleFileReaderException $e) {
|
||||
//logged already
|
||||
$bSelected = false;
|
||||
}
|
||||
}
|
||||
@@ -1825,7 +1837,7 @@ EOF
|
||||
$sChoiceName = $sChoiceId;
|
||||
}
|
||||
if ( (isset($aChoice['mandatory']) && $aChoice['mandatory']) ||
|
||||
(isset($aSelectedChoices[$sChoiceName]) && ($aSelectedChoices[$sChoiceName] == $sChoiceId)) )
|
||||
(isset($aSelectedChoices[$sChoiceName]) && ($aSelectedChoices[$sChoiceName] == $sChoiceId)) )
|
||||
{
|
||||
$sDisplayChoices .= '<li>'.$aChoice['title'].'</li>';
|
||||
if ($aSelectedExtensions !== null)
|
||||
@@ -1864,20 +1876,19 @@ EOF
|
||||
{
|
||||
try
|
||||
{
|
||||
$bSelected = false;
|
||||
SetupInfo::SetSelectedModules($aModules);
|
||||
eval('$bSelected = ('.$aModule['auto_select'].');');
|
||||
$bSelected = $this->GetPhpExpressionEvaluator()->ParseAndEvaluateBooleanExpression($aModule['auto_select']);
|
||||
if ($bSelected)
|
||||
{
|
||||
$aModules[$sModuleId] = true; // store the Id of the selected module
|
||||
$sDisplayChoices .= '<li>'.$aModule['label'].' (auto_select)</li>';
|
||||
$bModuleAdded = true;
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
catch(ModuleFileReaderException $e)
|
||||
{
|
||||
//logged already
|
||||
$sDisplayChoices .= '<li><b>Warning: auto_select failed with exception ('.$e->getMessage().') for module "'.$sModuleId.'"</b></li>';
|
||||
$bSelected = false;
|
||||
}
|
||||
if ($bSelected)
|
||||
{
|
||||
$aModules[$sModuleId] = true; // store the Id of the selected module
|
||||
$sDisplayChoices .= '<li>'.$aModule['label'].' (auto_select)</li>';
|
||||
$bModuleAdded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1894,11 +1905,11 @@ EOF
|
||||
{
|
||||
case 'start_install':
|
||||
case 'start_upgrade':
|
||||
$index = 0;
|
||||
break;
|
||||
$index = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
$index = (integer)$this->sCurrentState;
|
||||
$index = (integer)$this->sCurrentState;
|
||||
}
|
||||
return $index;
|
||||
}
|
||||
@@ -1925,10 +1936,10 @@ EOF
|
||||
|
||||
// Additional step for the "extensions"
|
||||
$aStepDefinition = array(
|
||||
'title' => 'Extensions',
|
||||
'description' => '<h2>Select additional extensions to install. You can launch the installation again to install new extensions, but you cannot remove already installed extensions.</h2>',
|
||||
'banner' => '/images/icons/icons8-puzzle.svg',
|
||||
'options' => array()
|
||||
'title' => 'Extensions',
|
||||
'description' => '<h2>Select additional extensions to install. You can launch the installation again to install new extensions, but you cannot remove already installed extensions.</h2>',
|
||||
'banner' => '/images/icons/icons8-puzzle.svg',
|
||||
'options' => array()
|
||||
);
|
||||
|
||||
foreach($this->oExtensionsMap->GetAllExtensions() as $oExtension)
|
||||
@@ -1936,14 +1947,14 @@ EOF
|
||||
if (($oExtension->sSource !== iTopExtension::SOURCE_WIZARD) && ($oExtension->bVisible) && (count($oExtension->aMissingDependencies) == 0))
|
||||
{
|
||||
$aStepDefinition['options'][] = array(
|
||||
'extension_code' => $oExtension->sCode,
|
||||
'title' => $oExtension->sLabel,
|
||||
'description' => $oExtension->sDescription,
|
||||
'more_info' => $oExtension->sMoreInfoUrl,
|
||||
'default' => true, // by default offer to install all modules
|
||||
'modules' => $oExtension->aModules,
|
||||
'mandatory' => $oExtension->bMandatory || ($oExtension->sSource === iTopExtension::SOURCE_REMOTE),
|
||||
'source_label' => $this->GetExtensionSourceLabel($oExtension->sSource),
|
||||
'extension_code' => $oExtension->sCode,
|
||||
'title' => $oExtension->sLabel,
|
||||
'description' => $oExtension->sDescription,
|
||||
'more_info' => $oExtension->sMoreInfoUrl,
|
||||
'default' => true, // by default offer to install all modules
|
||||
'modules' => $oExtension->aModules,
|
||||
'mandatory' => $oExtension->bMandatory || ($oExtension->sSource === iTopExtension::SOURCE_REMOTE),
|
||||
'source_label' => $this->GetExtensionSourceLabel($oExtension->sSource),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1958,24 +1969,24 @@ EOF
|
||||
{
|
||||
// No wizard configuration provided, build a standard one with just one big list
|
||||
$aStepDefinition = array(
|
||||
'title' => 'Modules Selection',
|
||||
'description' => '<h2>Select the modules to install. You can launch the installation again to install new modules, but you cannot remove already installed modules.</h2>',
|
||||
'banner' => '/images/icons/icons8-apps-tab.svg',
|
||||
'options' => array()
|
||||
'title' => 'Modules Selection',
|
||||
'description' => '<h2>Select the modules to install. You can launch the installation again to install new modules, but you cannot remove already installed modules.</h2>',
|
||||
'banner' => '/images/icons/icons8-apps-tab.svg',
|
||||
'options' => array()
|
||||
);
|
||||
foreach($this->oExtensionsMap->GetAllExtensions() as $oExtension)
|
||||
{
|
||||
if (($oExtension->bVisible) && (count($oExtension->aMissingDependencies) == 0))
|
||||
{
|
||||
$aStepDefinition['options'][] = array(
|
||||
'extension_code' => $oExtension->sCode,
|
||||
'title' => $oExtension->sLabel,
|
||||
'description' => $oExtension->sDescription,
|
||||
'more_info' => $oExtension->sMoreInfoUrl,
|
||||
'default' => true, // by default offer to install all modules
|
||||
'modules' => $oExtension->aModules,
|
||||
'mandatory' => $oExtension->bMandatory || ($oExtension->sSource !== iTopExtension::SOURCE_REMOTE),
|
||||
'source_label' => $this->GetExtensionSourceLabel($oExtension->sSource),
|
||||
'extension_code' => $oExtension->sCode,
|
||||
'title' => $oExtension->sLabel,
|
||||
'description' => $oExtension->sDescription,
|
||||
'more_info' => $oExtension->sMoreInfoUrl,
|
||||
'default' => true, // by default offer to install all modules
|
||||
'modules' => $oExtension->aModules,
|
||||
'mandatory' => $oExtension->bMandatory || ($oExtension->sSource !== iTopExtension::SOURCE_REMOTE),
|
||||
'source_label' => $this->GetExtensionSourceLabel($oExtension->sSource),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1996,17 +2007,17 @@ EOF
|
||||
switch($sSource)
|
||||
{
|
||||
case iTopExtension::SOURCE_MANUAL:
|
||||
$sResult = 'Local extensions folder';
|
||||
$sDecorationClass = 'fas fa-folder';
|
||||
break;
|
||||
$sResult = 'Local extensions folder';
|
||||
$sDecorationClass = 'fas fa-folder';
|
||||
break;
|
||||
|
||||
case iTopExtension::SOURCE_REMOTE:
|
||||
$sResult = (ITOP_APPLICATION == 'iTop') ? 'iTop Hub' : 'ITSM Designer';
|
||||
$sDecorationClass = (ITOP_APPLICATION == 'iTop') ? 'fc fc-chameleon-icon' : 'fa pencil-ruler';
|
||||
break;
|
||||
$sResult = (ITOP_APPLICATION == 'iTop') ? 'iTop Hub' : 'ITSM Designer';
|
||||
$sDecorationClass = (ITOP_APPLICATION == 'iTop') ? 'fc fc-chameleon-icon' : 'fa pencil-ruler';
|
||||
break;
|
||||
|
||||
default:
|
||||
$sResult = '';
|
||||
$sResult = '';
|
||||
}
|
||||
if ($sResult == '')
|
||||
{
|
||||
@@ -2591,10 +2602,10 @@ class WizStepDone extends WizardStep
|
||||
$oProductionEnv->InitDataModel($oConfig, true);
|
||||
$sIframeUrl = $oConfig->GetModuleSetting('itop-hub-connector', 'setup_url', '');
|
||||
|
||||
$sSetupTokenFile = APPROOT.'data/.setup';
|
||||
$sSetupToken = bin2hex(random_bytes(12));
|
||||
file_put_contents($sSetupTokenFile, $sSetupToken);
|
||||
$sIframeUrl.= "&setup_token=$sSetupToken";
|
||||
$sSetupTokenFile = APPROOT.'data/.setup';
|
||||
$sSetupToken = bin2hex(random_bytes(12));
|
||||
file_put_contents($sSetupTokenFile, $sSetupToken);
|
||||
$sIframeUrl.= "&setup_token=$sSetupToken";
|
||||
|
||||
if ($sIframeUrl != '')
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user