summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2011-08-25 20:09:36 +0000
committerthomascube <thomas@roundcube.net>2011-08-25 20:09:36 +0000
commitda71783bc95f786968955a865943f6052eca83a4 (patch)
tree08d8837e970fae554fc59ac000150c37cf5350fa
parent1a716d2d343b6614bec80d98cc46f327c296279e (diff)
Move timezone computation to rcube_config; don't override SESSION['timezone'] when saving prefs
-rw-r--r--program/include/main.inc21
-rw-r--r--program/include/rcube_config.php13
-rw-r--r--program/steps/settings/save_prefs.inc2
3 files changed, 18 insertions, 18 deletions
diff --git a/program/include/main.inc b/program/include/main.inc
index 0401fe2c1..edd74f860 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -1021,7 +1021,7 @@ function rcube_strtotime($date)
*/
function format_date($date, $format=NULL)
{
- global $CONFIG;
+ global $RCMAIL, $CONFIG;
$ts = NULL;
@@ -1032,13 +1032,7 @@ function format_date($date, $format=NULL)
return '';
// get user's timezone
- if ($CONFIG['timezone'] === 'auto')
- $tz = isset($_SESSION['timezone']) ? $_SESSION['timezone'] : date('Z')/3600;
- else {
- $tz = $CONFIG['timezone'];
- if ($CONFIG['dst_active'])
- $tz++;
- }
+ $tz = $RCMAIL->config->get_timezone();
// convert time to user's timezone
$timestamp = $ts - date('Z', $ts) + ($tz * 3600);
@@ -1823,17 +1817,10 @@ function rcmail_gen_message_id()
// Returns RFC2822 formatted current date in user's timezone
function rcmail_user_date()
{
- global $CONFIG;
+ global $RCMAIL, $CONFIG;
// get user's timezone
- if ($CONFIG['timezone'] === 'auto') {
- $tz = isset($_SESSION['timezone']) ? $_SESSION['timezone'] : date('Z')/3600;
- }
- else {
- $tz = $CONFIG['timezone'];
- if ($CONFIG['dst_active'])
- $tz++;
- }
+ $tz = $RCMAIL->config->get_timezone();
$date = time() + $tz * 60 * 60;
$date = gmdate('r', $date);
diff --git a/program/include/rcube_config.php b/program/include/rcube_config.php
index 9379e9e7b..31b7ed6b7 100644
--- a/program/include/rcube_config.php
+++ b/program/include/rcube_config.php
@@ -220,6 +220,19 @@ class rcube_config
return $this->prop;
}
+ /**
+ * Special getter for user's timezone
+ */
+ public function get_timezone()
+ {
+ $tz = $this->get('timezone');
+ if ($tz == 'auto')
+ $tz = isset($_SESSION['timezone']) ? $_SESSION['timezone'] : date('Z') / 3600;
+ else
+ $tz = intval($tz) + intval($this->get('dst_active'));
+
+ return $tz;
+ }
/**
* Return requested DES crypto key.
diff --git a/program/steps/settings/save_prefs.inc b/program/steps/settings/save_prefs.inc
index ac1cfb3d0..208874f5d 100644
--- a/program/steps/settings/save_prefs.inc
+++ b/program/steps/settings/save_prefs.inc
@@ -141,7 +141,7 @@ switch ($CURR_SECTION)
if (isset($CONFIG['max_pagesize']) && ($a_user_prefs['pagesize'] > $CONFIG['max_pagesize']))
$a_user_prefs['pagesize'] = (int) $CONFIG['max_pagesize'];
- $a_user_prefs['timezone'] = $_SESSION['timezone'] = (string) $a_user_prefs['timezone'];
+ $a_user_prefs['timezone'] = (string) $a_user_prefs['timezone'];
break;
case 'mailbox':