Branch 'roundcubemail-plugins-kolab-0.7' - plugins/calendar

Aleksander Machniak machniak at kolabsys.com
Wed Oct 10 11:18:36 CEST 2012


 plugins/calendar/calendar.php |   25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

New commits:
commit 15c2a813f4a0af111d5cf2a9c52d0feda2768363
Author: Aleksander Machniak (Kolab Systems) <machniak at kolabsys.com>
Date:   Wed Oct 10 11:15:42 2012 +0200

    Fix PHP Fatal error:  Uncaught exception 'Exception' with message
    'DateTimeZone::__construct(): Unknown or bad timezone (Bug #970)

diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php
index ccf6461..8160cb7 100644
--- a/plugins/calendar/calendar.php
+++ b/plugins/calendar/calendar.php
@@ -102,10 +102,27 @@ class calendar extends rcube_plugin
     $this->add_texts('localization/', $this->rc->task == 'calendar' && (!$this->rc->action || $this->rc->action == 'print'));
 
     // set user's timezone
-    $this->timezone = $this->rc->config->get('timezone');
-    $this->dst_active = $this->rc->config->get('dst_active');
-    $this->gmt_offset = ($this->timezone + $this->dst_active) * 3600;
-    $this->user_timezone = new DateTimeZone($this->timezone ? timezone_name_from_abbr("", $this->gmt_offset, $this->dst_active) : 'GMT');
+    // In 0.7 timezone setting is (most likely) a numeric value
+    $timezone = $this->rc->config->get('timezone', 'UTC');
+    if (is_numeric($timezone) && ($tz = timezone_name_from_abbr("", $timezone * 3600, 0))) {
+        $timezone = $tz;
+    }
+    else if (empty($timezone)) {
+        $timezone = 'UTC';
+    }
+
+    try {
+        $this->timezone = $timezone;
+        $this->user_timezone = new DateTimeZone($this->timezone);
+    }
+    catch (Exception $e) {
+        $this->timezone = 'UTC';
+        $this->user_timezone = new DateTimeZone($this->timezone);
+    }
+
+    $now = new DateTime('now', $this->timezone);
+    $this->gmt_offset = $now->getOffset();
+    $this->dst_active = $now->format('I');
 
     require($this->home . '/lib/calendar_ui.php');
     $this->ui = new calendar_ui($this);





More information about the commits mailing list