summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak (Kolab Systems) <machniak@kolabsys.com>2012-10-10 09:15:42 (GMT)
committerAleksander Machniak (Kolab Systems) <machniak@kolabsys.com>2012-10-10 09:15:42 (GMT)
commit15c2a813f4a0af111d5cf2a9c52d0feda2768363 (patch)
tree72062a2ee6f2cf2a7d7772a79f42a2275fbbba60
parent7b808563a85b4a7014a1355dd889497c3a0cfeac (diff)
downloadroundcubemail-plugins-kolab-15c2a813f4a0af111d5cf2a9c52d0feda2768363.tar.gz
Fix PHP Fatal error: Uncaught exception 'Exception' with message
'DateTimeZone::__construct(): Unknown or bad timezone (Bug #970)
-rw-r--r--plugins/calendar/calendar.php25
1 files changed, 21 insertions, 4 deletions
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);