plugins/libkolab

Thomas Brüderli bruederli at kolabsys.com
Mon Mar 16 14:43:14 CET 2015


 plugins/libkolab/lib/kolab_format_task.php |   14 ++++++++++++++
 plugins/libkolab/lib/kolab_format_xcal.php |   19 ++++++++++++++++++-
 2 files changed, 32 insertions(+), 1 deletion(-)

New commits:
commit c51c60eff835bd396c4adbde4ace0527cbebf385
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date:   Mon Mar 16 14:41:50 2015 +0100

    Avoid fatal errors when setting recurrence until date for tasks (#4852)

diff --git a/plugins/libkolab/lib/kolab_format_task.php b/plugins/libkolab/lib/kolab_format_task.php
index 4640875..cb35f98 100644
--- a/plugins/libkolab/lib/kolab_format_task.php
+++ b/plugins/libkolab/lib/kolab_format_task.php
@@ -117,6 +117,20 @@ class kolab_format_task extends kolab_format_xcal
     }
 
     /**
+     * Return the reference date for recurrence and alarms
+     *
+     * @return mixed DateTime instance of null if no refdate is available
+     */
+    public function get_reference_date()
+    {
+        if ($this->data['due'] && $this->data['due'] instanceof DateTime) {
+            return $this->data['due'];
+        }
+
+        return self::php_datetime($this->obj->due()) ?: parent::get_reference_date();
+    }
+
+    /**
      * Callback for kolab_storage_cache to get object specific tags to cache
      *
      * @return array List of tags to save in cache
diff --git a/plugins/libkolab/lib/kolab_format_xcal.php b/plugins/libkolab/lib/kolab_format_xcal.php
index 8c63b26..e7d1122 100644
--- a/plugins/libkolab/lib/kolab_format_xcal.php
+++ b/plugins/libkolab/lib/kolab_format_xcal.php
@@ -184,7 +184,10 @@ abstract class kolab_format_xcal extends kolab_format
                 $object['recurrence']['COUNT'] = $count;
             }
             else if ($until = self::php_datetime($rr->end())) {
-                $until->setTime($object['start']->format('G'), $object['start']->format('i'), 0);
+                $refdate = $this->get_reference_date();
+                if ($refdate && $refdate instanceof DateTime && !$refdate->_dateonly) {
+                    $until->setTime($refdate->format('G'), $refdate->format('i'), 0);
+                }
                 $object['recurrence']['UNTIL'] = $until;
             }
 
@@ -568,6 +571,20 @@ abstract class kolab_format_xcal extends kolab_format
     }
 
     /**
+     * Return the reference date for recurrence and alarms
+     *
+     * @return mixed DateTime instance of null if no refdate is available
+     */
+    public function get_reference_date()
+    {
+        if ($this->data['start'] && $this->data['start'] instanceof DateTime) {
+            return $this->data['start'];
+        }
+
+        return self::php_datetime($this->obj->start());
+    }
+
+    /**
      * Callback for kolab_storage_cache to get words to index for fulltext search
      *
      * @return array List of words to save in cache




More information about the commits mailing list