diff --git a/application/itopwebpage.class.inc.php b/application/itopwebpage.class.inc.php
index e76217c93..1d1cd04bd 100644
--- a/application/itopwebpage.class.inc.php
+++ b/application/itopwebpage.class.inc.php
@@ -1,5 +1,5 @@
1)
{
$oConfig = MetaModel::GetConfig();
- $siTopInstanceId = json_encode(utils::GetAbsoluteUrlAppRoot().'==='.$oConfig->GetDBHost().'/'.$oConfig->GetDBName().'/'.$oConfig->GetDBSubname());
+ $siTopInstanceId = json_encode(utils::GetAbsoluteUrlAppRoot().'==='.$oConfig->Get('db_host').'/'.$oConfig->Get('db_name').'/'.$oConfig->Get('db_subname'));
if ($this->bBreadCrumbEnabled)
{
if (is_null($this->sBreadCrumbEntryId))
diff --git a/core/cmdbsource.class.inc.php b/core/cmdbsource.class.inc.php
index b57b2b1e0..0adc1308f 100644
--- a/core/cmdbsource.class.inc.php
+++ b/core/cmdbsource.class.inc.php
@@ -1,5 +1,5 @@
Get('db_host');
+ $sUser = $oConfig->Get('db_user');
+ $sPwd = $oConfig->Get('db_pwd');
+ $sSource = $oConfig->Get('db_name');
+ $sSSLKey = $oConfig->Get('db_ssl.key');
+ $sSSLCert = $oConfig->Get('db_ssl.cert');
+ $sSSLCA = $oConfig->Get('db_ssl.ca');
+ $sSSLCipher = $oConfig->Get('db_ssl.cipher');
+
+ self::Init($sServer, $sUser, $sPwd, $sSource, $sSSLKey, $sSSLCert, $sSSLCA, $sSSLCipher);
+
+ $sCharacterSet = $oConfig->Get('db_character_set');
+ $sCollation = $oConfig->Get('db_collation');
+ self::SetCharacterSet($sCharacterSet, $sCollation);
+ }
+
/**
* @param string $sServer
* @param string $sUser
diff --git a/core/config.class.inc.php b/core/config.class.inc.php
index a37837209..02c6c767f 100644
--- a/core/config.class.inc.php
+++ b/core/config.class.inc.php
@@ -1,5 +1,5 @@
array(
'type' => 'string',
@@ -107,6 +111,83 @@ class Config
'source_of_value' => '',
'show_in_conf_sample' => false,
),
+ 'db_host' => array(
+ 'type' => 'string',
+ 'default' => null,
+ 'value' => '',
+ 'source_of_value' => '',
+ 'show_in_conf_sample' => true,
+ ),
+ 'db_user' => array(
+ 'type' => 'string',
+ 'default' => null,
+ 'value' => '',
+ 'source_of_value' => '',
+ 'show_in_conf_sample' => true,
+ ),
+ 'db_pwd' => array(
+ 'type' => 'string',
+ 'default' => null,
+ 'value' => '',
+ 'source_of_value' => '',
+ 'show_in_conf_sample' => true,
+ ),
+ 'db_name' => array(
+ 'type' => 'string',
+ 'default' => null,
+ 'value' => '',
+ 'source_of_value' => '',
+ 'show_in_conf_sample' => true,
+ ),
+ 'db_subname' => array(
+ 'type' => 'string',
+ 'default' => null,
+ 'value' => '',
+ 'source_of_value' => '',
+ 'show_in_conf_sample' => true,
+ ),
+ 'db_ssl.key' => array(
+ 'type' => 'string',
+ 'default' => null,
+ 'value' => '',
+ 'source_of_value' => '',
+ 'show_in_conf_sample' => true,
+ ),
+ 'db_ssl.cert' => array(
+ 'type' => 'string',
+ 'default' => null,
+ 'value' => '',
+ 'source_of_value' => '',
+ 'show_in_conf_sample' => true,
+ ),
+ 'db_ssl.ca' => array(
+ 'type' => 'string',
+ 'default' => null,
+ 'value' => '',
+ 'source_of_value' => '',
+ 'show_in_conf_sample' => true,
+ ),
+ 'db_ssl.cipher' => array(
+ 'type' => 'string',
+ 'default' => null,
+ 'value' => '',
+ 'source_of_value' => '',
+ 'show_in_conf_sample' => true,
+ ),
+ 'db_character_set' => array(
+ 'type' => 'string',
+ 'default' => null,
+ 'value' => '',
+ 'source_of_value' => '',
+ 'show_in_conf_sample' => true,
+ ),
+ 'db_collation' => array(
+ 'type' => 'string',
+ 'default' => null,
+ 'value' => '',
+ 'source_of_value' => '',
+ 'show_in_conf_sample' => true,
+ ),
'skip_check_to_write' => array(
'type' => 'bool',
'description' => 'Disable data format and integrity checks to boost up data load (insert or update)',
@@ -195,22 +276,22 @@ class Config
'source_of_value' => '',
'show_in_conf_sample' => false,
),
- 'allow_menu_on_linkset' => array(
- 'type' => 'bool',
- 'description' => 'Display Action menus in view mode on any LinkedSet with edit_mode != none',
- 'default' => false,
- 'value' => false,
- 'source_of_value' => '',
- 'show_in_conf_sample' => false,
- ),
- 'allow_target_creation' => array(
- 'type' => 'bool',
- 'description' => 'Displays the + button on external keys to create target objects',
- 'default' => true,
- 'value' => true,
- 'source_of_value' => '',
- 'show_in_conf_sample' => false,
- ),
+ 'allow_menu_on_linkset' => array(
+ 'type' => 'bool',
+ 'description' => 'Display Action menus in view mode on any LinkedSet with edit_mode != none',
+ 'default' => false,
+ 'value' => false,
+ 'source_of_value' => '',
+ 'show_in_conf_sample' => false,
+ ),
+ 'allow_target_creation' => array(
+ 'type' => 'bool',
+ 'description' => 'Displays the + button on external keys to create target objects',
+ 'default' => true,
+ 'value' => true,
+ 'source_of_value' => '',
+ 'show_in_conf_sample' => false,
+ ),
// Levels that trigger a confirmation in the CSV import/synchro wizard
'csv_import_min_object_confirmation' => array(
'type' => 'integer',
@@ -448,7 +529,15 @@ class Config
'type' => 'string',
'description' => 'Timezone (reference: http://php.net/manual/en/timezones.php). If empty, it will be left unchanged and MUST be explicitely configured in PHP',
// examples... not used (nor 'description')
- 'examples' => array('America/Sao_Paulo', 'America/New_York (standing for EDT)', 'America/Los_Angeles (standing for PDT)', 'Asia/Istanbul', 'Asia/Singapore', 'Africa/Casablanca', 'Australia/Sydney'),
+ 'examples' => array(
+ 'America/Sao_Paulo',
+ 'America/New_York (standing for EDT)',
+ 'America/Los_Angeles (standing for PDT)',
+ 'Asia/Istanbul',
+ 'Asia/Singapore',
+ 'Africa/Casablanca',
+ 'Australia/Sydney'
+ ),
'default' => 'Europe/Paris',
'value' => 'Europe/Paris',
'source_of_value' => '',
@@ -816,7 +905,7 @@ class Config
'default' => LINKSET_TRACKING_ALL,
'value' => LINKSET_TRACKING_ALL,
'source_of_value' => '',
- 'show_in_conf_sample' => false,
+ 'show_in_conf_sample' => false,
),
'user_rights_legacy' => array(
'type' => 'bool',
@@ -889,7 +978,7 @@ class Config
'value' => '',
'source_of_value' => '',
'show_in_conf_sample' => false,
- ),
+ ),
'concurrent_lock_override_profiles' => array(
'type' => 'array',
'description' => 'The list of profiles allowed to "kill" a lock',
@@ -897,7 +986,7 @@ class Config
'value' => '',
'source_of_value' => '',
'show_in_conf_sample' => false,
- ),
+ ),
'html_sanitizer' => array(
'type' => 'string',
'description' => 'The class to use for HTML sanitization: HTMLDOMSanitizer, HTMLPurifierSanitizer or HTMLNullSanitizer',
@@ -976,6 +1065,7 @@ class Config
{
return (array_key_exists($sPropCode, $this->m_aSettings));
}
+
public function GetDescription($sPropCode)
{
return $this->m_aSettings[$sPropCode];
@@ -984,24 +1074,24 @@ class Config
public function Set($sPropCode, $value, $sSourceDesc = 'unknown')
{
$sType = $this->m_aSettings[$sPropCode]['type'];
- switch($sType)
+ switch ($sType)
{
- case 'bool':
- $value = (bool) $value;
- break;
- case 'string':
- $value = (string) $value;
- break;
- case 'integer':
- $value = (integer) $value;
- break;
- case 'float':
- $value = (float) $value;
- break;
- case 'array':
- break;
- default:
- throw new CoreException('Unknown type for setting', array('property' => $sPropCode, 'type' => $sType));
+ case 'bool':
+ $value = (bool)$value;
+ break;
+ case 'string':
+ $value = (string)$value;
+ break;
+ case 'integer':
+ $value = (integer)$value;
+ break;
+ case 'float':
+ $value = (float)$value;
+ break;
+ case 'array':
+ break;
+ default:
+ throw new CoreException('Unknown type for setting', array('property' => $sPropCode, 'type' => $sType));
}
$this->m_aSettings[$sPropCode]['value'] = $value;
$this->m_aSettings[$sPropCode]['source_of_value'] = $sSourceDesc;
@@ -1013,22 +1103,9 @@ class Config
return $this->m_aSettings[$sPropCode]['value'];
}
- // Those variables will be deprecated later, when the transition to ...Get('my_setting') will be done
- protected $m_sDBHost;
- protected $m_sDBUser;
- protected $m_sDBPwd;
- protected $m_sDBName;
- protected $m_sDBSubname;
- protected $m_sDBSSLKey;
- protected $m_sDBSSLCert;
- protected $m_sDBSSLCA;
- protected $m_sDBSSLCipher;
- protected $m_sDBCharacterSet;
- protected $m_sDBCollation;
-
/**
* Event log options (see LOG_... definition)
- */
+ */
// Those variables will be deprecated later, when the transition to ...Get('my_setting') will be done
protected $m_bLogGlobal;
protected $m_bLogNotification;
@@ -1038,56 +1115,56 @@ class Config
/**
* @var integer Number of elements to be displayed when there are more than m_iMaxDisplayLimit elements
- */
+ */
protected $m_iMinDisplayLimit;
/**
* @var integer Max number of elements before truncating the display
- */
+ */
protected $m_iMaxDisplayLimit;
/**
* @var integer Number of seconds between two reloads of the display (standard)
- */
+ */
protected $m_iStandardReloadInterval;
/**
* @var integer Number of seconds between two reloads of the display (fast)
- */
+ */
protected $m_iFastReloadInterval;
-
+
/**
* @var boolean Whether or not a secure connection is required for using the application.
* If set, any attempt to connect to an iTop page with http:// will be redirected
* to https://
- */
+ */
protected $m_bSecureConnectionRequired;
/**
* @var string Langage code, default if the user language is undefined
- */
+ */
protected $m_sDefaultLanguage;
-
+
/**
* @var string Type of login process allowed: form|basic|url|external
*/
- protected $m_sAllowedLoginTypes;
-
+ protected $m_sAllowedLoginTypes;
+
/**
* @var string Name of the PHP variable in which external authentication information is passed by the web server
*/
- protected $m_sExtAuthVariable;
+ protected $m_sExtAuthVariable;
/**
* @var string Encryption key used for all attributes of type "encrypted string". Can be set to a random value
* unless you want to import a database from another iTop instance, in which case you must use
* the same encryption key in order to properly decode the encrypted fields
*/
- protected $m_sEncryptionKey;
+ protected $m_sEncryptionKey;
/**
* @var array Additional character sets to be supported by the interactive CSV import
* 'iconv_code' => 'display name'
*/
- protected $m_aCharsets;
+ protected $m_aCharsets;
public function __construct($sConfigFile = null, $bLoadConfig = true)
{
@@ -1101,23 +1178,12 @@ class Config
// Default AddOn, always present can be moved to an official iTop Module later if needed
'user rights' => 'addons/userrights/userrightsprofile.class.inc.php',
);
-
- foreach($this->m_aSettings as $sPropCode => $aSettingInfo)
+
+ foreach ($this->m_aSettings as $sPropCode => $aSettingInfo)
{
$this->m_aSettings[$sPropCode]['value'] = $aSettingInfo['default'];
}
- $this->m_sDBHost = '';
- $this->m_sDBUser = '';
- $this->m_sDBPwd = '';
- $this->m_sDBName = '';
- $this->m_sDBSubname = '';
- $this->m_sDBSSLKey = '';
- $this->m_sDBSSLCert = '';
- $this->m_sDBSSLCA = '';
- $this->m_sDBSSLCipher = '';
- $this->m_sDBCharacterSet = DEFAULT_CHARACTER_SET;
- $this->m_sDBCollation = DEFAULT_COLLATION;
$this->m_bLogGlobal = DEFAULT_LOG_GLOBAL;
$this->m_bLogNotification = DEFAULT_LOG_NOTIFICATION;
$this->m_bLogIssue = DEFAULT_LOG_ISSUE;
@@ -1133,7 +1199,7 @@ class Config
$this->m_sEncryptionKey = DEFAULT_ENCRYPTION_KEY;
$this->m_aCharsets = array();
$this->m_bQueryCacheEnabled = DEFAULT_QUERY_CACHE_ENABLED;
-
+
$this->m_aModuleSettings = array();
if ($bLoadConfig)
@@ -1142,20 +1208,20 @@ class Config
$this->Verify();
}
- // Application root url: set a default value, then normalize it
-/*
- * Does not work in CLI/unattended mode
- $sAppRootUrl = trim($this->Get('app_root_url'));
- if (strlen($sAppRootUrl) == 0)
- {
- $sAppRootUrl = utils::GetDefaultUrlAppRoot();
- }
- if (substr($sAppRootUrl, -1, 1) != '/')
- {
- $sAppRootUrl .= '/';
- }
- $this->Set('app_root_url', $sAppRootUrl);
- */
+ // Application root url: set a default value, then normalize it
+ /*
+ * Does not work in CLI/unattended mode
+ $sAppRootUrl = trim($this->Get('app_root_url'));
+ if (strlen($sAppRootUrl) == 0)
+ {
+ $sAppRootUrl = utils::GetDefaultUrlAppRoot();
+ }
+ if (substr($sAppRootUrl, -1, 1) != '/')
+ {
+ $sAppRootUrl .= '/';
+ }
+ $this->Set('app_root_url', $sAppRootUrl);
+ */
}
protected function CheckFile($sPurpose, $sFileName)
@@ -1166,10 +1232,17 @@ class Config
}
if (!is_readable($sFileName))
{
- throw new ConfigException("Could not read $sPurpose file (the file exists but cannot be read). Do you have the rights to access this file?", array('file' => $sFileName));
+ throw new ConfigException("Could not read $sPurpose file (the file exists but cannot be read). Do you have the rights to access this file?",
+ array('file' => $sFileName));
}
}
+ /**
+ * @param string $sConfigFile
+ *
+ * @throws \ConfigException
+ * @throws \CoreException
+ */
protected function Load($sConfigFile)
{
$this->CheckFile('configuration', $sConfigFile);
@@ -1198,22 +1271,26 @@ class Config
{
// well, never reach in case of parsing error :-(
// will be improved in PHP 6 ?
- throw new ConfigException('Error in configuration file', array('file' => $sConfigFile, 'error' => $e->getMessage()));
+ throw new ConfigException('Error in configuration file',
+ array('file' => $sConfigFile, 'error' => $e->getMessage()));
}
if (strlen($sNoise) > 0)
{
// Note: sNoise is an html output, but so far it was ok for me (e.g. showing the entire call stack)
- throw new ConfigException('Syntax error in configuration file', array('file' => $sConfigFile, 'error' => ''.htmlentities($sNoise, ENT_QUOTES, 'UTF-8').''));
+ throw new ConfigException('Syntax error in configuration file',
+ array('file' => $sConfigFile, 'error' => ''.htmlentities($sNoise, ENT_QUOTES, 'UTF-8').''));
}
if (!isset($MySettings) || !is_array($MySettings))
{
- throw new ConfigException('Missing array in configuration file', array('file' => $sConfigFile, 'expected' => '$MySettings'));
+ throw new ConfigException('Missing array in configuration file',
+ array('file' => $sConfigFile, 'expected' => '$MySettings'));
}
if (!array_key_exists('addons', $MyModules))
{
- throw new ConfigException('Missing item in configuration file', array('file' => $sConfigFile, 'expected' => '$MyModules[\'addons\']'));
+ throw new ConfigException('Missing item in configuration file',
+ array('file' => $sConfigFile, 'expected' => '$MyModules[\'addons\']'));
}
if (!array_key_exists('user rights', $MyModules['addons']))
{
@@ -1223,7 +1300,7 @@ class Config
$this->m_aAddons = $MyModules['addons'];
- foreach($MySettings as $sPropCode => $rawvalue)
+ foreach ($MySettings as $sPropCode => $rawvalue)
{
if ($this->IsProperty($sPropCode))
{
@@ -1239,32 +1316,19 @@ class Config
}
}
- $this->m_sDBHost = trim($MySettings['db_host']);
- $this->m_sDBUser = trim($MySettings['db_user']);
- $this->m_sDBPwd = trim($MySettings['db_pwd']);
- $this->m_sDBName = trim($MySettings['db_name']);
- $this->m_sDBSubname = trim($MySettings['db_subname']);
- $this->m_sDBSSLKey = isset($MySettings['db_ssl.key']) ? (trim($MySettings['db_ssl.key'])) : '';
- $this->m_sDBSSLCert = isset($MySettings['db_ssl.cert']) ? (trim($MySettings['db_ssl.cert'])) : '';
- $this->m_sDBSSLCA = isset($MySettings['db_ssl.ca']) ? (trim($MySettings['db_ssl.ca'])) : '';
- $this->m_sDBSSLCipher = isset($MySettings['db_ssl.cipher']) ? trim($MySettings['db_ssl.cipher']) : '';
-
- $this->m_sDBCharacterSet = isset($MySettings['db_character_set']) ? trim($MySettings['db_character_set']) : DEFAULT_CHARACTER_SET;
- $this->m_sDBCollation = isset($MySettings['db_collation']) ? trim($MySettings['db_collation']) : DEFAULT_COLLATION;
-
- $this->m_bLogGlobal = isset($MySettings['log_global']) ? (bool) trim($MySettings['log_global']) : DEFAULT_LOG_GLOBAL;
- $this->m_bLogNotification = isset($MySettings['log_notification']) ? (bool) trim($MySettings['log_notification']) : DEFAULT_LOG_NOTIFICATION;
- $this->m_bLogIssue = isset($MySettings['log_issue']) ? (bool) trim($MySettings['log_issue']) : DEFAULT_LOG_ISSUE;
- $this->m_bLogWebService = isset($MySettings['log_web_service']) ? (bool) trim($MySettings['log_web_service']) : DEFAULT_LOG_WEB_SERVICE;
- $this->m_bQueryCacheEnabled = isset($MySettings['query_cache_enabled']) ? (bool) trim($MySettings['query_cache_enabled']) : DEFAULT_QUERY_CACHE_ENABLED;
+ $this->m_bLogGlobal = isset($MySettings['log_global']) ? (bool)trim($MySettings['log_global']) : DEFAULT_LOG_GLOBAL;
+ $this->m_bLogNotification = isset($MySettings['log_notification']) ? (bool)trim($MySettings['log_notification']) : DEFAULT_LOG_NOTIFICATION;
+ $this->m_bLogIssue = isset($MySettings['log_issue']) ? (bool)trim($MySettings['log_issue']) : DEFAULT_LOG_ISSUE;
+ $this->m_bLogWebService = isset($MySettings['log_web_service']) ? (bool)trim($MySettings['log_web_service']) : DEFAULT_LOG_WEB_SERVICE;
+ $this->m_bQueryCacheEnabled = isset($MySettings['query_cache_enabled']) ? (bool)trim($MySettings['query_cache_enabled']) : DEFAULT_QUERY_CACHE_ENABLED;
$this->m_iMinDisplayLimit = isset($MySettings['min_display_limit']) ? trim($MySettings['min_display_limit']) : DEFAULT_MIN_DISPLAY_LIMIT;
$this->m_iMaxDisplayLimit = isset($MySettings['max_display_limit']) ? trim($MySettings['max_display_limit']) : DEFAULT_MAX_DISPLAY_LIMIT;
$this->m_iStandardReloadInterval = isset($MySettings['standard_reload_interval']) ? trim($MySettings['standard_reload_interval']) : DEFAULT_STANDARD_RELOAD_INTERVAL;
$this->m_iFastReloadInterval = isset($MySettings['fast_reload_interval']) ? trim($MySettings['fast_reload_interval']) : DEFAULT_FAST_RELOAD_INTERVAL;
- $this->m_bSecureConnectionRequired = isset($MySettings['secure_connection_required']) ? (bool) trim($MySettings['secure_connection_required']) : DEFAULT_SECURE_CONNECTION_REQUIRED;
+ $this->m_bSecureConnectionRequired = isset($MySettings['secure_connection_required']) ? (bool)trim($MySettings['secure_connection_required']) : DEFAULT_SECURE_CONNECTION_REQUIRED;
- $this->m_aModuleSettings = isset($MyModuleSettings) ? $MyModuleSettings : array();
+ $this->m_aModuleSettings = isset($MyModuleSettings) ? $MyModuleSettings : array();
$this->m_sDefaultLanguage = isset($MySettings['default_language']) ? trim($MySettings['default_language']) : 'EN US';
$this->m_sAllowedLoginTypes = isset($MySettings['allowed_login_types']) ? trim($MySettings['allowed_login_types']) : DEFAULT_ALLOWED_LOGIN_TYPES;
@@ -1285,6 +1349,7 @@ class Config
{
return $this->m_aModuleSettings[$sModule][$sProperty];
}
+
// Fall back to the predefined XML parameter, if any
return $this->GetModuleParameter($sModule, $sProperty, $defaultvalue);
}
@@ -1295,14 +1360,15 @@ class Config
if (class_exists('ModulesXMLParameters'))
{
$aAllParams = ModulesXMLParameters::GetData($sModule);
- if(array_key_exists($sProperty, $aAllParams))
+ if (array_key_exists($sProperty, $aAllParams))
{
$ret = $aAllParams[$sProperty];
}
}
+
return $ret;
}
-
+
public function SetModuleSetting($sModule, $sProperty, $value)
{
$this->m_aModuleSettings[$sModule][$sProperty] = $value;
@@ -1312,61 +1378,80 @@ class Config
{
return $this->m_aAddons;
}
+
public function SetAddons($aAddons)
{
$this->m_aAddons = $aAddons;
}
+ /**
+ * @return string
+ * @deprecated 2.5 will be removed in 2.6
+ * @see Config::Get() as a replacement
+ */
public function GetDBHost()
{
- return $this->m_sDBHost;
+ return $this->Get('db_host');
}
-
+
+ /**
+ * @return string
+ * @deprecated 2.5 will be removed in 2.6
+ * @see Config::Get() as a replacement
+ */
public function GetDBName()
{
- return $this->m_sDBName;
+ return $this->Get('db_name');
}
+ /**
+ * @return string
+ * @deprecated 2.5 will be removed in 2.6
+ * @see Config::Get() as a replacement
+ */
public function GetDBSubname()
{
- return $this->m_sDBSubname;
+ return $this->Get('db_subname');
}
- public function GetDBSSLKey()
- {
- return $this->m_sDBSSLKey;
- }
-
- public function GetDBSSLCert()
- {
- return $this->m_sDBSSLCert;
- }
- public function GetDBSSLCA()
- {
- return $this->m_sDBSSLCA;
- }
- public function GetDBSSLCipher()
- {
- return $this->m_sDBSSLCipher;
- }
+ /**
+ * @return string
+ * @deprecated 2.5 will be removed in 2.6
+ * @see Config::Get() as a replacement
+ */
public function GetDBCharacterSet()
{
- return $this->m_sDBCharacterSet;
+ return $this->Get('db_character_set');
}
+ /**
+ * @return string
+ * @deprecated 2.5 will be removed in 2.6
+ * @see Config::Get() as a replacement
+ */
public function GetDBCollation()
{
- return $this->m_sDBCollation;
+ return $this->Get('db_collation');
}
+ /**
+ * @return string
+ * @deprecated 2.5 will be removed in 2.6
+ * @see Config::Get() as a replacement
+ */
public function GetDBUser()
{
- return $this->m_sDBUser;
+ return $this->Get('db_user');
}
+ /**
+ * @return string
+ * @deprecated 2.5 will be removed in 2.6
+ * @see Config::Get() as a replacement
+ */
public function GetDBPwd()
{
- return $this->m_sDBPwd;
+ return $this->Get('db_pwd');
}
public function GetLogGlobal()
@@ -1448,61 +1533,6 @@ class Config
{
return $this->m_aCharsets;
}
-
- public function SetDBHost($sDBHost)
- {
- $this->m_sDBHost = $sDBHost;
- }
-
- public function SetDBName($sDBName)
- {
- $this->m_sDBName = $sDBName;
- }
-
- public function SetDBSubname($sDBSubName)
- {
- $this->m_sDBSubname = $sDBSubName;
- }
-
- public function SetDBSSLKey($sDBSSLKey)
- {
- $this->m_sDBSSLKey = $sDBSSLKey;
- }
-
- public function SetDBSSLCert($sDBSSLCert)
- {
- $this->m_sDBSSLCert = $sDBSSLCert;
- }
-
- public function SetDBSSLCA($sDBSSLCA)
- {
- $this->m_sDBSSLCA = $sDBSSLCA;
- }
-
- public function SetDBSSLCipher($sDBSSLCipher)
- {
- $this->m_sDBSSLCipher = $sDBSSLCipher;
- }
-
- public function SetDBCharacterSet($sDBCharacterSet)
- {
- $this->m_sDBCharacterSet = $sDBCharacterSet;
- }
-
- public function SetDBCollation($sDBCollation)
- {
- $this->m_sDBCollation = $sDBCollation;
- }
-
- public function SetDBUser($sUser)
- {
- $this->m_sDBUser = $sUser;
- }
-
- public function SetDBPwd($sPwd)
- {
- $this->m_sDBPwd = $sPwd;
- }
public function SetLogGlobal($iLogGlobal)
{
@@ -1577,7 +1607,7 @@ class Config
public function AddCSVImportCharset($sIconvCode, $sDisplayName)
{
$this->m_aCharsets[$sIconvCode] = $sDisplayName;
- }
+ }
public function GetLoadedFile()
{
@@ -1590,15 +1620,16 @@ class Config
return $this->m_sFile;
}
}
-
+
/**
* Render the configuration as an associative array
- * @return boolean True otherwise throws an Exception
- */
+ *
+ * @return array
+ */
public function ToArray()
{
$aSettings = array();
- foreach($this->m_aSettings as $sPropCode => $aSettingInfo)
+ foreach ($this->m_aSettings as $sPropCode => $aSettingInfo)
{
$aSettings[$sPropCode] = $aSettingInfo['value'];
}
@@ -1636,19 +1667,22 @@ class Config
$aSettings['module_settings'][$sModule][$sProperty] = $value;
}
}
- foreach($this->m_aAddons as $sKey => $sFile)
+ foreach ($this->m_aAddons as $sKey => $sFile)
{
$aSettings['addon_list'][] = $sFile;
}
+
return $aSettings;
}
/**
* Write the configuration to a file (php format) that can be reloaded later
* By default write to the same file that was specified when constructing the object
+ *
* @param $sFileName string Name of the file to write to (emtpy to write to the same file)
+ *
* @return boolean True otherwise throws an Exception
- */
+ */
public function WriteToFile($sFileName = '')
{
if (empty($sFileName))
@@ -1663,12 +1697,13 @@ class Config
fwrite($hFile, " *\n");
fwrite($hFile, " * Configuration file, generated by the ".ITOP_APPLICATION." configuration wizard\n");
fwrite($hFile, " *\n");
- fwrite($hFile, " * The file is used in MetaModel::LoadConfig() which does all the necessary initialization job\n");
+ fwrite($hFile,
+ " * The file is used in MetaModel::LoadConfig() which does all the necessary initialization job\n");
fwrite($hFile, " *\n");
fwrite($hFile, " */\n");
-
+
$aConfigSettings = $this->m_aSettings;
-
+
// Old fashioned boolean settings
$aBoolValues = array(
'log_global' => $this->m_bLogGlobal,
@@ -1678,7 +1713,7 @@ class Config
'query_cache_enabled' => $this->m_bQueryCacheEnabled,
'secure_connection_required' => $this->m_bSecureConnectionRequired,
);
- foreach($aBoolValues as $sKey => $bValue)
+ foreach ($aBoolValues as $sKey => $bValue)
{
$aConfigSettings[$sKey] = array(
'show_in_conf_sample' => true,
@@ -1686,7 +1721,7 @@ class Config
'value' => $bValue,
);
}
-
+
// Old fashioned integer settings
$aIntValues = array(
'fast_reload_interval' => $this->m_iFastReloadInterval,
@@ -1694,7 +1729,7 @@ class Config
'min_display_limit' => $this->m_iMinDisplayLimit,
'standard_reload_interval' => $this->m_iStandardReloadInterval,
);
- foreach($aIntValues as $sKey => $iValue)
+ foreach ($aIntValues as $sKey => $iValue)
{
$aConfigSettings[$sKey] = array(
'show_in_conf_sample' => true,
@@ -1705,24 +1740,13 @@ class Config
// Old fashioned remaining values
$aOtherValues = array(
- 'db_host' => $this->m_sDBHost,
- 'db_user' => $this->m_sDBUser,
- 'db_pwd' => $this->m_sDBPwd,
- 'db_name' => $this->m_sDBName,
- 'db_subname' => $this->m_sDBSubname,
- 'db_ssl_key' => $this->m_sDBSSLKey,
- 'db_ssl_cert' => $this->m_sDBSSLCert,
- 'db_ssl_ca' => $this->m_sDBSSLCA,
- 'db_ssl_cipher' => $this->m_sDBSSLCipher,
- 'db_character_set' => $this->m_sDBCharacterSet,
- 'db_collation' => $this->m_sDBCollation,
'default_language' => $this->m_sDefaultLanguage,
'allowed_login_types' => $this->m_sAllowedLoginTypes,
'ext_auth_variable' => $this->m_sExtAuthVariable,
'encryption_key' => $this->m_sEncryptionKey,
'csv_import_charsets' => $this->m_aCharsets,
);
- foreach($aOtherValues as $sKey => $value)
+ foreach ($aOtherValues as $sKey => $value)
{
$aConfigSettings[$sKey] = array(
'show_in_conf_sample' => true,
@@ -1730,22 +1754,22 @@ class Config
'value' => $value,
);
}
-
+
ksort($aConfigSettings);
fwrite($hFile, "\$MySettings = array(\n");
- foreach($aConfigSettings as $sPropCode => $aSettingInfo)
+ foreach ($aConfigSettings as $sPropCode => $aSettingInfo)
{
// Write all values that are either always visible or present in the cloned config file
- if ($aSettingInfo['show_in_conf_sample'] || (!empty($aSettingInfo['source_of_value']) && ($aSettingInfo['source_of_value'] != 'unknown')) )
+ if ($aSettingInfo['show_in_conf_sample'] || (!empty($aSettingInfo['source_of_value']) && ($aSettingInfo['source_of_value'] != 'unknown')))
{
$sType = $aSettingInfo['type'];
- switch($sType)
+ switch ($sType)
{
- case 'bool':
- $sSeenAs = $aSettingInfo['value'] ? 'true' : 'false';
- break;
- default:
- $sSeenAs = self::PrettyVarExport($aSettingInfo['value'], "\t");
+ case 'bool':
+ $sSeenAs = $aSettingInfo['value'] ? 'true' : 'false';
+ break;
+ default:
+ $sSeenAs = self::PrettyVarExport($aSettingInfo['value'], "\t");
}
fwrite($hFile, "\n");
if (isset($aSettingInfo['description']))
@@ -1759,13 +1783,14 @@ class Config
{
$default = $default ? 'true' : 'false';
}
- fwrite($hFile, "\t//\tdefault: ".self::PrettyVarExport($aSettingInfo['default'],"\t//\t\t", true)."\n");
+ fwrite($hFile,
+ "\t//\tdefault: ".self::PrettyVarExport($aSettingInfo['default'], "\t//\t\t", true)."\n");
}
fwrite($hFile, "\t'$sPropCode' => $sSeenAs,\n");
}
}
fwrite($hFile, ");\n");
-
+
fwrite($hFile, "\n");
fwrite($hFile, "/**\n *\n * Modules specific settings\n *\n */\n");
fwrite($hFile, "\$MyModuleSettings = array(\n");
@@ -1780,7 +1805,7 @@ class Config
fwrite($hFile, "\t),\n");
}
fwrite($hFile, ");\n");
-
+
fwrite($hFile, "\n/**\n");
fwrite($hFile, " *\n");
fwrite($hFile, " * Data model modules to be loaded. Names are specified as relative paths\n");
@@ -1788,13 +1813,14 @@ class Config
fwrite($hFile, " */\n");
fwrite($hFile, "\$MyModules = array(\n");
fwrite($hFile, "\t'addons' => array (\n");
- foreach($this->m_aAddons as $sKey => $sFile)
+ foreach ($this->m_aAddons as $sKey => $sFile)
{
fwrite($hFile, "\t\t'$sKey' => '$sFile',\n");
}
fwrite($hFile, "\t),\n");
fwrite($hFile, ");\n");
fwrite($hFile, '?'.'>'); // Avoid perturbing the syntax highlighting !
+
return fclose($hFile);
}
else
@@ -1818,16 +1844,16 @@ class Config
}
if (isset($aParamValues['mode']) && isset($aParamValues['language']))
{
- if (($aParamValues['mode'] == 'install') || $this->GetDefaultLanguage() == '')
+ if (($aParamValues['mode'] == 'install') || $this->GetDefaultLanguage() == '')
{
$this->SetDefaultLanguage($aParamValues['language']);
}
}
if (isset($aParamValues['db_server']))
{
- $this->SetDBHost($aParamValues['db_server']);
- $this->SetDBUser($aParamValues['db_user']);
- $this->SetDBPwd($aParamValues['db_pwd']);
+ $this->Set('db_host', $aParamValues['db_server']);
+ $this->Set('db_user', $aParamValues['db_user']);
+ $this->Set('db_pwd', $aParamValues['db_pwd']);
$sDBName = $aParamValues['db_name'];
if ($sDBName == '')
{
@@ -1837,14 +1863,26 @@ class Config
$sDBName = $aParamValues['new_db_name'];
}
}
- $this->SetDBName($sDBName);
- $this->SetDBSubname($aParamValues['db_prefix']);
- if (isset($aParamValues['db_ssl_key'])) { $this->SetDBSSLKey($aParamValues['db_ssl_key']);}
- if (isset($aParamValues['db_ssl_key'])) { $this->SetDBSSLCert($aParamValues['db_ssl_cert']);}
- if (isset($aParamValues['db_ssl_ca'])) { $this->SetDBSSLCA($aParamValues['db_ssl_ca']);}
- if (isset($aParamValues['db_ssl_cipher'])) { $this->SetDBSSLCipher($aParamValues['db_ssl_cipher']);}
+ $this->Set('db_name', $sDBName);
+ $this->Set('db_subname', $aParamValues['db_prefix']);
+ if (isset($aParamValues['db_ssl_key']))
+ {
+ $this->Set('db_ssl.key', $aParamValues['db_ssl_key']);
+ }
+ if (isset($aParamValues['db_ssl_key']))
+ {
+ $this->Set('db_ssl.cert', $aParamValues['db_ssl_cert']);
+ }
+ if (isset($aParamValues['db_ssl_ca']))
+ {
+ $this->Set('db_ssl.ca', $aParamValues['db_ssl_ca']);
+ }
+ if (isset($aParamValues['db_ssl_cipher']))
+ {
+ $this->Set('db_ssl.cipher', $aParamValues['db_ssl_cipher']);
+ }
}
-
+
if (isset($aParamValues['selected_modules']))
{
$aSelectedModules = explode(',', $aParamValues['selected_modules']);
@@ -1852,24 +1890,29 @@ class Config
else
{
$aSelectedModules = null;
- }
+ }
$this->UpdateIncludes($sModulesDir, $aSelectedModules);
}
/**
- * Helper function to rebuild the default configuration and the list of includes from a directory and a list of selected modules
- * @param string $sModulesDir The relative path to the directory to scan for modules (typically the 'env-xxx' directory resulting from the compilation)
- * @param array $aSelectedModules An array of selected modules' identifiers. If null all modules found will be considered as installed
+ * Helper function to rebuild the default configuration and the list of includes from a directory and a list of
+ * selected modules
+ *
+ * @param string $sModulesDir The relative path to the directory to scan for modules (typically the 'env-xxx'
+ * directory resulting from the compilation)
+ * @param array $aSelectedModules An array of selected modules' identifiers. If null all modules found will be
+ * considered as installed
+ *
* @throws Exception
*/
public function UpdateIncludes($sModulesDir, $aSelectedModules = null)
{
if (!is_null($sModulesDir))
- {
+ {
// 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();
-
+
$aModules = ModuleDiscovery::GetAvailableModules(array(APPROOT.$sModulesDir));
foreach ($aModules as $sModuleId => $aModuleInfo)
{
@@ -1902,7 +1945,7 @@ class Config
{
throw new Exception("Wrong installer class: '$sModuleInstallerClass' is not derived from 'ModuleInstallerAPI' - Module: ".$aModuleInfo['label']);
}
- $aCallSpec = array($sModuleInstallerClass,'BeforeWritingConfig');
+ $aCallSpec = array($sModuleInstallerClass, 'BeforeWritingConfig');
call_user_func_array($aCallSpec, array($this));
}
}
@@ -1914,8 +1957,8 @@ class Config
/**
* Helper: for an array of string, change the prefix when found
*/
- protected static function ChangePrefix(&$aStrings, $sSearchPrefix, $sNewPrefix)
- {
+ protected static function ChangePrefix(&$aStrings, $sSearchPrefix, $sNewPrefix)
+ {
foreach ($aStrings as &$sFile)
{
if (substr($sFile, 0, strlen($sSearchPrefix)) == $sSearchPrefix)
@@ -1927,18 +1970,21 @@ class Config
/**
* Obsolete: kept only for backward compatibility of the Toolkit
- * Quick and dirty way to clone a config file into another environment
- */
+ * Quick and dirty way to clone a config file into another environment
+ */
public function ChangeModulesPath($sSourceEnv, $sTargetEnv)
{
// Now does nothing since the includes are built into the environment itself
}
-
+
/**
* Pretty format a var_export'ed value so that (if possible) the identation is preserved on every line
+ *
* @param mixed $value The value to export
* @param string $sIndentation The string to use to indent the text
- * @param bool $bForceIndentation Forces the identation (enven if it breaks/changes an eval, for example to ouput a value inside a comment)
+ * @param bool $bForceIndentation Forces the identation (enven if it breaks/changes an eval, for example to ouput a
+ * value inside a comment)
+ *
* @return string The indented export string
*/
protected static function PrettyVarExport($value, $sIndentation, $bForceIndentation = false)
@@ -1952,13 +1998,15 @@ class Config
eval('$aImported='.$sNiceExport.';');
// Check if adding the identations at the beginning of each line
// did not modify the values (in case of a string containing a line break)
- if($aImported != $value)
+ if ($aImported != $value)
{
$sNiceExport = $sExport;
}
}
- return $sNiceExport;
+
+ return $sNiceExport;
}
}
+
?>
diff --git a/core/metamodel.class.php b/core/metamodel.class.php
index 6fdc2f61f..b9d77e256 100644
--- a/core/metamodel.class.php
+++ b/core/metamodel.class.php
@@ -182,7 +182,7 @@ abstract class MetaModel
var_dump(get_class_vars(__CLASS__));
}
- /** @var Config */
+ /** @var Config m_oConfig */
private static $m_oConfig = null;
/** @var array */
protected static $m_aModulesParameters = array();
@@ -5801,17 +5801,8 @@ abstract class MetaModel
self::IncludeModule($sToInclude, 'addons');
}
- $sServer = self::$m_oConfig->GetDBHost();
- $sUser = self::$m_oConfig->GetDBUser();
- $sPwd = self::$m_oConfig->GetDBPwd();
- $sSource = self::$m_oConfig->GetDBName();
- $sSSLKey = self::$m_oConfig->GetDBSSLKey();
- $sSSLCert = self::$m_oConfig->GetDBSSLCert();
- $sSSLCA = self::$m_oConfig->GetDBSSLCA();
- $sSSLCipher = self::$m_oConfig->GetDBSSLCipher();
- $sTablePrefix = self::$m_oConfig->GetDBSubname();
- $sCharacterSet = self::$m_oConfig->GetDBCharacterSet();
- $sCollation = self::$m_oConfig->GetDBCollation();
+ $sSource = self::$m_oConfig->Get('db_name');
+ $sTablePrefix = self::$m_oConfig->Get('db_subname');
if (self::$m_bUseAPCCache)
{
@@ -5888,8 +5879,7 @@ abstract class MetaModel
self::$m_sDBName = $sSource;
self::$m_sTablePrefix = $sTablePrefix;
- CMDBSource::Init($sServer, $sUser, $sPwd, '', $sSSLKey, $sSSLCert, $sSSLCA, $sSSLCipher); // do not select the DB (could not exist)
- CMDBSource::SetCharacterSet($sCharacterSet, $sCollation);
+ CMDBSource::InitFromConfig(self::$m_oConfig);
// Later when timezone implementation is correctly done: CMDBSource::SetTimezone($sDBTimezone);
}
diff --git a/core/mutex.class.inc.php b/core/mutex.class.inc.php
index daf82fd02..a3e7e81e9 100644
--- a/core/mutex.class.inc.php
+++ b/core/mutex.class.inc.php
@@ -1,5 +1,5 @@
GetDBName();
- $sDBSubname = $oConfig->GetDBSubname();
- $this->sDBSSLKey = $oConfig->GetDBSSLKey();
- $this->sDBSSLCert = $oConfig->GetDBSSLCert();
- $this->sDBSSLCA = $oConfig->GetDBSSLCA();
- $this->sDBSSLCipher = $oConfig->GetDBSSLCipher();
+ $sDBHost = is_null($sDBHost) ? $oConfig->Get('db_host') : $sDBHost;
+ $sDBUser = is_null($sDBUser) ? $oConfig->Get('db_user') : $sDBUser;
+ $sDBPwd = is_null($sDBPwd) ? $oConfig->Get('db_pwd') : $sDBPwd;
+ $sDBName = $oConfig->Get('db_name');
+ $sDBSubname = $oConfig->Get('db_subname');
+ $this->sDBSSLKey = $oConfig->Get('db_ssl.key');
+ $this->sDBSSLCert = $oConfig->Get('db_ssl.cert');
+ $this->sDBSSLCA = $oConfig->Get('db_ssl.ca');
+ $this->sDBSSLCipher = $oConfig->Get('db_ssl.cipher');
$this->sName = 'itop.'.$sName;
$this->sName = $sName;
if (substr($sName, -strlen($sDBName.$sDBSubname)) != $sDBName.$sDBSubname)
@@ -75,9 +78,6 @@ class iTopMutex
// It is a MUST to create a dedicated session each time a lock is required, because
// using GET_LOCK anytime on the same session will RELEASE the current and unique session lock (known issue)
- $sDBHost = is_null($sDBHost) ? $oConfig->GetDBHost() : $sDBHost;
- $sDBUser = is_null($sDBUser) ? $oConfig->GetDBUser() : $sDBUser;
- $sDBPwd = is_null($sDBPwd) ? $oConfig->GetDBPwd() : $sDBPwd;
$this->InitMySQLSession($sDBHost, $sDBUser, $sDBPwd);
}
diff --git a/datamodels/2.x/itop-backup/check-backup.php b/datamodels/2.x/itop-backup/check-backup.php
index a8b0e3083..2af5a7375 100644
--- a/datamodels/2.x/itop-backup/check-backup.php
+++ b/datamodels/2.x/itop-backup/check-backup.php
@@ -86,10 +86,10 @@ function MakeArchiveFileName($iRefTime = null)
$sBackupFile = utils::ReadParam('backup_file', $sDefaultBackupFileName, true, 'raw_data');
$oConfig = new Config(APPCONF.'production/config-itop.php');
-
- $sBackupFile = str_replace('__HOST__', $oConfig->GetDBHost(), $sBackupFile);
- $sBackupFile = str_replace('__DB__', $oConfig->GetDBName(), $sBackupFile);
- $sBackupFile = str_replace('__SUBNAME__', $oConfig->GetDBSubName(), $sBackupFile);
+
+ $sBackupFile = str_replace('__HOST__', $oConfig->Get('db_host'), $sBackupFile);
+ $sBackupFile = str_replace('__DB__', $oConfig->Get('db_name'), $sBackupFile);
+ $sBackupFile = str_replace('__SUBNAME__', $oConfig->Get('db_subname'), $sBackupFile);
if (is_null($iRefTime))
{
diff --git a/datamodels/2.x/itop-backup/status.php b/datamodels/2.x/itop-backup/status.php
index 5666aa169..dae1687fc 100644
--- a/datamodels/2.x/itop-backup/status.php
+++ b/datamodels/2.x/itop-backup/status.php
@@ -1,5 +1,5 @@
GetModuleSetting('itop-backup', 'mysql_bindir', ''));
- $sDBHost = addslashes(MetaModel::GetConfig()->GetDBHost());
- $sDBUser = addslashes(MetaModel::GetConfig()->GetDBUser());
- $sDBPwd = addslashes(MetaModel::GetConfig()->GetDBPwd());
- $sDBName = addslashes(MetaModel::GetConfig()->GetDBName());
- $sDBSubName = addslashes(MetaModel::GetConfig()->GetDBSubName());
+ $sDBHost = addslashes(MetaModel::GetConfig()->Get('db_host'));
+ $sDBUser = addslashes(MetaModel::GetConfig()->Get('db_user'));
+ $sDBPwd = addslashes(MetaModel::GetConfig()->Get('db_pwd'));
+ $sDBName = addslashes(MetaModel::GetConfig()->Get('db_name'));
+ $sDBSubName = addslashes(MetaModel::GetConfig()->Get('db_subname'));
$sEnvironment = addslashes(utils::GetCurrentEnvironment());
diff --git a/datamodels/2.x/itop-hub-connector/launch.php b/datamodels/2.x/itop-hub-connector/launch.php
index afe9a2783..1265d21b0 100644
--- a/datamodels/2.x/itop-hub-connector/launch.php
+++ b/datamodels/2.x/itop-hub-connector/launch.php
@@ -189,9 +189,9 @@ function collect_configuration()
// iTop modules
$oConfig = MetaModel::GetConfig();
- $sLatestInstallationDate = CMDBSource::QueryToScalar("SELECT max(installed) FROM ".$oConfig->GetDBSubname()."priv_module_install");
+ $sLatestInstallationDate = CMDBSource::QueryToScalar("SELECT max(installed) FROM ".$oConfig->Get('db_subname')."priv_module_install");
// Get the latest installed modules, without the "root" ones (iTop version and datamodel version)
- $aInstalledModules = CMDBSource::QueryToArray("SELECT * FROM ".$oConfig->GetDBSubname()."priv_module_install WHERE installed = '".$sLatestInstallationDate."' AND parent_id != 0");
+ $aInstalledModules = CMDBSource::QueryToArray("SELECT * FROM ".$oConfig->Get('db_subname')."priv_module_install WHERE installed = '".$sLatestInstallationDate."' AND parent_id != 0");
foreach ($aInstalledModules as $aDBInfo)
{
diff --git a/setup/backup.class.inc.php b/setup/backup.class.inc.php
index f2f202ee9..a1adffe67 100644
--- a/setup/backup.class.inc.php
+++ b/setup/backup.class.inc.php
@@ -1,5 +1,5 @@
GetDBHost();
- $sDBUser = MetaModel::GetConfig()->GetDBUser();
- $sDBPwd = MetaModel::GetConfig()->GetDBPwd();
- $sDBName = MetaModel::GetConfig()->GetDBName();
- $sDBSubName = MetaModel::GetConfig()->GetDBSubName();
+ $sDBHost = MetaModel::GetConfig()->Get('db_host');
+ $sDBUser = MetaModel::GetConfig()->Get('db_user');
+ $sDBPwd = MetaModel::GetConfig()->Get('db_pwd');
+ $sDBName = MetaModel::GetConfig()->Get('db_name');
+ $sDBSubName = MetaModel::GetConfig()->Get('db_subname');
}
// Compute the port (if present in the host name)
diff --git a/setup/extensionsmap.class.inc.php b/setup/extensionsmap.class.inc.php
index 2736704f8..729e11aa5 100644
--- a/setup/extensionsmap.class.inc.php
+++ b/setup/extensionsmap.class.inc.php
@@ -547,11 +547,10 @@ class iTopExtensionsMap
{
if (CMDBSource::DBName() === null)
{
- CMDBSource::Init($oConfig->GetDBHost(), $oConfig->GetDBUser(), $oConfig->GetDBPwd(), $oConfig->GetDBName());
- CMDBSource::SetCharacterSet($oConfig->GetDBCharacterSet(), $oConfig->GetDBCollation());
+ CMDBSource::InitFromConfig($oConfig);
}
- $sLatestInstallationDate = CMDBSource::QueryToScalar("SELECT max(installed) FROM ".$oConfig->GetDBSubname()."priv_extension_install");
- $aInstalledExtensions = CMDBSource::QueryToArray("SELECT * FROM ".$oConfig->GetDBSubname()."priv_extension_install WHERE installed = '".$sLatestInstallationDate."'");
+ $sLatestInstallationDate = CMDBSource::QueryToScalar("SELECT max(installed) FROM ".$oConfig->Get('db_subname')."priv_extension_install");
+ $aInstalledExtensions = CMDBSource::QueryToArray("SELECT * FROM ".$oConfig->Get('db_subname')."priv_extension_install WHERE installed = '".$sLatestInstallationDate."'");
}
catch (MySQLException $e)
{
diff --git a/setup/runtimeenv.class.inc.php b/setup/runtimeenv.class.inc.php
index 015386c3b..89c660ee0 100644
--- a/setup/runtimeenv.class.inc.php
+++ b/setup/runtimeenv.class.inc.php
@@ -1,5 +1,5 @@
GetDBHost(), $oConfig->GetDBUser(), $oConfig->GetDBPwd(), $oConfig->GetDBName(), $oConfig->GetDBSSLKey(), $oConfig->GetDBSSLCert(), $oConfig->GetDBSSLCA(), $oConfig->GetDBSSLCipher());
- CMDBSource::SetCharacterSet($oConfig->GetDBCharacterSet(), $oConfig->GetDBCollation());
- $aSelectInstall = CMDBSource::QueryToArray("SELECT * FROM ".$oConfig->GetDBSubname()."priv_module_install");
+ CMDBSource::InitFromConfig($oConfig);
+ $aSelectInstall = CMDBSource::QueryToArray("SELECT * FROM ".$oConfig->Get('db_subname')."priv_module_install");
}
catch (MySQLException $e)
{
@@ -577,13 +576,13 @@ class RunTimeEnvironment
*/
public function CreateDatabaseStructure(Config $oConfig, $sMode)
{
- if (strlen($oConfig->GetDBSubname()) > 0)
+ if (strlen($oConfig->Get('db_subname')) > 0)
{
- $this->log_info("Creating the structure in '".$oConfig->GetDBName()."' (table names prefixed by '".$oConfig->GetDBSubname()."').");
+ $this->log_info("Creating the structure in '".$oConfig->Get('db_name')."' (table names prefixed by '".$oConfig->Get('db_subname')."').");
}
else
{
- $this->log_info("Creating the structure in '".$oConfig->GetDBSubname()."'.");
+ $this->log_info("Creating the structure in '".$oConfig->Get('db_subname')."'.");
}
//MetaModel::CheckDefinitions();
@@ -596,13 +595,13 @@ class RunTimeEnvironment
}
else
{
- if (strlen($oConfig->GetDBSubname()) > 0)
+ if (strlen($oConfig->Get('db_subname')) > 0)
{
- throw new Exception("Error: found iTop tables into the database '".$oConfig->GetDBName()."' (prefix: '".$oConfig->GetDBSubname()."'). Please, try selecting another database instance or specify another prefix to prevent conflicting table names.");
+ throw new Exception("Error: found iTop tables into the database '".$oConfig->Get('db_name')."' (prefix: '".$oConfig->Get('db_subname')."'). Please, try selecting another database instance or specify another prefix to prevent conflicting table names.");
}
else
{
- throw new Exception("Error: found iTop tables into the database '".$oConfig->GetDBName()."'. Please, try selecting another database instance or specify a prefix to prevent conflicting table names.");
+ throw new Exception("Error: found iTop tables into the database '".$oConfig->Get('db_name')."'. Please, try selecting another database instance or specify a prefix to prevent conflicting table names.");
}
}
}
@@ -641,13 +640,13 @@ class RunTimeEnvironment
}
else
{
- if (strlen($oConfig->GetDBSubname()) > 0)
+ if (strlen($oConfig->Get('db_subname')) > 0)
{
- throw new Exception("Error: No previous instance of iTop found into the database '".$oConfig->GetDBName()."' (prefix: '".$oConfig->GetDBSubname()."'). Please, try selecting another database instance.");
+ throw new Exception("Error: No previous instance of iTop found into the database '".$oConfig->Get('db_name')."' (prefix: '".$oConfig->Get('db_subname')."'). Please, try selecting another database instance.");
}
else
{
- throw new Exception("Error: No previous instance of iTop found into the database '".$oConfig->GetDBName()."'. Please, try selecting another database instance.");
+ throw new Exception("Error: No previous instance of iTop found into the database '".$oConfig->Get('db_name')."'. Please, try selecting another database instance.");
}
}
}
@@ -724,8 +723,7 @@ class RunTimeEnvironment
if (CMDBSource::DBName() == '')
{
// In case this has not yet been done
- CMDBSource::Init($oConfig->GetDBHost(), $oConfig->GetDBUser(), $oConfig->GetDBPwd(), $oConfig->GetDBName());
- CMDBSource::SetCharacterSet($oConfig->GetDBCharacterSet(), $oConfig->GetDBCollation());
+ CMDBSource::InitFromConfig($oConfig);
}
if ($sShortComment === null)
@@ -836,15 +834,14 @@ class RunTimeEnvironment
try
{
require_once(APPROOT.'/core/cmdbsource.class.inc.php');
- CMDBSource::Init($oConfig->GetDBHost(), $oConfig->GetDBUser(), $oConfig->GetDBPwd(), $oConfig->GetDBName(), $oConfig->GetDBSSLKey(), $oConfig->GetDBSSLCert(), $oConfig->GetDBSSLCA(), $oConfig->GetDBSSLCipher());
- CMDBSource::SetCharacterSet($oConfig->GetDBCharacterSet(), $oConfig->GetDBCollation());
- $sSQLQuery = "SELECT * FROM ".$oConfig->GetDBSubname()."priv_module_install";
+ CMDBSource::InitFromConfig($oConfig);
+ $sSQLQuery = "SELECT * FROM ".$oConfig->Get('db_subname')."priv_module_install";
$aSelectInstall = CMDBSource::QueryToArray($sSQLQuery);
}
catch (MySQLException $e)
{
// No database or erroneous information
- $this->log_error('Can not connect to the database: host: '.$oConfig->GetDBHost().', user:'.$oConfig->GetDBUser().', pwd:'.$oConfig->GetDBPwd().', db name:'.$oConfig->GetDBName());
+ $this->log_error('Can not connect to the database: host: '.$oConfig->Get('db_host').', user:'.$oConfig->Get('db_user').', pwd:'.$oConfig->Get('db_pwd').', db name:'.$oConfig->Get('db_name'));
$this->log_error('Exception '.$e->getMessage());
return false;
}
diff --git a/setup/setuputils.class.inc.php b/setup/setuputils.class.inc.php
index ba19be9e8..cdfd32009 100644
--- a/setup/setuputils.class.inc.php
+++ b/setup/setuputils.class.inc.php
@@ -1,5 +1,5 @@
$sSourceDir,
'source_environment' => $sSourceEnvironment,
'configuration_file' => $sConfigFile,
- 'db_server' => $oPrevConf->GetDBHost(),
- 'db_user' => $oPrevConf->GetDBUser(),
- 'db_pwd' => $oPrevConf->GetDBPwd(),
- 'db_name' => $oPrevConf->GetDBName(),
- 'db_prefix' => $oPrevConf->GetDBSubname(),
+ 'db_server' => $oPrevConf->Get('db_host'),
+ 'db_user' => $oPrevConf->Get('db_user'),
+ 'db_pwd' => $oPrevConf->Get('db_pwd'),
+ 'db_name' => $oPrevConf->Get('db_name'),
+ 'db_prefix' => $oPrevConf->Get('db_subname'),
'graphviz_path' => $oPrevConf->Get('graphviz_path'),
);
}
diff --git a/synchro/synchrodatasource.class.inc.php b/synchro/synchrodatasource.class.inc.php
index fb1b02a1f..a427c34a7 100644
--- a/synchro/synchrodatasource.class.inc.php
+++ b/synchro/synchrodatasource.class.inc.php
@@ -753,7 +753,7 @@ EOF
{
$sDBTableName = preg_replace('/[^A-za-z0-9_]/', '_', $sDBTableName); // Remove forbidden characters from the table name
}
- $sPrefix = MetaModel::GetConfig()->GetDBSubName()."synchro_data_";
+ $sPrefix = MetaModel::GetConfig()->Get('db_subname')."synchro_data_";
if (strpos($sDBTableName, $sPrefix) !== 0)
{
$sDBTableName = $sPrefix.$sDBTableName;
@@ -972,7 +972,7 @@ EOF
}
}
- $sDBName = MetaModel::GetConfig()->GetDBName();
+ $sDBName = MetaModel::GetConfig()->Get('db_name');
try
{
// Note: as per the MySQL documentation, using information_schema behaves exactly like SHOW TRIGGERS (user privileges)