diff options
author | Aleksander Machniak <alec@alec.pl> | 2013-09-04 15:46:49 +0200 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2013-09-04 15:46:49 +0200 |
commit | 7ebe063a16e172367fe08ac192bf32f3d9454a9c (patch) | |
tree | 2cf32cff0243a76ab3fc9a79d6464b029ce5da88 /program/lib/Roundcube | |
parent | b6be23ac4bb9ebe8fd90f347e3f209c2e0e5f24e (diff) |
Aviod code duplication in timezone configuration handling
Diffstat (limited to 'program/lib/Roundcube')
-rw-r--r-- | program/lib/Roundcube/rcube_config.php | 50 |
1 files changed, 19 insertions, 31 deletions
diff --git a/program/lib/Roundcube/rcube_config.php b/program/lib/Roundcube/rcube_config.php index 90e1394cf..5f7823a5d 100644 --- a/program/lib/Roundcube/rcube_config.php +++ b/program/lib/Roundcube/rcube_config.php @@ -138,17 +138,6 @@ class rcube_config // enable display_errors in 'show' level, but not for ajax requests ini_set('display_errors', intval(empty($_REQUEST['_remote']) && ($this->prop['debug_level'] & 4))); - // set timezone auto settings values - if ($this->prop['timezone'] == 'auto') { - $this->prop['_timezone_value'] = $this->client_timezone(); - } - else if (is_numeric($this->prop['timezone']) && ($tz = timezone_name_from_abbr("", $this->prop['timezone'] * 3600, 0))) { - $this->prop['timezone'] = $tz; - } - else if (empty($this->prop['timezone'])) { - $this->prop['timezone'] = 'UTC'; - } - // remove deprecated properties unset($this->prop['dst_active']); @@ -246,8 +235,10 @@ class rcube_config $rcube = rcube::get_instance(); - if ($name == 'timezone' && isset($this->prop['_timezone_value'])) { - $result = $this->prop['_timezone_value']; + if ($name == 'timezone') { + if (empty($result) || $result == 'auto') { + $result = $this->client_timezone(); + } } else if ($name == 'client_mimetypes') { if ($result == null && $def == null) @@ -305,11 +296,6 @@ class rcube_config } } - // convert user's timezone into the new format - if (is_numeric($prefs['timezone']) && ($tz = timezone_name_from_abbr('', $prefs['timezone'] * 3600, 0))) { - $prefs['timezone'] = $tz; - } - // larry is the new default skin :-) if ($prefs['skin'] == 'default') { $prefs['skin'] = self::DEFAULT_SKIN; @@ -317,13 +303,6 @@ class rcube_config $this->userprefs = $prefs; $this->prop = array_merge($this->prop, $prefs); - - // override timezone settings with client values - if ($this->prop['timezone'] == 'auto') { - $this->prop['_timezone_value'] = isset($_SESSION['timezone']) ? $this->client_timezone() : $this->prop['_timezone_value']; - } - else if (isset($this->prop['_timezone_value'])) - unset($this->prop['_timezone_value']); } @@ -464,13 +443,12 @@ class rcube_config */ private function client_timezone() { - if (isset($_SESSION['timezone']) && is_numeric($_SESSION['timezone']) - && ($ctz = timezone_name_from_abbr("", $_SESSION['timezone'] * 3600, 0))) { - return $ctz; - } - else if (!empty($_SESSION['timezone'])) { + // @TODO: remove this legacy timezone handling in the future + $props = $this->fix_legacy_props(array('timezone' => $_SESSION['timezone'])); + + if (!empty($props['timezone'])) { try { - $tz = timezone_open($_SESSION['timezone']); + $tz = new DateTimeZone($props['timezone']); return $tz->getName(); } catch (Exception $e) { /* gracefully ignore */ } @@ -498,6 +476,16 @@ class rcube_config } } + // convert deprecated numeric timezone value + if (isset($props['timezone']) && is_numeric($props['timezone'])) { + if ($tz = timezone_name_from_abbr("", $props['timezone'] * 3600, 0)) { + $props['timezone'] = $tz; + } + else { + unset($props['timezone']); + } + } + return $props; } } |