thomascube
2011-08-25 da71783bc95f786968955a865943f6052eca83a4
Move timezone computation to rcube_config; don't override SESSION['timezone'] when saving prefs

3 files modified
36 ■■■■ changed files
program/include/main.inc 21 ●●●● patch | view | raw | blame | history
program/include/rcube_config.php 13 ●●●●● patch | view | raw | blame | history
program/steps/settings/save_prefs.inc 2 ●●● patch | view | raw | blame | history
program/include/main.inc
@@ -1021,7 +1021,7 @@
 */
function format_date($date, $format=NULL)
{
  global $CONFIG;
  global $RCMAIL, $CONFIG;
  
  $ts = NULL;
@@ -1032,13 +1032,7 @@
    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 @@
// 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);
program/include/rcube_config.php
@@ -220,6 +220,19 @@
        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.
program/steps/settings/save_prefs.inc
@@ -141,7 +141,7 @@
    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':