diff --git a/setup/applicationinstaller.class.inc.php b/setup/applicationinstaller.class.inc.php index eb10afd42..418ec49be 100644 --- a/setup/applicationinstaller.class.inc.php +++ b/setup/applicationinstaller.class.inc.php @@ -426,6 +426,11 @@ class ApplicationInstaller chmod($sTargetPath, 0755); } } + else if (substr($sTargetPath, 0, strlen(APPROOT)) == APPROOT) + { + // If the directory is under the root folder - as expected - let's clean-it before compiling + SetupUtils::tidydir($sTargetPath); + } $oFactory = new ModelFactory($aDirsToScan); $aModules = $oFactory->FindModules(); diff --git a/setup/setuputils.class.inc.php b/setup/setuputils.class.inc.php index 43d7ec397..07e4e6656 100644 --- a/setup/setuputils.class.inc.php +++ b/setup/setuputils.class.inc.php @@ -64,7 +64,13 @@ class SetupUtils static function CheckPHPVersion() { $aResult = array(); - + + // For log file(s) + if (!is_dir(APPROOT.'log')) + { + @mkdir(APPROOT.'log'); + } + SetupPage::log('Info - CheckPHPVersion'); if (version_compare(phpversion(), self::PHP_MIN_VERSION, '>=')) { @@ -74,6 +80,11 @@ class SetupUtils { $aResult[] = new CheckResult(CheckResult::ERROR, "Error: The current PHP Version (".phpversion().") is lower than the minimum version required to run ".ITOP_APPLICATION.", which is (".self::PHP_MIN_VERSION.")"); } + + // Check the common directories + $aWritableDirsErrors = self::CheckWritableDirs(array('log', 'env-production', 'conf', 'data')); + $aResult = array_merge($aResult, $aWritableDirsErrors); + $aMandatoryExtensions = array('mysqli', 'iconv', 'simplexml', 'soap', 'hash', 'json', 'session', 'pcre', 'dom'); $aOptionalExtensions = array('mcrypt' => 'Strong encryption will not be used.', 'ldap' => 'LDAP authentication will be disabled.'); @@ -196,7 +207,7 @@ class SetupUtils if ($iMaxPostSize <= $iMaxUploadSize) { - $aResult[] = new CheckResult(CheckResult::WARNING, "post_max_size (".ini_get('post_max_size').") in php.ini should be bigger than upload_max_filesize (".ini_get('upload_max_filesize').") otherwise you cannot upload files of the maximun size."); + $aResult[] = new CheckResult(CheckResult::WARNING, "post_max_size (".ini_get('post_max_size').") in php.ini should be strictly greater than upload_max_filesize (".ini_get('upload_max_filesize').") otherwise you cannot upload files of the maximum size."); } @@ -603,7 +614,7 @@ class SetupUtils $oPage->add('
| Server Name: | E.g. "localhost", "dbserver.mycompany.com" or "192.142.10.23" | |
| Login: | The account must have the following privileges on the database: SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, CREATE VIEW, SUPER, TRIGGER | |
| Password: | ||
| Password: |
| Login: | |
| Password: | |
| Confirm password: | |
| Password: | |
| Confirm password: | |
| Language: | ');
@@ -1031,6 +1031,8 @@ EOF
*/
class WizStepModulesChoice extends WizardStep
{
+ static protected $SEP = '_';
+ protected $bUpgrade = false;
public function GetTitle()
{
$aStepInfo = $this->GetStepInfo();
@@ -1094,6 +1096,7 @@ class WizStepModulesChoice extends WizardStep
protected function DisplayStep($oPage)
{
+ $this->bUpgrade = ($this->oWizard->GetParameter('install_mode') != 'install');
$aStepInfo = $this->GetStepInfo();
$oPage->add_style("div.choice { margin: 0.5em;}");
$oPage->add_style("div.choice a { text-decoration:none; font-weight: bold; color: #1C94C4 }");
@@ -1125,6 +1128,9 @@ class WizStepModulesChoice extends WizardStep
$aDefaults = array();
$aModules = SetupUtils::AnalyzeInstallation($this->oWizard);
$this->GetDefaults($aStepInfo, $aDefaults, $aModules);
+ //echo "aStepInfo:\n ".print_r($aStepInfo, true).""; + //echo " aDefaults:\n ".print_r($aDefaults, true).""; + $index = $this->GetStepIndex(); // retrieve the saved selection @@ -1137,14 +1143,13 @@ class WizStepModulesChoice extends WizardStep $aSelectedComponents = $aParameters[$index]; $oPage->add(' ');
- $this->DisplayOptions($oPage, $aStepInfo, $aSelectedComponents);
+ $this->DisplayOptions($oPage, $aStepInfo, $aSelectedComponents, $aDefaults);
$oPage->add(' ');
$oPage->add_script(
<<".print_r($aScores, true)." "; + // The choice with the bigger score wins ! + asort($aScores, SORT_NUMERIC); + $aKeys = array_keys($aScores); + $sBetterChoiceId = array_pop($aKeys); + $aDefaults[$sChoiceName] = $sBetterChoiceId; + } + return $iScore; } /** @@ -1292,7 +1327,7 @@ EOF $aOptions = isset($aInfo['options']) ? $aInfo['options'] : array(); foreach($aOptions as $index => $aChoice) { - $sChoiceId = $sParentId.'_'.$index; + $sChoiceId = $sParentId.self::$SEP.$index; if ( (isset($aChoice['mandatory']) && $aChoice['mandatory']) || (isset($aSelectedChoices[$sChoiceId]) && ($aSelectedChoices[$sChoiceId] == $sChoiceId)) ) { @@ -1320,7 +1355,7 @@ EOF $sChoiceName = null; foreach($aAlternatives as $index => $aChoice) { - $sChoiceId = $sParentId.'_'.$index; + $sChoiceId = $sParentId.self::$SEP.$index; if ($sChoiceName == null) { $sChoiceName = $sChoiceId; @@ -1472,7 +1507,7 @@ EOF return false; } - protected function DisplayOptions($oPage, $aStepInfo, $aSelectedComponents, $sParentId = '') + protected function DisplayOptions($oPage, $aStepInfo, $aSelectedComponents, $aDefaults, $sParentId = '') { $aOptions = isset($aStepInfo['options']) ? $aStepInfo['options'] : array(); $aAlternatives = isset($aStepInfo['alternatives']) ? $aStepInfo['alternatives'] : array(); @@ -1481,12 +1516,15 @@ EOF foreach($aOptions as $index => $aChoice) { $sAttributes = ''; - $sChoiceId = $sParentId.'_'.$index; - if (isset($aChoice['mandatory']) && $aChoice['mandatory']) + $sChoiceId = $sParentId.self::$SEP.$index; + $bIsDefault = array_key_exists($sChoiceId, $aDefaults); + $bSelected = isset($aSelectedComponents[$sChoiceId]) && ($aSelectedComponents[$sChoiceId] == $sChoiceId); + $bMandatory = (isset($aChoice['mandatory']) && $aChoice['mandatory']) || ($this->bUpgrade && $bIsDefault); + if ($bMandatory) { $oPage->add(' ');
}
- else if (isset($aSelectedComponents[$sChoiceId]) && ($aSelectedComponents[$sChoiceId] == $sChoiceId))
+ else if ($bSelected)
{
$oPage->add(' ');
}
@@ -1494,32 +1532,68 @@ EOF
{
$oPage->add(' ');
}
- $this->DisplayChoice($oPage, $aChoice, $aSelectedComponents, $sChoiceId);
+ $this->DisplayChoice($oPage, $aChoice, $aSelectedComponents, $aDefaults, $sChoiceId);
$oPage->add(' ');
$index++;
}
$sChoiceName = null;
+ $sDisabled = '';
+ $sChoiceIdNone = null;
foreach($aAlternatives as $index => $aChoice)
{
- $sAttributes = '';
- $sChoiceId = $sParentId.'_'.$index;
+ $sChoiceId = $sParentId.self::$SEP.$index;
if ($sChoiceName == null)
{
$sChoiceName = $sChoiceId; // All radios share the same name
}
+ $bIsDefault = array_key_exists($sChoiceName, $aDefaults) && ($aDefaults[$sChoiceName] == $sChoiceId);
+ $bMandatory = (isset($aChoice['mandatory']) && $aChoice['mandatory']) || ($this->bUpgrade && $bIsDefault);
+ if ($bMandatory)
+ {
+ // One choice is mandatory, all alternatives are disabled
+ $sDisabled = ' disabled data-disabled="disabled"';
+ }
+ if ( (!isset($aChoice['sub_options']) || (count($aChoice['sub_options']) == 0)) && (!isset($aChoice['modules']) || (count($aChoice['modules']) == 0)) )
+ {
+ $sChoiceIdNone = $sChoiceId; // the "None" / empty choice
+ }
+ }
+
+ foreach($aAlternatives as $index => $aChoice)
+ {
+ $sAttributes = '';
+ $sChoiceId = $sParentId.self::$SEP.$index;
+ if ($sChoiceName == null)
+ {
+ $sChoiceName = $sChoiceId; // All radios share the same name
+ }
+ $bIsDefault = array_key_exists($sChoiceName, $aDefaults) && ($aDefaults[$sChoiceName] == $sChoiceId);
+ $bSelected = isset($aSelectedComponents[$sChoiceName]) && ($aSelectedComponents[$sChoiceName] == $sChoiceId);
+ if ( !isset($aSelectedComponents[$sChoiceName]) && ($sChoiceIdNone != null))
+ {
+ // No choice selected, select the "None" option
+ $bSelected = ($sChoiceId == $sChoiceIdNone);
+ }
+ $bMandatory = (isset($aChoice['mandatory']) && $aChoice['mandatory']) || ($this->bUpgrade && $bIsDefault);
- if (isset($aSelectedComponents[$sChoiceName]) && ($aSelectedComponents[$sChoiceName] == $sChoiceId))
+ if ($bSelected)
{
$sAttributes = ' checked ';
}
- $oPage->add(' ');
- $this->DisplayChoice($oPage, $aChoice, $aSelectedComponents, $sChoiceId);
+ $sHidden = '';
+ if ($bMandatory)
+ {
+ $sAttributes = ' checked ';
+ $sHidden = '';
+ }
+ $oPage->add(' '.$sHidden.' ');
+ $this->DisplayChoice($oPage, $aChoice, $aSelectedComponents, $aDefaults, $sChoiceId);
$oPage->add(' ');
$index++;
}
}
- protected function DisplayChoice($oPage, $aChoice, $aSelectedComponents, $sChoiceId)
+ protected function DisplayChoice($oPage, $aChoice, $aSelectedComponents, $aDefaults, $sChoiceId)
{
$sMoreInfo = isset($aChoice['more_info']) ? $aChoice['more_info'] : '';
$oPage->add(' '.$sMoreInfo);
@@ -1527,7 +1601,7 @@ EOF
$oPage->add(''.$sDescription.'');
if (isset($aChoice['sub_options']))
{
- $this->DisplayOptions($oPage, $aChoice['sub_options'], $aSelectedComponents, $sChoiceId);
+ $this->DisplayOptions($oPage, $aChoice['sub_options'], $aSelectedComponents, $aDefaults, $sChoiceId);
}
$oPage->add(' ');
}
diff --git a/setup/xmldataloader.class.inc.php b/setup/xmldataloader.class.inc.php
index 11a36ba4f..f43c932ec 100644
--- a/setup/xmldataloader.class.inc.php
+++ b/setup/xmldataloader.class.inc.php
@@ -24,7 +24,7 @@
* @license http://opensource.org/licenses/AGPL-3.0
*/
-define ('KEYS_CACHE_FILE', APPROOT.'/keyscache.tmp');
+define ('KEYS_CACHE_FILE', APPROOT.'data/keyscache.tmp');
/**
* Class to load sets of objects from XML files into the database
* XML files can be produced by the 'export' web service or by any other means
@@ -121,6 +121,10 @@ class XMLDataLoader
*/
protected function SaveKeysCache()
{
+ if (!is_dir(APPROOT.'data'))
+ {
+ mkdir(APPROOT.'data');
+ }
$hFile = @fopen($this->m_sCacheFileName, 'w');
if ($hFile !== false)
{
|