diff --git a/setup/parameters.class.inc.php b/setup/parameters.class.inc.php
index 24b06b41d..c49889f21 100644
--- a/setup/parameters.class.inc.php
+++ b/setup/parameters.class.inc.php
@@ -37,6 +37,59 @@ class PHPParameters extends Parameters
$this->aData = $ITOP_PARAMS;
}
}
+
+ public function ToXML(DOMNode $oRoot, $data = null, $sNodeName = null)
+ {
+ if ($data === null)
+ {
+ $data = $this->aData;
+ }
+
+ if (is_array($data))
+ {
+ if ($oRoot instanceof DOMDocument)
+ {
+ $oNode = $oRoot->createElement($sNodeName);
+ }
+ else
+ {
+ $oNode = $oRoot->ownerDocument->createElement($sNodeName);
+ }
+ $oRoot->appendChild($oNode);
+
+ $aKeys = array_keys($data);
+ $bNumericKeys = true;
+ foreach($aKeys as $idx => $subkey)
+ {
+ if(((int)$subkey) !== $subkey)
+ {
+ $bNumericKeys = false;
+ break;
+ }
+ }
+ if ($bNumericKeys)
+ {
+ $oNode->setAttribute("type", "array");
+ foreach($data as $key => $value)
+ {
+ $this->ToXML($oNode, $value , 'item');
+ }
+ }
+ else
+ {
+ foreach($data as $key => $value)
+ {
+ $this->ToXML($oNode, $value , $key);
+ }
+ }
+ }
+ else
+ {
+ $oNode = $oRoot->ownerDocument->createElement($sNodeName, $data);
+ $oRoot->appendChild($oNode);
+ }
+ return $oNode;
+ }
}
class XMLParameters extends Parameters
diff --git a/setup/setuputils.class.inc.php b/setup/setuputils.class.inc.php
index c2740bc91..a584eae2b 100644
--- a/setup/setuputils.class.inc.php
+++ b/setup/setuputils.class.inc.php
@@ -667,8 +667,29 @@ function ValidateField(sFieldId, bUsed)
{
if (sValue.match(/^[A-Za-z][A-Za-z0-9_]*$/))
{
- $("#v_"+sFieldId).html("");
- return true;
+ var bCollision = false;
+ if (sFieldId == 'db_new_name')
+ {
+ // check that the "new name" does not correspond to an existing database
+ var sNewName = $('#db_new_name').val();
+ $('#db_name option').each( function() {
+ if ($(this).attr('value') == sNewName)
+ {
+ bCollision = true;
+ }
+ });
+ }
+
+ if (bCollision)
+ {
+ $("#v_"+sFieldId).html(' ');
+ return false;
+ }
+ else
+ {
+ $("#v_"+sFieldId).html("");
+ return true;
+ }
}
else
{
@@ -883,4 +904,26 @@ EOF
return $sHtml;
}
+
+ public static function AnalyzeInstallation($oWizard)
+ {
+ require_once(APPROOT.'/setup/moduleinstaller.class.inc.php');
+ $oConfig = new Config();
+
+ $aParamValues = array(
+ 'db_server' => $oWizard->GetParameter('db_server', ''),
+ 'db_user' => $oWizard->GetParameter('db_user', ''),
+ 'db_pwd' => $oWizard->GetParameter('db_server', ''),
+ 'db_name' => $oWizard->GetParameter('db_name', ''),
+ 'db_prefix' => $oWizard->GetParameter('db_prefix', ''),
+ 'source_dir' => APPROOT.'datamodel',
+ );
+ $oConfig->UpdateFromParams($aParamValues, 'datamodel');
+
+ $oProductionEnv = new RunTimeEnvironment();
+ $oConfig = new Config();
+ $aAvailableModules = $oProductionEnv->AnalyzeInstallation($oConfig, 'datamodel');
+
+ return $aAvailableModules;
+ }
}
\ No newline at end of file
diff --git a/setup/wizardsteps.class.inc.php b/setup/wizardsteps.class.inc.php
index eb1ab618f..aa821718f 100644
--- a/setup/wizardsteps.class.inc.php
+++ b/setup/wizardsteps.class.inc.php
@@ -230,17 +230,33 @@ class WizStepInstallOrUpgrade extends WizardStep
$oPage->add('
Location on the disk: ');
SetupUtils::DisplayDBParameters($oPage, false, $sDBServer, $sDBUser, $sDBPwd, $sDBName, $sDBPrefix);
- $sChecked = ($bDBBackup == 'install') ? ' checked ' : '';
- $oPage->add('Backup the '.ITOP_APPLICATION.' database before upgrading ');
- $oPage->add('Save the backup to: ');
+ $aBackupChecks = SetupUtils::CheckBackupPrerequisites($sDBBackupPath);
+ $bCanBackup = true;
+ $sMySQLDumpMessage = '';
+ foreach($aBackupChecks as $oCheck)
+ {
+ if ($oCheck->iSeverity == CheckResult::ERROR)
+ {
+ $bCanBackup = false;
+ $sMySQLDumpMessage .= ' Warning: '.$oCheck->sLabel;
+ }
+ else
+ {
+ $sMySQLDumpMessage .= ' '.$oCheck->sLabel.' ';
+ }
+ }
+ $sChecked = ($bCanBackup && ($bDBBackup == 'install')) ? ' checked ' : '';
+ $sDisabled = $bCanBackup ? '' : ' disabled ';
+ $oPage->add(' Backup the '.ITOP_APPLICATION.' database before upgrading ');
+ $oPage->add('Save the backup to: ');
$fFreeSpace = SetupUtils::CheckDiskSpace($sDBBackupPath);
$sMessage = '';
if ($fFreeSpace !== false)
{
- $sMessage = SetupUtils::HumanReadableSize($fFreeSpace).' free in '.dirname($sDBBackupPath);
+ $sMessage .= SetupUtils::HumanReadableSize($fFreeSpace).' free in '.dirname($sDBBackupPath);
}
- $oPage->add(' ');
- $oPage->add(''.$sMessage.' ');
+ $oPage->add('');
+ $oPage->add($sMySQLDumpMessage.''.$sMessage.' ');
$oPage->add('');
//$oPage->add('');
$oPage->add_ready_script(
@@ -615,8 +631,8 @@ class WizStepAdminAccount extends WizardStep
$oPage->add('');
$oPage->add('Administrator Account ');
$oPage->add('');
$oPage->add(' ');
+ $oPage->add_ready_script(
+<< ');
+ }
+ else
+ {
+ $("#v_admin_user").html('');
+ }
+
+ bPasswordsMatch = ($('#admin_pwd').val() == $('#confirm_pwd').val());
+ if (!bPasswordsMatch)
+ {
+ $('#v_admin_pwd').html(' ');
+ }
+ else
+ {
+ $('#v_admin_pwd').html('');
+ }
+ bRet = bPasswordsMatch && bRet;
+
+ return bRet;
+EOF
+ ;
+ }}
/**
* Miscellaneous Parameters (URL, Sample Data)
@@ -670,7 +726,8 @@ class WizStepMiscParams extends WizardStep
$oPage->add('');
$oPage->add('Application URL ');
$oPage->add('');
$oPage->add(' ');
$oPage->add('');
@@ -682,6 +739,33 @@ class WizStepMiscParams extends WizardStep
$oPage->p(' I am installing a production instance, create an empty database to start from.');
$oPage->add('');
$oPage->add(' ');
+ $oPage->add_ready_script(
+<< ');
+ }
+ else
+ {
+ $("#v_application_url").html('');
+ }
+ return bRet;
+EOF
+ ;
}
}
@@ -704,7 +788,7 @@ class WizStepModulesChoice extends WizardStep
public function ProcessParams($bMoveForward = true)
{
- // Accumualtes the selected modules:
+ // Accumulates the selected modules:
$index = $this->GetStepIndex();
// use json_encode:decode to store a hash array: step_id => array(input_name => selected_input_id)
@@ -727,12 +811,15 @@ class WizStepModulesChoice extends WizardStep
{
// Exiting this step of the wizard, let's convert the selection into a list of modules
$aModules = array();
+ $sDisplayChoices = '';
for($i = 0; $i <= $index; $i++)
{
$aStepInfo = $this->GetStepInfo($i);
- $this->GetSelectedModules($aStepInfo, $aSelectedChoices[$i], $aModules);
+ $sDisplayChoices .= $this->GetSelectedModules($aStepInfo, $aSelectedChoices[$i], $aModules);
}
+ $sDisplayChoices .= ' ';
$this->oWizard->SetParameter('selected_modules', json_encode(array_keys($aModules)));
+ $this->oWizard->SetParameter('display_choices', $sDisplayChoices);
return array('class' => 'WizStepSummary', 'state' => '');
}
@@ -749,6 +836,7 @@ class WizStepModulesChoice extends WizardStep
$aStepInfo = $this->GetStepInfo();
$oPage->add_style("div.choice { margin: 0.5em;}");
$oPage->add_style("div.description { margin-left: 2em; }");
+ $oPage->add_style(".choice-disabled { color: #999; }");
$oPage->add('');
$sBannerPath = isset($aStepInfo['banner']) ? $aStepInfo['banner'] : '';
if (!empty($sBannerPath))
@@ -788,6 +876,62 @@ class WizStepModulesChoice extends WizardStep
$oPage->add('');
$this->DisplayOptions($oPage, $aStepInfo, $aSelectedComponents);
$oPage->add('
');
+
+ $oPage->add_script(
+<<add_ready_script(
+<<AnalyzeInstallation() as $sModuleId => $aModule)
+ foreach(SetupUtils::AnalyzeInstallation($this->oWizard) as $sModuleId => $aModule)
{
if ($sModuleId != ROOT_MODULE)
{
@@ -860,6 +1004,7 @@ class WizStepModulesChoice extends WizardStep
if ( (isset($aChoice['mandatory']) && $aChoice['mandatory']) ||
(isset($aSelectedChoices[$sChoiceId]) && ($aSelectedChoices[$sChoiceId] == $sChoiceId)) )
{
+ $sDisplayChoices .= ''.$aChoice['title'].' ';
if (isset($aChoice['modules']))
{
foreach($aChoice['modules'] as $sModuleId)
@@ -870,8 +1015,11 @@ class WizStepModulesChoice extends WizardStep
// Recurse only for selected choices
if (isset($aChoice['sub_options']))
{
- $this->GetSelectedModules($aChoice['sub_options'], $aSelectedChoices, $aModules, $sChoiceId);
+ $sDisplayChoices .= '';
+ $sDisplayChoices = $this->GetSelectedModules($aChoice['sub_options'], $aSelectedChoices, $aModules, $sChoiceId, $sDisplayChoices);
+ $sDisplayChoices .= ' ';
}
+ $sDisplayChoices .= '';
}
$index++;
}
@@ -888,6 +1036,7 @@ class WizStepModulesChoice extends WizardStep
if ( (isset($aChoice['mandatory']) && $aChoice['mandatory']) ||
(isset($aSelectedChoices[$sChoiceName]) && ($aSelectedChoices[$sChoiceName] == $sChoiceId)) )
{
+ $sDisplayChoices .= ''.$aChoice['title'].' ';
if (isset($aChoice['modules']))
{
foreach($aChoice['modules'] as $sModuleId)
@@ -898,11 +1047,15 @@ class WizStepModulesChoice extends WizardStep
// Recurse only for selected choices
if (isset($aChoice['sub_options']))
{
- $this->GetSelectedModules($aChoice['sub_options'], $aSelectedChoices, $aModules, $sChoiceId);
+ $sDisplayChoices .= '';
+ $sDisplayChoices = $this->GetSelectedModules($aChoice['sub_options'], $aSelectedChoices, $aModules, $sChoiceId, $sDisplayChoices);
+ $sDisplayChoices .= ' ';
}
+ $sDisplayChoices .= '';
}
$index++;
}
+ return $sDisplayChoices;
}
protected function GetStepIndex()
@@ -942,7 +1095,7 @@ class WizStepModulesChoice extends WizardStep
else if ($idx == 0)
{
// No wizard configuration provided, build a standard one:
- $aAvailableModules = $this->AnalyzeInstallation();
+ $aAvailableModules = SetupUtils::AnalyzeInstallation($this->oWizard);
$aStepInfo = array(
'title' => 'Modules Selection',
'description' => 'Select the modules to install. You can launch the installation again to install new modules, but you cannot remove already installed modules. ',
@@ -989,28 +1142,6 @@ class WizStepModulesChoice extends WizardStep
}
return $aStepInfo;
}
-
- protected function AnalyzeInstallation()
- {
- require_once(APPROOT.'/setup/moduleinstaller.class.inc.php');
- $oConfig = new Config();
-
- $aParamValues = array(
- 'db_server' => $this->oWizard->GetParameter('db_server', ''),
- 'db_user' => $this->oWizard->GetParameter('db_user', ''),
- 'db_pwd' => $this->oWizard->GetParameter('db_server', ''),
- 'db_name' => $this->oWizard->GetParameter('db_name', ''),
- 'db_prefix' => $this->oWizard->GetParameter('db_prefix', ''),
- 'source_dir' => APPROOT.'datamodel',
- );
- $oConfig->UpdateFromParams($aParamValues, 'datamodel');
-
- $oProductionEnv = new RunTimeEnvironment();
- $oConfig = new Config();
- $aAvailableModules = $oProductionEnv->AnalyzeInstallation($oConfig, 'datamodel');
-
- return $aAvailableModules;
- }
protected function DisplayOptions($oPage, $aStepInfo, $aSelectedComponents, $sParentId = '')
{
@@ -1024,15 +1155,15 @@ class WizStepModulesChoice extends WizardStep
$sChoiceId = $sParentId.'_'.$index;
if (isset($aChoice['mandatory']) && $aChoice['mandatory'])
{
- $oPage->add(' ');
+ $oPage->add('
');
}
else if (isset($aSelectedComponents[$sChoiceId]) && ($aSelectedComponents[$sChoiceId] == $sChoiceId))
{
- $oPage->add('
');
+ $oPage->add('
');
}
else
{
- $oPage->add('
');
+ $oPage->add('
');
}
$this->DisplayChoice($oPage, $aChoice, $aSelectedComponents, $sChoiceId);
$oPage->add('
');
@@ -1052,7 +1183,7 @@ class WizStepModulesChoice extends WizardStep
{
$sAttributes = ' checked ';
}
- $oPage->add('
');
+ $oPage->add('
');
$this->DisplayChoice($oPage, $aChoice, $aSelectedComponents, $sChoiceId);
$oPage->add('
');
$index++;
@@ -1063,12 +1194,12 @@ class WizStepModulesChoice extends WizardStep
{
$oPage->add('
'.htmlentities($aChoice['title'], ENT_QUOTES, 'UTF-8').' ');
$sDescription = isset($aChoice['description']) ? htmlentities($aChoice['description'], ENT_QUOTES, 'UTF-8') : '';
- $oPage->add('
'.$sDescription);
+ $oPage->add('
'.$sDescription.'');
if (isset($aChoice['sub_options']))
{
$this->DisplayOptions($oPage, $aChoice['sub_options'], $aSelectedComponents, $sChoiceId);
}
- $oPage->add('
');
+ $oPage->add('
');
}
protected function GetSourceFilePath()
@@ -1085,7 +1216,16 @@ class WizStepSummary extends WizardStep
{
public function GetTitle()
{
- return 'Installation summary';
+ $sMode = $this->oWizard->GetParameter('mode', 'install');
+ if ($sMode == 'install')
+ {
+ return 'Ready to install';
+
+ }
+ else
+ {
+ return 'Ready to upgrade';
+ }
}
public function GetPossibleSteps()
@@ -1109,8 +1249,121 @@ class WizStepSummary extends WizardStep
public function Display(WebPage $oPage)
{
+ $oPage->add_style(
+<<
oWizard->GetParameter('mode', 'install');
+
+ $sPreinstallationPhase = '';
+
+ $sDestination = ITOP_APPLICATION.(($sMode == 'install') ? ' version '.ITOP_VERSION.' is about to be installed ' : ' is about to be upgraded ');
+ $sDBDescription = ' existing database '.$this->oWizard->GetParameter('db_name').' ';
+ if (($sMode == 'install') && ($this->oWizard->GetParameter('create_db') == 'yes'))
+ {
+ $sDBDescription = ' new database '.$this->oWizard->GetParameter('db_new_name').' ';
+ }
+ $sDestination .= 'into the '.$sDBDescription.' on the server '.$this->oWizard->GetParameter('db_server').' .';
+ $oPage->add(''.$sDestination.' ');
+
+ $oPage->add('Installation Parameters ');
+ $oPage->add('');
+ $oPage->add('
Database Parameters ');
+ $oPage->add('Server Name: '.$this->oWizard->GetParameter('db_server').' ');
+ $oPage->add('DB User Name: '.$this->oWizard->GetParameter('db_user').' ');
+ $oPage->add('DB user password: '.$this->oWizard->GetParameter('db_pwd').' ');
+ if (($sMode == 'install') && ($this->oWizard->GetParameter('create_db') == 'yes'))
+ {
+ $oPage->add('Database Name: '.$this->oWizard->GetParameter('db_new_name').' (will be created) ');
+ }
+ else
+ {
+ $oPage->add('Database Name: '.$this->oWizard->GetParameter('db_name').' ');
+ }
+ if ($this->oWizard->GetParameter('db_prefix') != '')
+ {
+ $oPage->add('Prefix for the '.ITOP_APPLICATION.' tables: '.$this->oWizard->GetParameter('db_prefix').' ');
+ }
+ else
+ {
+ $oPage->add('Prefix for the '.ITOP_APPLICATION.' tables: none ');
+ }
+ $oPage->add(' ');
+
+ $oPage->add('
Data Model Configuration ');
+ $oPage->add($this->oWizard->GetParameter('display_choices'));
+ $oPage->add('
');
+
+ $oPage->add('
Other Parameters ');
+ $oPage->add('Default language: '.$this->oWizard->GetParameter('default_language').' ');
+ $oPage->add('URL to access the application: '.$this->oWizard->GetParameter('application_url').' ');
+ if ($this->oWizard->GetParameter('sample_data') == 'yes')
+ {
+ $oPage->add('Sample data will be loaded into the database. ');
+ }
+ $oPage->add(' ');
+
+ $oPage->add('
Admininistrator Account ');
+ $oPage->add('Login: '.$this->oWizard->GetParameter('admin_user').' ');
+ $oPage->add('Password: '.$this->oWizard->GetParameter('admin_pwd').' ');
+ $oPage->add('Language: '.$this->oWizard->GetParameter('admin_language').' ');
+ $oPage->add(' ');
+
+ $aMiscOptions = json_decode($this->oWizard->GetParameter('misc_options', '[]'), true /* bAssoc */);
+ if (count($aMiscOptions) > 0)
+ {
+ $oPage->add('
Miscellaneous Options ');
+ foreach($aMiscOptions as $sKey => $sValue)
+ {
+ $oPage->add(''.$sKey.': '.$sValue.' ');
+ }
+ $oPage->add(' ');
+
+ }
+
+ $aSelectedModules = json_decode($this->oWizard->GetParameter('selected_modules'), true);
+/*
$oPage->add('
Selected modules:');
- $aSelectedModules = json_decode($this->oWizard->GetParameter('selected_modules'));
sort($aSelectedModules);
foreach($aSelectedModules as $sModuleId)
{
@@ -1118,17 +1371,22 @@ class WizStepSummary extends WizardStep
}
$oPage->add(' ');
- $oPage->add('
Ready to Start...
');
+*/
$oPage->add_ready_script(
<<
oWizard->GetParameter('mode', 'install');
$sBackupDestination = '';
$sConfigurationFile = '';
$sDBName = $this->oWizard->GetParameter('db_name');
@@ -1186,7 +1444,7 @@ EOF
'language' => $this->oWizard->GetParameter('default_language'),
'selected_modules' => $aSelectedModules,
'sample_data' => ($this->oWizard->GetParameter('sample_data', '') == 'yes') ? true : false ,
- 'options' => json_decode($this->oWizard->GetParameter('misc_options')),
+ 'options' => json_decode($this->oWizard->GetParameter('misc_options', '[]'), true),
);
if ($sBackupDestination != '')
@@ -1196,8 +1454,33 @@ EOF
'configuration_file' => $sConfigurationFile,
);
}
-
$sJSONData = json_encode($aInstallParams);
+ if (isset($aMiscOptions['generate_config']))
+ {
+ $oDoc = new DOMDocument('1.0', 'UTF-8');
+ $oDoc->preserveWhiteSpace = false;
+ $oDoc->formatOutput = true;
+ $oParams = new PHPParameters();
+ $oParams->LoadFromHash($aInstallParams);
+ $oParams->ToXML($oDoc, null, 'installation');
+ $sXML = $oDoc->saveXML();
+
+ $oPage->add('XML Config file ');
+ $oPage->add(htmlentities($sXML, ENT_QUOTES, 'UTF-8'));
+ $oPage->add(' ');
+ }
+
+
+ $oPage->add(' '); // params_summary
+ $oPage->add(' ');
+
+ $oPage->add('Progress of the installation ');
+ $oPage->add('');
+ $oPage->add_linked_script('../setup/jquery.progression.js');
+ $oPage->add('
Ready to start...
0%
');
+ $oPage->add('
'); // progress_content
+ $oPage->add(' ');
+
$oPage->add(' ');
}
@@ -1212,11 +1495,15 @@ EOF
if (($aRes['status'] != ApplicationInstaller::ERROR) && ($aRes['next-step'] != ''))
{
// Tell the web page to move the progress bar and to launch the next step
+ $sMessage = addslashes(htmlentities($aRes['next-step-label'], ENT_QUOTES, 'UTF-8'));
$oPage->add_ready_script(
<< {$aRes['next-step-label']}');
+ $('#setup_msg').html('$sMessage');
+ $('#progress').progression( {Current:{$aRes['percentage-completed']}, Maximum: 100, aBackgroundImg: GetAbsoluteUrlAppRoot()+'setup/orange-progress.gif', aTextColor: '#000000'} );
+
+ //$("#percentage").html('{$aRes['percentage-completed']} % completed {$aRes['next-step-label']}');
ExecuteStep('{$aRes['next-step']}');
EOF
);
@@ -1227,6 +1514,7 @@ EOF
$oPage->add_ready_script(
<<add_ready_script(
<<Error {$aRes['message']}');
+ $('#setup_msg').html('$sMessage');
EOF
);
}
@@ -1287,8 +1576,48 @@ class WizStepDone extends WizardStep
public function Display(WebPage $oPage)
{
- $oPage->p('Installation Completed.');
+ // Check if there are some manual steps required:
+ $aManualSteps = array();
+ $aAvailableModules = SetupUtils::AnalyzeInstallation($this->oWizard);
+
+ $sRootUrl = utils::GetAbsoluteUrlAppRoot();
+ $aSelectedModules = json_decode($this->oWizard->GetParameter('selected_modules'), true);
+ foreach($aSelectedModules as $sModuleId)
+ {
+ if (!empty($aAvailableModules[$sModuleId]['doc.manual_setup']))
+ {
+ $aManualSteps[$aAvailableModules[$sModuleId]['label']] = $sRootUrl.$aAvailableModules[$sModuleId]['doc.manual_setup'];
+ }
+ }
+ if (count($aManualSteps) > 0)
+ {
+ $oPage->add("Manual operations required ");
+ $oPage->p("In order to complete the installation, the following manual operations are required:");
+ foreach($aManualSteps as $sModuleLabel => $sUrl)
+ {
+ $oPage->p("Manual instructions for $sModuleLabel ");
+ }
+ $oPage->add("Congratulations for installing iTop ");
+ }
+ else
+ {
+ $oPage->add("Congratulations for installing iTop ");
+ $oPage->ok("The installation completed successfully.");
+ }
+ // Form goes here.. No back button since the job is done !
+ $oPage->add('');
+ $oPage->add(" ");
+ $oPage->add(" ");
+ $oPage->add(" ");
+ $oPage->add('
');
+ $sForm = '';
$oPage->add(' ');
+ $sForm = addslashes($sForm);
+ $oPage->add_ready_script("$('#wiz_form').after('$sForm');");
}
public function CanMoveForward()