diff --git a/core/config.class.inc.php b/core/config.class.inc.php index 0206af775..fc8f20f29 100644 --- a/core/config.class.inc.php +++ b/core/config.class.inc.php @@ -105,10 +105,31 @@ class Config public function __construct($sConfigFile, $bLoadConfig = true) { $this->m_sFile = $sConfigFile; - $this->m_aAppModules = array(); + $this->m_aAppModules = array( + // Some default modules, always present can be move to an official iTop Module later if needed + '../application/transaction.class.inc.php', + '../application/menunode.class.inc.php', + '../application/user.preferences.class.inc.php', + '../application/audit.rule.class.inc.php', +// Romain - That's dirty, because those 3 classes are in fact part of the core +// but I needed those classes to be derived from cmdbAbstractObject +// (to be managed via the GUI) and this class in not really known from +// the core, PLUS I needed the includes to be there also for the setup +// to create the tables. + '../core/event.class.inc.php', + '../core/action.class.inc.php', + '../core/trigger.class.inc.php', + ); $this->m_aDataModels = array(); - $this->m_aAddons = array(); - $this->m_aDictionaries = array(); + $this->m_aAddons = array( + // Default AddOn, always present can be moved to an official iTop Module later if needed + 'user rights' => '../addons/userrights/userrightsprofile.class.inc.php', + ); + $this->m_aDictionaries = array( + // Default dictionaries, always present can be moved to an official iTop Module later if needed + '../dictionaries/dictionary.itop.core.php', + '../dictionaries/dictionary.itop.ui.php', + ); $this->m_sDBHost = ''; $this->m_sDBUser = ''; @@ -244,21 +265,37 @@ class Config { return $this->m_aAppModules; } + public function SetAppModules($aAppModules) + { + $this->m_aAppModules = $aAppModules; + } public function GetDataModels() { return $this->m_aDataModels; } + public function SetDataModels($aDataModels) + { + $this->m_aDataModels = $aDataModels; + } public function GetAddons() { return $this->m_aAddons; } + public function SetAddons($aAddons) + { + $this->m_aAddons = $aAddons; + } public function GetDictionaries() { return $this->m_aDictionaries; } + public function SetDictionaries($aDictionaries) + { + $this->m_aDictionaries = $aDictionaries; + } public function GetDBHost() { @@ -466,33 +503,28 @@ class Config fwrite($hFile, " */\n"); fwrite($hFile, "\$MyModules = array(\n"); fwrite($hFile, "\t'application' => array (\n"); - fwrite($hFile, "\t\t'../application/transaction.class.inc.php',\n"); - fwrite($hFile, "\t\t'../application/menunode.class.inc.php',\n"); - fwrite($hFile, "\t\t'../application/user.preferences.class.inc.php',\n"); - fwrite($hFile, "\t\t'../application/audit.rule.class.inc.php',\n"); -// Romain - That's dirty, because those 3 classes are in fact part of the core -// but I needed those classes to be derived from cmdbAbstractObject -// (to be managed via the GUI) and this class in not really known from -// the core, PLUS I needed the includes to be there also for the setup -// to create the tables. - fwrite($hFile, "\t\t'../core/event.class.inc.php',\n"); - fwrite($hFile, "\t\t'../core/action.class.inc.php',\n"); - fwrite($hFile, "\t\t'../core/trigger.class.inc.php',\n"); - fwrite($hFile, "\t\t// to be continued...\n"); + foreach($this->m_aAppModules as $sFile) + { + fwrite($hFile, "\t\t'$sFile',\n"); + } fwrite($hFile, "\t),\n"); fwrite($hFile, "\t'business' => array (\n"); - fwrite($hFile, "\t\t'../business/itop.business.class.inc.php'\n"); - fwrite($hFile, "\t\t// to be continued...\n"); + foreach($this->m_aDataModels as $sFile) + { + fwrite($hFile, "\t\t'$sFile',\n"); + } fwrite($hFile, "\t),\n"); fwrite($hFile, "\t'addons' => array (\n"); - fwrite($hFile, "\t\t'user rights' => '../addons/userrights/userrightsprofile.class.inc.php',\n"); - fwrite($hFile, "\t\t// other modules to come later\n"); + foreach($this->m_aAddons as $sKey => $sFile) + { + fwrite($hFile, "\t\t'$sKey' => '$sFile',\n"); + } fwrite($hFile, "\t),\n"); fwrite($hFile, "\t'dictionaries' => array (\n"); - fwrite($hFile, "\t\t'../dictionaries/dictionary.itop.model.php',\n"); - fwrite($hFile, "\t\t'../dictionaries/dictionary.itop.core.php',\n"); - fwrite($hFile, "\t\t'../dictionaries/dictionary.itop.ui.php',\n"); - fwrite($hFile, "\t\t// to be continued...\n"); + foreach($this->m_aDictionaries as $sFile) + { + fwrite($hFile, "\t\t'$sFile',\n"); + } fwrite($hFile, "\t),\n"); fwrite($hFile, ");\n"); fwrite($hFile, '?'.'>'); // Avoid perturbing the syntax highlighting ! diff --git a/core/metamodel.class.php b/core/metamodel.class.php index b8420641d..87c408c03 100644 --- a/core/metamodel.class.php +++ b/core/metamodel.class.php @@ -1294,10 +1294,10 @@ abstract class MetaModel return self::$m_Category2Class[$sCategory]; } - if (count(self::$m_Category2Class) > 0) - { - throw new CoreException("unkown class category '$sCategory', expecting a value in {".implode(', ', array_keys(self::$m_Category2Class))."}"); - } + //if (count(self::$m_Category2Class) > 0) + //{ + // throw new CoreException("unkown class category '$sCategory', expecting a value in {".implode(', ', array_keys(self::$m_Category2Class))."}"); + //} return array(); } diff --git a/modules/itop-basic-1.0.0/module.itop-basic.php b/modules/itop-basic-1.0.0/module.itop-basic.php index ff99a61f3..8804e299b 100644 --- a/modules/itop-basic-1.0.0/module.itop-basic.php +++ b/modules/itop-basic-1.0.0/module.itop-basic.php @@ -2,11 +2,12 @@ SetupWebPage::AddModule( + __FILE__, // Path to the current file, all other file names are relative to the directory containing this file 'itop-basic/1.0.0', array( // Identification // - 'label' => 'Change Management', + 'label' => 'iTop Basic Model', // Setup // 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 6c2421856..3e0d69c4c 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 @@ -2,6 +2,7 @@ SetupWebPage::AddModule( + __FILE__, // Path to the current file, all other file names are relative to the directory containing this file 'itop-change-mgmt/1.0.0', array( // Identification diff --git a/modules/itop-config-mgmt-1.0.0/module.itop-config-mgmt.php b/modules/itop-config-mgmt-1.0.0/module.itop-config-mgmt.php index 2e0889d32..f836a5583 100644 --- a/modules/itop-config-mgmt-1.0.0/module.itop-config-mgmt.php +++ b/modules/itop-config-mgmt-1.0.0/module.itop-config-mgmt.php @@ -2,6 +2,7 @@ SetupWebPage::AddModule( + __FILE__, // Path to the current file, all other file names are relative to the directory containing this file 'itop-config-mgmt/1.0.0', array( // Identification diff --git a/modules/itop-incident-mgmt-1.0.0/module.itop-incident-mgmt.php b/modules/itop-incident-mgmt-1.0.0/module.itop-incident-mgmt.php index 734485914..dd804dbe7 100644 --- a/modules/itop-incident-mgmt-1.0.0/module.itop-incident-mgmt.php +++ b/modules/itop-incident-mgmt-1.0.0/module.itop-incident-mgmt.php @@ -2,6 +2,7 @@ SetupWebPage::AddModule( + __FILE__, // Path to the current file, all other file names are relative to the directory containing this file 'itop-incident-mgmt/1.0.0', array( // Identification diff --git a/modules/itop-knownerror-mgmt-1.0.0/module.itop-knownerror-mgmt.php b/modules/itop-knownerror-mgmt-1.0.0/module.itop-knownerror-mgmt.php index 78ed17aff..359d68d5d 100644 --- a/modules/itop-knownerror-mgmt-1.0.0/module.itop-knownerror-mgmt.php +++ b/modules/itop-knownerror-mgmt-1.0.0/module.itop-knownerror-mgmt.php @@ -2,6 +2,7 @@ SetupWebPage::AddModule( + __FILE__, // Path to the current file, all other file names are relative to the directory containing this file 'itop-knownerror-mgmt/1.0.0', array( // Identification diff --git a/modules/itop-problem-mgmt-1.0.0/module.itop-problem-mgmt.php b/modules/itop-problem-mgmt-1.0.0/module.itop-problem-mgmt.php index b1306658c..793eee1e7 100644 --- a/modules/itop-problem-mgmt-1.0.0/module.itop-problem-mgmt.php +++ b/modules/itop-problem-mgmt-1.0.0/module.itop-problem-mgmt.php @@ -2,11 +2,12 @@ SetupWebPage::AddModule( + __FILE__, // Path to the current file, all other file names are relative to the directory containing this file 'itop-problem-mgmt/1.0.0', array( // Identification // - 'label' => 'Problem Managemen', + 'label' => 'Problem Management', // Setup // diff --git a/modules/itop-request-mgmt-1.0.0/module.itop-request-mgmt.php b/modules/itop-request-mgmt-1.0.0/module.itop-request-mgmt.php index 1b5a26a37..cb233b713 100644 --- a/modules/itop-request-mgmt-1.0.0/module.itop-request-mgmt.php +++ b/modules/itop-request-mgmt-1.0.0/module.itop-request-mgmt.php @@ -2,6 +2,7 @@ SetupWebPage::AddModule( + __FILE__, // Path to the current file, all other file names are relative to the directory containing this file 'itop-request-mgmt/1.0.0', array( // Identification diff --git a/modules/itop-service-mgmt-1.0.0/module.itop-service-mgmt.php b/modules/itop-service-mgmt-1.0.0/module.itop-service-mgmt.php index 2c7652990..b338da1b6 100644 --- a/modules/itop-service-mgmt-1.0.0/module.itop-service-mgmt.php +++ b/modules/itop-service-mgmt-1.0.0/module.itop-service-mgmt.php @@ -2,6 +2,7 @@ SetupWebPage::AddModule( + __FILE__, // Path to the current file, all other file names are relative to the directory containing this file 'itop-service-mgmt/1.0.0', array( // Identification diff --git a/setup/ajax.dataloader.php b/setup/ajax.dataloader.php index 1ddd98a82..4a8667b76 100644 --- a/setup/ajax.dataloader.php +++ b/setup/ajax.dataloader.php @@ -127,7 +127,7 @@ try $oDataLoader->LoadFile($sFileName); $sResult = sprintf("loading of %s done. (Overall %d %% completed).", basename($sFileName), $iPercent); - echo $sResult; + //echo $sResult; SetupWebPage::log_info($sResult); if ($sSessionStatus == 'end') @@ -138,6 +138,7 @@ try } catch(Exception $e) { + header("HTTP/1.0 500 Internal server error."); echo "
An error happened while loading the data
\n"; echo ''.$e."
\n"; SetupWebPage::log_error("An error happened while loading the data. ".$e); diff --git a/setup/index.php b/setup/index.php index b516c62d1..2de96ad61 100644 --- a/setup/index.php +++ b/setup/index.php @@ -38,9 +38,13 @@ define('MYSQL_MIN_VERSION', '5.0.0'); define('MIN_MEMORY_LIMIT', 32*1024*1024); -$sOperation = Utils::ReadParam('operation', 'step1'); +$sOperation = Utils::ReadParam('operation', 'step0'); $oP = new SetupWebPage('iTop configuration wizard'); +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Various helper function +/////////////////////////////////////////////////////////////////////////////////////////////////// + /** * Get a nicely formatted version string */ @@ -262,7 +266,7 @@ function CheckPHPVersion(SetupWebPage $oP) return $bResult; } - + /** * Helper function check the connection to the database and (if connected) to enumerate * the existing databases @@ -359,8 +363,8 @@ function InitDataModel(SetupWebPage $oP, $sConfigFileName, $bAllowMissingDatabas */ function CreateDatabaseStructure(SetupWebPage $oP, Config $oConfig, $sDBName, $sDBPrefix) { - InitDataModel($oP, TMP_CONFIG_FILE, true); // Allow the DB to NOT exist since we're about to create it ! + InitDataModel($oP, TMP_CONFIG_FILE, true); // Allow the DB to NOT exist since we're about to create it ! $oP->log('Info - CreateDatabaseStructure'); if (strlen($sDBPrefix) > 0) { @@ -375,7 +379,7 @@ function CreateDatabaseStructure(SetupWebPage $oP, Config $oConfig, $sDBName, $s if (!MetaModel::DBExists(/* bMustBeComplete */ false)) { MetaModel::DBCreate(); - $oP->ok("Database structure successfuly created."); + $oP->ok("Database structure successfully created."); } else { @@ -412,48 +416,68 @@ function CreateAdminAccount(SetupWebPage $oP, Config $oConfig, $sAdminUser, $sAd } } -//aFilesToLoad[aFilesToLoad.length] = './menus.xml'; // First load the menus - -function ListDataFiles($sDirectory, SetupWebPage $oP) +function ListModuleFiles($sDirectory, SetupWebPage $oP) { - $aFilesToLoad = array(); - if ($hDir = @opendir($sDirectory)) + //echo "$sDirectory
\n"; + if ($hDir = opendir($sDirectory)) { // This is the correct way to loop over the directory. (according to the documentation) while (($sFile = readdir($hDir)) !== false) { - $sExtension = pathinfo($sFile, PATHINFO_EXTENSION ); - if (strcasecmp($sExtension, 'xml') == 0) + $aMatches = array(); + if (is_dir($sDirectory.'/'.$sFile)) { - $aFilesToLoad[] = $sDirectory.'/'.$sFile; + if (($sFile != '.') && ($sFile != '..') && ($sFile != '.svn')) + { + ListModuleFiles($sDirectory.'/'.$sFile, $oP); + } + } + else if (preg_match('/^module\.(.*).php$/i', $sFile, $aMatches)) + { + try + { + //echo "Loading: $sDirectory/$sFile...
\n"; + require_once($sDirectory.'/'.$sFile); + //echo "Done.
\n"; + } + catch(Exception $e) + { + // Continue... + } } } closedir($hDir); - // Load order is important we expect the files to be ordered - // like numbered 1.Organizations.xml 2.Locations.xml , etc. - asort($aFilesToLoad); } else { $oP->error("Data directory (".$sDirectory.") not found or not readable."); } - return $aFilesToLoad; } /** * Scans the ./data directory for XML files and output them as a Javascript array */ -function PopulateDataFilesList(SetupWebPage $oP) +function PopulateDataFilesList(SetupWebPage $oP, $aParamValues) { $oP->add("