diff options
author | Thomas Bruederli <thomas@roundcube.net> | 2012-10-31 11:50:33 +0100 |
---|---|---|
committer | Thomas Bruederli <thomas@roundcube.net> | 2012-10-31 11:50:33 +0100 |
commit | 086b153ae274e528e709d179795d0bafd5f382bd (patch) | |
tree | 932252c46cafcea76da0fc50bcf423626ec2a78c /program/include | |
parent | dc6794f9c40be9a4aed6927faad85b95d7642369 (diff) |
Improve client-side timezone detection using jsTimezoneDetect by Jon Nylander (#1488725); removed obsolete dstactive detection
Diffstat (limited to 'program/include')
-rw-r--r-- | program/include/rcmail.php | 4 | ||||
-rw-r--r-- | program/include/rcube_config.php | 15 | ||||
-rw-r--r-- | program/include/rcube_output_html.php | 5 |
3 files changed, 18 insertions, 6 deletions
diff --git a/program/include/rcmail.php b/program/include/rcmail.php index c2f76b388..3728e5d19 100644 --- a/program/include/rcmail.php +++ b/program/include/rcmail.php @@ -542,9 +542,7 @@ class rcmail extends rcube $_SESSION['login_time'] = time(); if (isset($_REQUEST['_timezone']) && $_REQUEST['_timezone'] != '_default_') - $_SESSION['timezone'] = floatval($_REQUEST['_timezone']); - if (isset($_REQUEST['_dstactive']) && $_REQUEST['_dstactive'] != '_default_') - $_SESSION['dst_active'] = intval($_REQUEST['_dstactive']); + $_SESSION['timezone'] = rcube_utils::get_input_value('_timezone', rcube_utils::INPUT_GPC); // force reloading complete list of subscribed mailboxes $storage->clear_cache('mailboxes', true); diff --git a/program/include/rcube_config.php b/program/include/rcube_config.php index b9fd95578..1f165ba4a 100644 --- a/program/include/rcube_config.php +++ b/program/include/rcube_config.php @@ -412,7 +412,20 @@ class rcube_config */ private function client_timezone() { - return isset($_SESSION['timezone']) && ($ctz = timezone_name_from_abbr("", $_SESSION['timezone'] * 3600, 0)) ? $ctz : date_default_timezone_get(); + if (isset($_SESSION['timezone']) && is_numeric($_SESSION['timezone']) + && ($ctz = timezone_name_from_abbr("", $_SESSION['timezone'] * 3600, 0))) { + return $ctz; + } + else if (!empty($_SESSION['timezone'])) { + try { + $tz = timezone_open($_SESSION['timezone']); + return $tz->getName(); + } + catch (Exception $e) { /* gracefully ignore */ } + } + + // fallback to server's timezone + return date_default_timezone_get(); } } diff --git a/program/include/rcube_output_html.php b/program/include/rcube_output_html.php index d42171869..71aec7775 100644 --- a/program/include/rcube_output_html.php +++ b/program/include/rcube_output_html.php @@ -1493,7 +1493,6 @@ class rcube_output_html extends rcube_output $input_task = new html_hiddenfield(array('name' => '_task', 'value' => 'login')); $input_action = new html_hiddenfield(array('name' => '_action', 'value' => 'login')); $input_tzone = new html_hiddenfield(array('name' => '_timezone', 'id' => 'rcmlogintz', 'value' => '_default_')); - $input_dst = new html_hiddenfield(array('name' => '_dstactive', 'id' => 'rcmlogindst', 'value' => '_default_')); $input_url = new html_hiddenfield(array('name' => '_url', 'id' => 'rcmloginurl', 'value' => $url)); $input_user = new html_inputfield(array('name' => '_user', 'id' => 'rcmloginuser') + $attrib + $user_attrib); @@ -1545,7 +1544,6 @@ class rcube_output_html extends rcube_output $out = $input_task->show(); $out .= $input_action->show(); $out .= $input_tzone->show(); - $out .= $input_dst->show(); $out .= $input_url->show(); $out .= $table->show(); @@ -1558,6 +1556,9 @@ class rcube_output_html extends rcube_output $out = $this->form_tag(array('name' => $form_name, 'method' => 'post'), $out); } + // include script for timezone detection + $this->include_script('jstz.min.js'); + return $out; } |