2 commits - plugins/calendar plugins/libkolab

Thomas Brüderli bruederli at kolabsys.com
Wed Jan 22 11:23:26 CET 2014


 plugins/calendar/config.inc.php.dist               |    3 +--
 plugins/libkolab/lib/kolab_date_recurrence.php     |   12 ++++++------
 plugins/libkolab/lib/kolab_storage_cache.php       |    2 ++
 plugins/libkolab/lib/kolab_storage_cache_event.php |    8 ++++----
 plugins/libkolab/lib/kolab_storage_cache_task.php  |    4 ++--
 plugins/libkolab/lib/kolab_storage_folder.php      |    2 +-
 6 files changed, 16 insertions(+), 15 deletions(-)

New commits:
commit 965a9b74b36d5282159780abb97fe6a7c2a2adb3
Author: Thomas Bruederli <thomas at roundcube.net>
Date:   Wed Jan 22 11:22:23 2014 +0100

    Fix anually recurrence end date on 32bit systems by replacing (overflowing) unix timestamps with DateTime objects (#2613)

diff --git a/plugins/libkolab/lib/kolab_date_recurrence.php b/plugins/libkolab/lib/kolab_date_recurrence.php
index 1dc63be..06dd331 100644
--- a/plugins/libkolab/lib/kolab_date_recurrence.php
+++ b/plugins/libkolab/lib/kolab_date_recurrence.php
@@ -101,7 +101,7 @@ class kolab_date_recurrence
     /**
      * Get the end date of the occurence of this recurrence cycle
      *
-     * @return mixed Timestamp with end date of the last event or False if recurrence exceeds limit
+     * @return DateTime|bool End datetime of the last event or False if recurrence exceeds limit
      */
     public function end()
     {
@@ -109,25 +109,25 @@ class kolab_date_recurrence
 
         // recurrence end date is given
         if ($event['recurrence']['UNTIL'] instanceof DateTime) {
-            return $event['recurrence']['UNTIL']->format('U');
+            return $event['recurrence']['UNTIL'];
         }
 
         // let libkolab do the work
         if ($this->engine && ($cend = $this->engine->getLastOccurrence()) && ($end_dt = kolab_format::php_datetime(new cDateTime($cend)))) {
-            return $end_dt->format('U');
+            return $end_dt;
         }
 
         // determine a reasonable end date if none given
-        if (!$event['recurrence']['COUNT'] && $event['start'] instanceof DateTime) {
+        if (!$event['recurrence']['COUNT'] && $event['end'] instanceof DateTime) {
           switch ($event['recurrence']['FREQ']) {
             case 'YEARLY':  $intvl = 'P100Y'; break;
             case 'MONTHLY': $intvl = 'P20Y';  break;
             default:        $intvl = 'P10Y';  break;
           }
 
-          $end_dt = clone $event['start'];
+          $end_dt = clone $event['end'];
           $end_dt->add(new DateInterval($intvl));
-          return $end_dt->format('U');
+          return $end_dt;
         }
 
         return false;
diff --git a/plugins/libkolab/lib/kolab_storage_cache.php b/plugins/libkolab/lib/kolab_storage_cache.php
index 186f261..efd61ef 100644
--- a/plugins/libkolab/lib/kolab_storage_cache.php
+++ b/plugins/libkolab/lib/kolab_storage_cache.php
@@ -24,6 +24,8 @@
 
 class kolab_storage_cache
 {
+    const DB_DATE_FORMAT = 'Y-m-d H:i:s';
+
     protected $db;
     protected $imap;
     protected $folder;
diff --git a/plugins/libkolab/lib/kolab_storage_cache_event.php b/plugins/libkolab/lib/kolab_storage_cache_event.php
index 876c3b4..5fc44cd 100644
--- a/plugins/libkolab/lib/kolab_storage_cache_event.php
+++ b/plugins/libkolab/lib/kolab_storage_cache_event.php
@@ -34,14 +34,14 @@ class kolab_storage_cache_event extends kolab_storage_cache
     {
         $sql_data = parent::_serialize($object);
 
-        // database runs in server's timezone so using date() is what we want
-        $sql_data['dtstart'] = date('Y-m-d H:i:s', is_object($object['start']) ? $object['start']->format('U') : $object['start']);
-        $sql_data['dtend']   = date('Y-m-d H:i:s', is_object($object['end'])   ? $object['end']->format('U')   : $object['end']);
+        $sql_data['dtstart'] = is_object($object['start']) ? $object['start']->format(self::DB_DATE_FORMAT) : date(self::DB_DATE_FORMAT, $object['start']);
+        $sql_data['dtend']   = is_object($object['end'])   ? $object['end']->format(self::DB_DATE_FORMAT)   : date(self::DB_DATE_FORMAT, $object['end']);
 
         // extend date range for recurring events
         if ($object['recurrence'] && $object['_formatobj']) {
             $recurrence = new kolab_date_recurrence($object['_formatobj']);
-            $sql_data['dtend'] = date('Y-m-d 23:59:59', $recurrence->end() ?: strtotime('now +10 years'));
+            $dtend = $recurrence->end() ?: new DateTime('now +10 years');
+            $sql_data['dtend'] = $dtend->format(self::DB_DATE_FORMAT);
         }
 
         return $sql_data;
diff --git a/plugins/libkolab/lib/kolab_storage_cache_task.php b/plugins/libkolab/lib/kolab_storage_cache_task.php
index a1953f6..7bf5c79 100644
--- a/plugins/libkolab/lib/kolab_storage_cache_task.php
+++ b/plugins/libkolab/lib/kolab_storage_cache_task.php
@@ -35,9 +35,9 @@ class kolab_storage_cache_task extends kolab_storage_cache
         $sql_data = parent::_serialize($object) + array('dtstart' => null, 'dtend' => null);
 
         if ($object['start'])
-            $sql_data['dtstart'] = date('Y-m-d H:i:s', is_object($object['start']) ? $object['start']->format('U') : $object['start']);
+            $sql_data['dtstart'] = is_object($object['start']) ? $object['start']->format(self::DB_DATE_FORMAT) : date(self::DB_DATE_FORMAT, $object['start']);
         if ($object['due'])
-            $sql_data['dtend']   = date('Y-m-d H:i:s', is_object($object['due'])   ? $object['due']->format('U')   : $object['due']);
+            $sql_data['dtend']   = is_object($object['due'])   ? $object['due']->format(self::DB_DATE_FORMAT)   : date(self::DB_DATE_FORMAT, $object['due']);
 
         return $sql_data;
     }
diff --git a/plugins/libkolab/lib/kolab_storage_folder.php b/plugins/libkolab/lib/kolab_storage_folder.php
index 766df8c..f0aac7b 100644
--- a/plugins/libkolab/lib/kolab_storage_folder.php
+++ b/plugins/libkolab/lib/kolab_storage_folder.php
@@ -809,7 +809,7 @@ class kolab_storage_folder
                         $recurrence = new kolab_date_recurrence($object['_formatobj']);
                         if ($end = $recurrence->end()) {
                             unset($exception['recurrence']['COUNT']);
-                            $exception['recurrence']['UNTIL'] = new DateTime('@'.$end);
+                            $exception['recurrence']['UNTIL'] = $end;
                         }
                     }
 


commit 8a820d1994339cd7fd4a1714ec8c518935dc46e1
Author: Thomas Bruederli <thomas at roundcube.net>
Date:   Wed Jan 22 11:19:53 2014 +0100

    Remove outdated version information

diff --git a/plugins/calendar/config.inc.php.dist b/plugins/calendar/config.inc.php.dist
index 4ec3c08..34b1009 100644
--- a/plugins/calendar/config.inc.php.dist
+++ b/plugins/calendar/config.inc.php.dist
@@ -2,10 +2,9 @@
 /*
  +-------------------------------------------------------------------------+
  | Configuration for the Calendar plugin                                   |
- | Version 0.7-beta                                                        |
  |                                                                         |
  | Copyright (C) 2010, Lazlo Westerhof - Netherlands                       |
- | Copyright (C) 2011, Kolab Systems AG                                    |
+ | Copyright (C) 2011-2014, Kolab Systems AG                               |
  |                                                                         |
  | This program is free software: you can redistribute it and/or modify    |
  | it under the terms of the GNU Affero General Public License as          |




More information about the commits mailing list