diff --git a/application/loginwebpage.class.inc.php b/application/loginwebpage.class.inc.php
index 35c6daee2..e5a454f15 100644
--- a/application/loginwebpage.class.inc.php
+++ b/application/loginwebpage.class.inc.php
@@ -433,7 +433,7 @@ EOF
if ($bMustBeAdmin && !UserRights::IsAdministrator())
{
require_once(APPROOT.'/setup/setuppage.class.inc.php');
- $oP = new SetupWebPage(Dict::S('UI:PageTitle:FatalError'));
+ $oP = new SetupPage(Dict::S('UI:PageTitle:FatalError'));
$oP->add("
".Dict::S('UI:Login:Error:AccessAdmin')."
\n");
$oP->p("".Dict::S('UI:LogOffMenu')."");
$oP->output();
diff --git a/core/config.class.inc.php b/core/config.class.inc.php
index c1abed60f..ad326c45e 100644
--- a/core/config.class.inc.php
+++ b/core/config.class.inc.php
@@ -551,8 +551,8 @@ class Config
protected $m_bLogNotification;
protected $m_bLogIssue;
protected $m_bLogWebService;
- protected $m_bLogKpiDuration; // private setting
- protected $m_bLogKpiMemory; // private setting
+ protected $m_bLogKPIDuration; // private setting
+ protected $m_bLogKPIMemory; // private setting
protected $m_bDebugQueries; // private setting
protected $m_bQueryCacheEnabled; // private setting
diff --git a/core/metamodel.class.php b/core/metamodel.class.php
index 8f38847f5..ad670092b 100644
--- a/core/metamodel.class.php
+++ b/core/metamodel.class.php
@@ -825,7 +825,11 @@ if (!array_key_exists($sAttCode, self::$m_aAttribDefs[$sClass]))
final static public function GetClassFilterDef($sClass, $sFilterCode)
{
- self::_check_subclass($sClass);
+ self::_check_subclass($sClass);
+ if (!array_key_exists($sFilterCode, self::$m_aFilterDefs[$sClass]))
+ {
+ throw new CoreException("Unknown filter code '$sFilterCode' for class '$sClass'");
+ }
return self::$m_aFilterDefs[$sClass][$sFilterCode];
}
@@ -4028,11 +4032,19 @@ if (!array_key_exists($sAttCode, self::$m_aAttribDefs[$sClass]))
}
}
- public static function Startup($sConfigFile, $bModelOnly = false, $bAllowCache = true, $bTraceSourceFiles = false)
+ public static function Startup($config, $bModelOnly = false, $bAllowCache = true, $bTraceSourceFiles = false)
{
self::$m_bTraceSourceFiles = $bTraceSourceFiles;
- self::LoadConfig($sConfigFile, $bAllowCache);
+ // $config can be either a filename, or a Configuration object (volatile!)
+ if ($config instanceof Config)
+ {
+ self::LoadConfig($config, $bAllowCache);
+ }
+ else
+ {
+ self::LoadConfig(new Config($config), $bAllowCache);
+ }
if ($bModelOnly) return;
@@ -4054,9 +4066,9 @@ if (!array_key_exists($sAttCode, self::$m_aAttribDefs[$sClass]))
}
}
- public static function LoadConfig($sConfigFile, $bAllowCache = false)
+ public static function LoadConfig($oConfiguration, $bAllowCache = false)
{
- self::$m_oConfig = new Config($sConfigFile);
+ self::$m_oConfig = $oConfiguration;
// Set log ASAP
if (self::$m_oConfig->GetLogGlobal())
@@ -4119,7 +4131,7 @@ if (!array_key_exists($sAttCode, self::$m_aAttribDefs[$sClass]))
{
foreach (self::$m_oConfig->GetDictionaries() as $sModule => $sToInclude)
{
- self::IncludeModule($sConfigFile, 'dictionaries', $sToInclude);
+ self::IncludeModule('dictionaries', $sToInclude);
}
if (self::$m_bUseAPCCache)
{
@@ -4135,19 +4147,19 @@ if (!array_key_exists($sAttCode, self::$m_aAttribDefs[$sClass]))
foreach (self::$m_oConfig->GetAppModules() as $sModule => $sToInclude)
{
- self::IncludeModule($sConfigFile, 'application', $sToInclude);
+ self::IncludeModule('application', $sToInclude);
}
foreach (self::$m_oConfig->GetDataModels() as $sModule => $sToInclude)
{
- self::IncludeModule($sConfigFile, 'business', $sToInclude);
+ self::IncludeModule('business', $sToInclude);
}
foreach (self::$m_oConfig->GetWebServiceCategories() as $sModule => $sToInclude)
{
- self::IncludeModule($sConfigFile, 'webservice', $sToInclude);
+ self::IncludeModule('webservice', $sToInclude);
}
foreach (self::$m_oConfig->GetAddons() as $sModule => $sToInclude)
{
- self::IncludeModule($sConfigFile, 'addons', $sToInclude);
+ self::IncludeModule('addons', $sToInclude);
}
$sServer = self::$m_oConfig->GetDBHost();
@@ -4249,7 +4261,7 @@ if (!array_key_exists($sAttCode, self::$m_aAttribDefs[$sClass]))
protected static $m_aExtensionClasses = array();
- protected static function IncludeModule($sConfigFile, $sModuleType, $sToInclude)
+ protected static function IncludeModule($sModuleType, $sToInclude)
{
$sFirstChar = substr($sToInclude, 0, 1);
$sSecondChar = substr($sToInclude, 1, 1);
@@ -4274,6 +4286,7 @@ if (!array_key_exists($sAttCode, self::$m_aAttribDefs[$sClass]))
}
if (!file_exists($sFile))
{
+ $sConfigFile = self::$m_oConfig->GetLoadedFile();
throw new CoreException('Wrong filename in configuration file', array('file' => $sConfigFile, 'module' => $sModuleType, 'filename' => $sFile));
}
require_once($sFile);
diff --git a/modules/itop-attachments/module.attachments.php b/modules/itop-attachments/module.attachments.php
index 2ae724e98..613ca107a 100644
--- a/modules/itop-attachments/module.attachments.php
+++ b/modules/itop-attachments/module.attachments.php
@@ -98,12 +98,12 @@ class AttachmentInstaller extends ModuleInstallerAPI
// get the org_id from the container object
//
// Prerequisite: change null into 0 (workaround to the fact that we cannot use IS NULL in OQL)
- SetupWebPage::log_info("Initializing attachment/item_org_id - null to zero");
+ SetupPage::log_info("Initializing attachment/item_org_id - null to zero");
$sTableName = MetaModel::DBGetTable('Attachment');
$sRepair = "UPDATE `$sTableName` SET `item_org_id` = 0 WHERE `item_org_id` IS NULL";
CMDBSource::Query($sRepair);
- SetupWebPage::log_info("Initializing attachment/item_org_id - zero to the container");
+ SetupPage::log_info("Initializing attachment/item_org_id - zero to the container");
$oSearch = DBObjectSearch::FromOQL("SELECT Attachment WHERE item_org_id = 0");
$oSet = new DBObjectSet($oSearch);
$iUpdated = 0;
@@ -117,7 +117,7 @@ class AttachmentInstaller extends ModuleInstallerAPI
}
}
- SetupWebPage::log_info("Initializing attachment/item_org_id - $iUpdated records have been adjusted");
+ SetupPage::log_info("Initializing attachment/item_org_id - $iUpdated records have been adjusted");
}
}
diff --git a/modules/itop-change-mgmt-1.0.0/module.itop-change-mgmt.php b/modules/itop-change-mgmt-1.0.0/module.itop-change-mgmt.php
index e45e671ae..f5a1e79bb 100644
--- a/modules/itop-change-mgmt-1.0.0/module.itop-change-mgmt.php
+++ b/modules/itop-change-mgmt-1.0.0/module.itop-change-mgmt.php
@@ -85,7 +85,7 @@ class ChangeManagementInstaller extends ModuleInstallerAPI
if (CMDBSource::IsField($sSourceTable, $sField) && CMDBSource::IsField($sTargetTable, $sField) && CMDBSource::IsField($sSourceTable, $sSourceKeyField) && CMDBSource::IsField($sTargetTable, $sTargetKeyField))
{
- SetupWebPage::log_info("Issue #464 - Copying change/start_date into ticket/start_date");
+ SetupPage::log_info("Issue #464 - Copying change/start_date into ticket/start_date");
$sRepair = "UPDATE `$sTargetTable`, `$sSourceTable` SET `$sTargetTable`.`$sField` = `$sSourceTable`.`$sField` WHERE `$sTargetTable`.`$sField` IS NULL AND`$sTargetTable`.`$sTargetKeyField` = `$sSourceTable`.`$sSourceKeyField`";
CMDBSource::Query($sRepair);
}
diff --git a/modules/itop-config-mgmt-1.0.0/model.itop-config-mgmt.php b/modules/itop-config-mgmt-1.0.0/model.itop-config-mgmt.php
index 376bf6e92..a48a187ff 100644
--- a/modules/itop-config-mgmt-1.0.0/model.itop-config-mgmt.php
+++ b/modules/itop-config-mgmt-1.0.0/model.itop-config-mgmt.php
@@ -1599,14 +1599,6 @@ class lnkProcessToSolution extends cmdbAbstractObject
// Create the top-level group. fRank = 1, means it will be inserted after the group '0', which is usually 'Welcome'
-// Note (RQ) :
-// After 1.0.1, the welcome page and menus have been removed from the application
-// and put into a separate module "itop-welcome-itil"
-// Until we develop a migration utility, and as would like to preserve the
-// capability to upgrade iTop without any manual operation, we have decided to
-// implement this dirty workaround that makes it...
-require_once(APPROOT.'modules/itop-welcome-itil/model.itop-welcome-itil.php');
-
// Starting with iTop 1.2 you can restrict the list of organizations displayed in the drop-down list
// by specifying a query as shown below. Note that this is NOT a security settings, since the
// choice 'All Organizations' will always be available in the menu
diff --git a/pages/UI.php b/pages/UI.php
index 5d2d5447c..5b01b6f6d 100644
--- a/pages/UI.php
+++ b/pages/UI.php
@@ -2188,7 +2188,7 @@ EOF
catch(CoreException $e)
{
require_once(APPROOT.'/setup/setuppage.class.inc.php');
- $oP = new SetupWebPage(Dict::S('UI:PageTitle:FatalError'));
+ $oP = new SetupPage(Dict::S('UI:PageTitle:FatalError'));
if ($e instanceof SecurityException)
{
$oP->add("
\n");
$oP->error(Dict::Format('UI:Error_Details', $e->getMessage()));
$oP->output();
diff --git a/setup/ajax.dataloader.php b/setup/ajax.dataloader.php
index f8168f08c..0d13659d9 100644
--- a/setup/ajax.dataloader.php
+++ b/setup/ajax.dataloader.php
@@ -26,7 +26,7 @@
/**
* This page is called to perform "asynchronously" the setup actions
* parameters
- * 'operation': one of 'update_db_schema', 'after_db_creation', 'file'
+ * 'operation': one of 'compile_data_model', 'update_db_schema', 'after_db_creation', 'file'
*
* if 'operation' == 'update_db_schema':
* 'mode': install | upgrade
@@ -51,7 +51,7 @@ if (empty($sMemoryLimit))
// On some PHP installations, memory_limit does not exist as a PHP setting!
// (encountered on a 5.2.0 under Windows)
// In that case, ini_set will not work, let's keep track of this and proceed with the data load
- SetupWebPage::log_info("No memory limit has been defined in this instance of PHP");
+ SetupPage::log_info("No memory limit has been defined in this instance of PHP");
}
else
{
@@ -62,11 +62,11 @@ else
{
if (ini_set('memory_limit', SAFE_MINIMUM_MEMORY) === FALSE)
{
- SetupWebPage::log_error("memory_limit is too small: $iMemoryLimit and can not be increased by the script itself.");
+ SetupPage::log_error("memory_limit is too small: $iMemoryLimit and can not be increased by the script itself.");
}
else
{
- SetupWebPage::log_info("memory_limit increased from $iMemoryLimit to ".SAFE_MINIMUM_MEMORY.".");
+ SetupPage::log_info("memory_limit increased from $iMemoryLimit to ".SAFE_MINIMUM_MEMORY.".");
}
}
@@ -84,7 +84,7 @@ function FatalErrorCatcher($sOutput)
}
$sOutput = "$errors\n";
// Logging to a file does not work if the whole memory is exhausted...
- //SetupWebPage::log_error("Fatal error - in $__FILE__ , $errors");
+ //SetupPage::log_error("Fatal error - in $__FILE__ , $errors");
}
return $sOutput;
}
@@ -95,7 +95,7 @@ function FatalErrorCatcher($sOutput)
*/
function CreateAdminAccount(Config $oConfig, $sAdminUser, $sAdminPwd, $sLanguage)
{
- SetupWebPage::log_info('CreateAdminAccount');
+ SetupPage::log_info('CreateAdminAccount');
if (UserRights::CreateAdministrator($sAdminUser, $sAdminPwd, $sLanguage))
{
@@ -136,49 +136,137 @@ try
{
switch($sOperation)
{
-
- case 'update_db_schema':
- SetupWebPage::log_info("Update Database Schema.");
- InitDataModel(TMP_CONFIG_FILE, true); // load data model and connect to the database
- $sMode = Utils::ReadParam('mode', 'install');
+ //////////////////////////////
+ //
+ case 'compile_data_model':
+ //
+ SetupPage::log_info("Compiling data model.");
+
+ require_once(APPROOT.'designer/modulediscovery.class.inc.php');
+ require_once(APPROOT.'designer/modelfactory.inc.class.php');
+ require_once(APPROOT.'designer/compiler.inc.class.php');
+
$sSelectedModules = Utils::ReadParam('selected_modules', '', false, 'raw_data');
$aSelectedModules = explode(',', $sSelectedModules);
- if(!CreateDatabaseStructure(MetaModel::GetConfig(), $aSelectedModules, $sMode))
+
+ $sWorkspace = Utils::ReadParam('workspace_dir', '', false, 'raw_data');
+ $sSourceDir = Utils::ReadParam('source_dir', '', false, 'raw_data');
+ $sTargetDir = Utils::ReadParam('target_dir', '', false, 'raw_data');
+ if (empty($sSourceDir) || empty($sTargetDir))
+ {
+ throw new Exception("missing parameter source_dir and/or target_dir");
+ }
+
+ $sSourcePath = APPROOT.$sSourceDir;
+ $sTargetPath = APPROOT.$sTargetDir;
+ if (!is_dir($sSourcePath))
+ {
+ throw new Exception("Failed to find the source directory '$sSourcePath', please check the rights of the web server");
+ }
+ if (!is_dir($sTargetPath) && !mkdir($sTargetPath))
+ {
+ throw new Exception("Failed to create directory '$sTargetPath', please check the rights of the web server");
+ }
+ // owner:rwx user/group:rx
+ chmod($sTargetPath, 0755);
+
+ $oFactory = new ModelFactory($sSourcePath);
+ $aModules = $oFactory->FindModules();
+
+ foreach($aModules as $foo => $oModule)
+ {
+ $sModule = $oModule->GetName();
+ if (in_array($sModule, $aSelectedModules))
+ {
+ $oFactory->LoadModule($oModule);
+ }
+ }
+ if (strlen($sWorkspace) > 0)
+ {
+ $oWorkspace = new MFWorkspace(APPROOT.$sWorkspace);
+ if (file_exists($oWorkspace->GetWorkspacePath()))
+ {
+ $oFactory->LoadModule($oWorkspace);
+ }
+ }
+ //$oFactory->Dump();
+
+ $oMFCompiler = new MFCompiler($oFactory, $sSourcePath);
+ $oMFCompiler->Compile($sTargetPath);
+ SetupPage::log_info("Data model successfully compiled to '$sTargetPath'.");
+ break;
+
+ //////////////////////////////
+ //
+ case 'update_db_schema':
+ //
+ SetupPage::log_info("Update Database Schema.");
+
+ $oConfig = new Config(TMP_CONFIG_FILE, false /* Don't try to load it */);
+
+ $aParamValues = array(
+ 'db_server' => utils::ReadParam('db_server', '', false, 'raw_data'),
+ 'db_user' => utils::ReadParam('db_user', '', false, 'raw_data'),
+ 'db_pwd' => utils::ReadParam('db_pwd', '', false, 'raw_data'),
+ 'db_name' => utils::ReadParam('db_name', '', false, 'raw_data'),
+ 'new_db_name' => utils::ReadParam('new_db_name', '', false, 'raw_data'),
+ 'db_prefix' => utils::ReadParam('db_prefix', '', false, 'raw_data')
+ );
+ $sModuleDir = Utils::ReadParam('modules_dir', '');
+ UpdateConfigSettings($oConfig, $aParamValues, $sModuleDir);
+
+ InitDataModel($oConfig, true); // load data model only
+
+ $sMode = Utils::ReadParam('mode', 'install');
+ if(!CreateDatabaseStructure(MetaModel::GetConfig(), $sMode))
{
throw(new Exception("Failed to create/upgrade the database structure"));
}
- SetupWebPage::log_info("Database Schema Successfully Updated.");
+ SetupPage::log_info("Database Schema Successfully Updated.");
break;
+ //////////////////////////////
+ //
case 'after_db_create':
- SetupWebPage::log_info('After Database Creation');
+ //
+ SetupPage::log_info('After Database Creation');
+
+ $oConfig = new Config(TMP_CONFIG_FILE, false /* Don't try to load it */);
+
+ $aParamValues = array(
+ 'db_server' => utils::ReadParam('db_server', '', false, 'raw_data'),
+ 'db_user' => utils::ReadParam('db_user', '', false, 'raw_data'),
+ 'db_pwd' => utils::ReadParam('db_pwd', '', false, 'raw_data'),
+ 'db_name' => utils::ReadParam('db_name', '', false, 'raw_data'),
+ 'new_db_name' => utils::ReadParam('new_db_name', '', false, 'raw_data'),
+ 'db_prefix' => utils::ReadParam('db_prefix', '', false, 'raw_data')
+ );
+ $sModuleDir = Utils::ReadParam('modules_dir', '');
+ UpdateConfigSettings($oConfig, $aParamValues, $sModuleDir);
+
+ InitDataModel($oConfig, false); // load data model and connect to the database
+
$sMode = Utils::ReadParam('mode', 'install');
$sSelectedModules = Utils::ReadParam('selected_modules', '', false, 'raw_data');
$aSelectedModules = explode(',', $sSelectedModules);
- InitDataModel(TMP_CONFIG_FILE, true); // load data model and connect to the database
// Perform here additional DB setup... profiles, etc...
-
- $aAvailableModules = AnalyzeInstallation(MetaModel::GetConfig());
-
- $aStructureDataFiles = array();
- $aSampleDataFiles = array();
-
+ //
+ $aAvailableModules = AnalyzeInstallation(MetaModel::GetConfig(), $sModuleDir);
foreach($aAvailableModules as $sModuleId => $aModule)
{
if (($sModuleId != ROOT_MODULE) && in_array($sModuleId, $aSelectedModules) &&
isset($aAvailableModules[$sModuleId]['installer']) )
{
$sModuleInstallerClass = $aAvailableModules[$sModuleId]['installer'];
- SetupWebPage::log_info("Calling Module Handler: $sModuleInstallerClass::AfterDatabaseCreation(oConfig, {$aModule['version_db']}, {$aModule['version_code']})");
+ SetupPage::log_info("Calling Module Handler: $sModuleInstallerClass::AfterDatabaseCreation(oConfig, {$aModule['version_db']}, {$aModule['version_code']})");
// The validity of the sModuleInstallerClass has been established in BuildConfig()
$aCallSpec = array($sModuleInstallerClass, 'AfterDatabaseCreation');
call_user_func_array($aCallSpec, array(MetaModel::GetConfig(), $aModule['version_db'], $aModule['version_code']));
}
}
-
- if (!RecordInstallation(MetaModel::GetConfig(), $aSelectedModules))
+ if (!RecordInstallation($oConfig, $aSelectedModules, $sModuleDir))
{
throw(new Exception("Failed to record the installation information"));
}
@@ -195,22 +283,39 @@ try
}
else
{
- SetupWebPage::log_info("Administrator account '$sAdminUser' created.");
+ SetupPage::log_info("Administrator account '$sAdminUser' created.");
}
}
break;
+ //////////////////////////////
+ //
case 'load_data': // Load data files
+ //
$sFileName = Utils::ReadParam('file', '', false, 'raw_data');
$sSessionStatus = Utils::ReadParam('session_status', '');
$iPercent = (integer)Utils::ReadParam('percent', 0);
- SetupWebPage::log_info("Loading file: $sFileName");
+ SetupPage::log_info("Loading file: $sFileName");
if (empty($sFileName) || !file_exists($sFileName))
{
throw(new Exception("File $sFileName does not exist"));
}
-
- InitDataModel(TMP_CONFIG_FILE, false); // When called by the wizard, the final config is not yet there
+
+ $oConfig = new Config(TMP_CONFIG_FILE, false /* Don't try to load it */);
+
+ $aParamValues = array(
+ 'db_server' => utils::ReadParam('db_server', '', false, 'raw_data'),
+ 'db_user' => utils::ReadParam('db_user', '', false, 'raw_data'),
+ 'db_pwd' => utils::ReadParam('db_pwd', '', false, 'raw_data'),
+ 'db_name' => utils::ReadParam('db_name', '', false, 'raw_data'),
+ 'new_db_name' => utils::ReadParam('new_db_name', '', false, 'raw_data'),
+ 'db_prefix' => utils::ReadParam('db_prefix', '', false, 'raw_data')
+ );
+ $sModuleDir = Utils::ReadParam('modules_dir', '');
+ UpdateConfigSettings($oConfig, $aParamValues, $sModuleDir);
+
+ InitDataModel($oConfig, false); // load data model and connect to the database
+
$oDataLoader = new XMLDataLoader();
if ($sSessionStatus == 'start')
{
@@ -218,18 +323,18 @@ try
$oChange->Set("date", time());
$oChange->Set("userinfo", "Initialization");
$iChangeId = $oChange->DBInsert();
- SetupWebPage::log_info("starting data load session");
+ SetupPage::log_info("starting data load session");
$oDataLoader->StartSession($oChange);
}
$oDataLoader->LoadFile($sFileName);
$sResult = sprintf("loading of %s done. (Overall %d %% completed).", basename($sFileName), $iPercent);
- SetupWebPage::log_info($sResult);
+ SetupPage::log_info($sResult);
if ($sSessionStatus == 'end')
{
$oDataLoader->EndSession();
- SetupWebPage::log_info("ending data load session");
+ SetupPage::log_info("ending data load session");
}
break;
@@ -242,18 +347,18 @@ catch(Exception $e)
header("HTTP/1.0 500 Internal server error.");
echo "
An error happened while processing the installation:
\n";
echo '
'.$e."
\n";
- SetupWebPage::log_error("An error happened while processing the installation: ".$e);
+ SetupPage::log_error("An error happened while processing the installation: ".$e);
}
if (function_exists('memory_get_peak_usage'))
{
if ($sOperation == 'file')
{
- SetupWebPage::log_info("loading file '$sFileName', peak memory usage. ".memory_get_peak_usage());
+ SetupPage::log_info("loading file '$sFileName', peak memory usage. ".memory_get_peak_usage());
}
else
{
- SetupWebPage::log_info("operation '$sOperation', peak memory usage. ".memory_get_peak_usage());
+ SetupPage::log_info("operation '$sOperation', peak memory usage. ".memory_get_peak_usage());
}
}
?>
diff --git a/setup/email.test.php b/setup/email.test.php
index 32dc45081..0ea574b54 100644
--- a/setup/email.test.php
+++ b/setup/email.test.php
@@ -32,7 +32,7 @@ require_once(APPROOT.'/core/email.class.inc.php');
require_once('./setuppage.class.inc.php');
$sOperation = Utils::ReadParam('operation', 'step1');
-$oP = new SetupWebPage('iTop email test utility');
+$oP = new SetupPage('iTop email test utility');
/**
@@ -110,7 +110,7 @@ function CheckEmailSetting($oP)
* Display the form for the first step of the test wizard
* which consists in a basic check of the configuration and display of a form for testing
*/
-function DisplayStep1(SetupWebPage $oP)
+function DisplayStep1(SetupPage $oP)
{
$sNextOperation = 'step2';
$oP->add("
iTop email test
\n");
@@ -145,7 +145,7 @@ function DisplayStep1(SetupWebPage $oP)
* Display the form for the second step of the configuration wizard
* which consists in sending an email, which maybe a problem under Windows
*/
-function DisplayStep2(SetupWebPage $oP, $sFrom, $sTo)
+function DisplayStep2(SetupPage $oP, $sFrom, $sTo)
{
//$sNextOperation = 'step3';
$oP->add("
iTop configuration wizard
\n");
diff --git a/setup/index.php b/setup/index.php
index 7b2ca2866..0d9bf84af 100644
--- a/setup/index.php
+++ b/setup/index.php
@@ -40,7 +40,7 @@ define('MIN_MEMORY_LIMIT', 32*1024*1024);
define('SUHOSIN_GET_MAX_VALUE_LENGTH', 2048);
$sOperation = Utils::ReadParam('operation', 'step0');
-$oP = new SetupWebPage('iTop configuration wizard');
+$oP = new SetupPage('iTop configuration wizard');
///////////////////////////////////////////////////////////////////////////////////////////////////
// Various helper function
@@ -120,7 +120,7 @@ function GetUploadTmpDir()
* is compatible with the application
* @return boolean true if this is Ok, false otherwise
*/
-function CheckPHPVersion(SetupWebPage $oP)
+function CheckPHPVersion(SetupPage $oP)
{
$bResult = true;
$aErrors = array();
@@ -380,7 +380,7 @@ function CheckPHPVersion(SetupWebPage $oP)
* the existing databases
* @return Array The list of databases found in the server
*/
-function CheckServerConnection(SetupWebPage $oP, $sDBServer, $sDBUser, $sDBPwd)
+function CheckServerConnection(SetupPage $oP, $sDBServer, $sDBUser, $sDBPwd)
{
$aResult = array();
$oP->log('Info - CheckServerConnection');
@@ -442,14 +442,14 @@ function CheckServerConnection(SetupWebPage $oP, $sDBServer, $sDBUser, $sDBPwd)
/**
* Scans the ./data directory for XML files and output them as a Javascript array
*/
-function PopulateDataFilesList(SetupWebPage $oP, $aParamValues, $oConfig)
+function PopulateDataFilesList(SetupPage $oP, $aParamValues, $oConfig)
{
$sScript = "function PopulateDataFilesList()\n";
$sScript .= "{\n";
$sScript .= "if (aFilesToLoad.length > 0) return;"; // Populate the list only once...
- $aAvailableModules = AnalyzeInstallation($oConfig);
+ $aAvailableModules = AnalyzeInstallation($oConfig, $aParamValues['source_dir']);
$sMode = $aParamValues['mode'];
$aStructureDataFiles = array();
@@ -501,11 +501,11 @@ function PopulateDataFilesList(SetupWebPage $oP, $aParamValues, $oConfig)
/**
* Add some parameters as hidden inputs into a form
- * @param SetupWebpage $oP The page to insert the form elements into
+ * @param SetupPage $oP The page to insert the form elements into
* @param Hash $aParamValues The pairs name/value to be stored in the form
* @param Array $aExcludeParams A list of parameters to exclude from the previous hash
*/
-function AddParamsToForm(SetupWebpage $oP, $aParamValues, $aExcludeParams = array())
+function AddParamsToForm(SetupPage $oP, $aParamValues, $aExcludeParams = array())
{
foreach($aParamValues as $sName => $value)
{
@@ -537,64 +537,37 @@ function AddHiddenParam($oP, $sName, $value)
}
/**
- * Build the config file from the parameters (especially the selected modules)
- */
-function BuildConfig(SetupWebpage $oP, Config &$oConfig, $aParamValues, $aAvailableModules)
+ * Helper function to get the available languages from the given directory
+ * @param $sDir Path to the dictionary
+ * @return an array of language code => description
+ */
+function GetAvailableLanguages($sDir)
{
- // Initialize the arrays below with default values for the application...
- $oEmptyConfig = new Config('dummy_file', false); // Do NOT load any config file, just set the default values
- $aAddOns = $oEmptyConfig->GetAddOns();
- $aAppModules = $oEmptyConfig->GetAppModules();
- $aDataModels = $oEmptyConfig->GetDataModels();
- $aWebServiceCategories = $oEmptyConfig->GetWebServiceCategories();
- $aDictionaries = $oEmptyConfig->GetDictionaries();
- // Merge the values with the ones provided by the modules
- // Make sure when don't load the same file twice...
- foreach($aParamValues['module'] as $sModuleId)
+ require_once(APPROOT.'/core/coreexception.class.inc.php');
+ require_once(APPROOT.'/core/dict.class.inc.php');
+
+ $aFiles = scandir($sDir);
+ foreach($aFiles as $sFile)
{
- $oP->log('Installed iTop module: '. $sModuleId);
- if (isset($aAvailableModules[$sModuleId]['datamodel']))
+ if ($sFile == '.' || $sFile == '..' || $sFile == '.svn')
{
- $aDataModels = array_unique(array_merge($aDataModels, $aAvailableModules[$sModuleId]['datamodel']));
+ // Skip
+ continue;
}
- if (isset($aAvailableModules[$sModuleId]['webservice']))
+
+ $sFilePath = $sDir.'/'.$sFile;
+ if (is_file($sFilePath) && preg_match('/^.+\.dict.*\.php$/i', $sFilePath, $aMatches))
{
- $aWebServiceCategories = array_unique(array_merge($aWebServiceCategories, $aAvailableModules[$sModuleId]['webservice']));
- }
- if (isset($aAvailableModules[$sModuleId]['dictionary']))
- {
- $aDictionaries = array_unique(array_merge($aDictionaries, $aAvailableModules[$sModuleId]['dictionary']));
- }
- if (isset($aAvailableModules[$sModuleId]['settings']))
- {
- foreach($aAvailableModules[$sModuleId]['settings'] as $sProperty => $value)
- {
- list($sName, $sVersion) = GetModuleName($sModuleId);
- $oConfig->SetModuleSetting($sName, $sProperty, $value);
- }
- }
- if (isset($aAvailableModules[$sModuleId]['installer']))
- {
- $sModuleInstallerClass = $aAvailableModules[$sModuleId]['installer'];
- if (!class_exists($sModuleInstallerClass))
- {
- throw new Exception("Wrong installer class: '$sModuleInstallerClass' is not a PHP class - Module: ".$aAvailableModules[$sModuleId]['label']);
- }
- if (!is_subclass_of($sModuleInstallerClass, 'ModuleInstallerAPI'))
- {
- throw new Exception("Wrong installer class: '$sModuleInstallerClass' is not derived from 'ModuleInstallerAPI' - Module: ".$aAvailableModules[$sModuleId]['label']);
- }
- $aCallSpec = array($sModuleInstallerClass, 'BeforeWritingConfig');
- $oConfig = call_user_func_array($aCallSpec, array($oConfig));
+ require_once($sFilePath);
}
}
- $oConfig->SetAddOns($aAddOns);
- $oConfig->SetAppModules($aAppModules);
- $oConfig->SetDataModels($aDataModels);
- $oConfig->SetWebServiceCategories($aWebServiceCategories);
- $oConfig->SetDictionaries($aDictionaries);
+
+ return Dict::GetLanguages();
}
+
+
+
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Handling of the different steps of the setup wizard
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -602,7 +575,7 @@ function BuildConfig(SetupWebpage $oP, Config &$oConfig, $aParamValues, $aAvaila
/**
* Displays the welcome screen and check some basic prerequisites
*/
-function WelcomeAndCheckPrerequisites(SetupWebPage $oP, $aParamValues, $iCurrentStep)
+function WelcomeAndCheckPrerequisites(SetupPage $oP, $aParamValues, $iCurrentStep)
{
$sNextOperation = 'step'.($iCurrentStep+1);
$aParamValues['previous_step'] = 0;
@@ -620,9 +593,8 @@ function WelcomeAndCheckPrerequisites(SetupWebPage $oP, $aParamValues, $iCurrent
if (file_exists(FINAL_CONFIG_FILE))
{
$oConfig = new Config(FINAL_CONFIG_FILE);
- $oConfig->WriteToFile(TMP_CONFIG_FILE);
- $aVersion = AnalyzeInstallation($oConfig);
+ $aVersion = AnalyzeInstallation($oConfig, $aParamValues['source_dir']);
if (!empty($aVersion[ROOT_MODULE]['version_db']))
{
$aPreviousParams = array('mode', 'db_server', 'db_user', 'db_pwd','db_name', 'new_db_name', 'db_prefix');
@@ -641,6 +613,8 @@ function WelcomeAndCheckPrerequisites(SetupWebPage $oP, $aParamValues, $iCurrent
AddHiddenParam($oP, 'db_name', $oConfig->GetDBName());
AddHiddenParam($oP, 'db_prefix', $oConfig->GetDBSubname());
AddHiddenParam($oP, 'mode', $sMode);
+ AddHiddenParam($oP, 'source_dir', 'whichsourcedir');
+ AddHiddenParam($oP, 'target_dir', 'whichtargetdir');
if (CheckPHPVersion($oP))
{
$oP->add("
\n");
$oP->add("\n");
- $aPreviousParams = array('mode');
+
+ //AddHiddenParam($oP, 'source_dir', 'datamodel');
+ AddHiddenParam($oP, 'source_dir', 'modules'); // not ready for the big bang ?
+ AddHiddenParam($oP, 'target_dir', 'env-production');
+
+ $aPreviousParams = array('mode', 'source_dir', 'target_dir');
AddParamsToForm($oP, $aParamValues, $aPreviousParams);
$oP->add("
\n");
$oP->add("
\n");
@@ -709,7 +688,7 @@ function LicenceAcknowledgement($oP, $aParamValues, $iCurrentStep)
* Display the form for the first step of the configuration wizard
* which consists in the database server selection
*/
-function DatabaseServerSelection(SetupWebPage $oP, $aParamValues, $iCurrentStep)
+function DatabaseServerSelection(SetupPage $oP, $aParamValues, $iCurrentStep)
{
$sNextOperation = 'step'.($iCurrentStep+1);
$iPrevStep = 1;
@@ -752,7 +731,7 @@ function DatabaseServerSelection(SetupWebPage $oP, $aParamValues, $iCurrentStep)
* 1) Validating the parameters by connecting to the database server
* 2) Prompting to select an existing database or to create a new one
*/
-function DatabaseInstanceSelection(SetupWebPage $oP, $aParamValues, $iCurrentStep, $oConfig)
+function DatabaseInstanceSelection(SetupPage $oP, $aParamValues, $iCurrentStep, $oConfig)
{
$sNextOperation = 'step'.($iCurrentStep+1);
$iPrevStep = 2;
@@ -773,12 +752,6 @@ function DatabaseInstanceSelection(SetupWebPage $oP, $aParamValues, $iCurrentSte
}
else
{
- // Connection is Ok, save it and continue the setup wizard
- $oConfig->SetDBHost($sDBServer);
- $oConfig->SetDBUser($sDBUser);
- $oConfig->SetDBPwd($sDBPwd);
- $oConfig->WriteToFile();
-
$oP->add("