diff --git a/application/utils.inc.php b/application/utils.inc.php index 45656f2cc..c096b59f6 100644 --- a/application/utils.inc.php +++ b/application/utils.inc.php @@ -658,27 +658,49 @@ class utils return str_replace($aSearch, $aReplacement, $sOldDateTimeFormat); } + /** + * @return \Config from the current environement, or if not existing from the production env, else new Config made from scratch + * @uses \MetaModel::GetConfig() don't forget to add the needed require_once(APPROOT.'core/metamodel.class.php'); + */ static public function GetConfig() { if (self::$oConfig == null) { self::$oConfig = MetaModel::GetConfig(); + if (self::$oConfig == null) { $sConfigFile = self::GetConfigFilePath(); - if (file_exists($sConfigFile)) + if (!file_exists($sConfigFile)) { - self::$oConfig = new Config($sConfigFile); - } - else - { - // When executing the setup, the config file may be still missing - self::$oConfig = new Config(); + $sConfigFile = self::GetConfigFilePath('production'); + if (!file_exists($sConfigFile)) + { + $sConfigFile = null; + } } + + self::$oConfig = new Config($sConfigFile); } } return self::$oConfig; } + + public static function InitTimeZone() { + $oConfig = self::GetConfig(); + $sItopTimeZone = $oConfig->Get('timezone'); + + if (!empty($sItopTimeZone)) + { + date_default_timezone_set($sItopTimeZone); + } + else + { + // Leave as is... up to the admin to set a value somewhere... + // see http://php.net/manual/en/datetime.configuration.php#ini.date.timezone + } + } + /** * Returns the absolute URL to the application root path * @return string The absolute URL to the application root, without the first slash diff --git a/pages/exec.php b/pages/exec.php index 6513eb25a..0ece3c4a6 100644 --- a/pages/exec.php +++ b/pages/exec.php @@ -36,6 +36,9 @@ require_once('../approot.inc.php'); // Needed to read the parameters (with sanitization) require_once(APPROOT.'application/utils.inc.php'); +require_once(APPROOT.'core/metamodel.class.php'); + +utils::InitTimeZone(); $sModule = utils::ReadParam('exec_module', ''); if ($sModule == '')