Branch 'dev/recurring-invitations' - 4 commits - plugins/calendar plugins/libcalendaring

Thomas Brüderli bruederli at kolabsys.com
Tue Feb 17 15:49:27 CET 2015


 plugins/calendar/calendar.php                      |   17 +++++++++++----
 plugins/calendar/drivers/kolab/kolab_calendar.php  |    4 +--
 plugins/calendar/drivers/kolab/kolab_driver.php    |   23 ++++++++++++++++-----
 plugins/calendar/skins/larry/print.css             |    1 
 plugins/libcalendaring/lib/libcalendaring_itip.php |    6 ++++-
 5 files changed, 39 insertions(+), 12 deletions(-)

New commits:
commit f7e7df62a28541b0d3bcecf77ffc2819e006924f
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date:   Tue Feb 17 15:49:14 2015 +0100

    Apply date offset from exceptions to recurring occurrences (#4386)

diff --git a/plugins/calendar/drivers/kolab/kolab_calendar.php b/plugins/calendar/drivers/kolab/kolab_calendar.php
index 4316542..a392a9f 100644
--- a/plugins/calendar/drivers/kolab/kolab_calendar.php
+++ b/plugins/calendar/drivers/kolab/kolab_calendar.php
@@ -297,7 +297,7 @@ class kolab_calendar extends kolab_storage_folder_api
             $exdate = $exception['recurrence_date'] ? $exception['recurrence_date']->format('Ymd') : substr($exception['_instance'], 0, 8);
             if ($exdate == $event_date) {
               $event['_instance'] = $exception['_instance'];
-              kolab_driver::merge_event_data($event, $exception);
+              kolab_driver::merge_exception_data($event, $exception);
             }
           }
         }
@@ -641,7 +641,7 @@ class kolab_calendar extends kolab_storage_folder_api
         $rec_event['_instance'] = $instance_id;
 
         if ($overlay_data || $exdata[$datestr])  // copy data from exception
-          kolab_driver::merge_event_data($rec_event, $exdata[$datestr] ?: $overlay_data);
+          kolab_driver::merge_exception_data($rec_event, $exdata[$datestr] ?: $overlay_data);
 
         $rec_event['id'] = $rec_id;
         $rec_event['recurrence_id'] = $event['uid'];
diff --git a/plugins/calendar/drivers/kolab/kolab_driver.php b/plugins/calendar/drivers/kolab/kolab_driver.php
index 0a9790c..ff02fbb 100644
--- a/plugins/calendar/drivers/kolab/kolab_driver.php
+++ b/plugins/calendar/drivers/kolab/kolab_driver.php
@@ -928,6 +928,10 @@ class kolab_driver extends calendar_driver
     if ($old['recurrence'] || $old['recurrence_id']) {
       $master = $old['recurrence_id'] ? $fromcalendar->get_event($old['recurrence_id']) : $old;
       $savemode = $event['_savemode'] ?: ($old['recurrence_id'] ? 'current' : 'all');
+
+      // this-and-future on the first instance equals to 'all'
+      if (!$old['recurrence_id'] && $savemode == 'future')
+        $savemode = 'all';
     }
 
     // check if update affects scheduling and update attendee status accordingly
@@ -1135,7 +1139,7 @@ class kolab_driver extends calendar_driver
       // merge the new event properties onto future exceptions
       if ($savemode == 'future' && $exception['_instance'] >= $old['_instance']) {
         unset($event['thisandfuture']);
-        self::merge_event_data($master['recurrence']['EXCEPTIONS'][$i], $event);
+        self::merge_exception_data($master['recurrence']['EXCEPTIONS'][$i], $event);
       }
     }
 /*
@@ -1171,19 +1175,28 @@ class kolab_driver extends calendar_driver
    * @param array The event object to be altered
    * @param array The overlay event object to be merged over $event
    */
-  public static function merge_event_data(&$event, $overlay)
+  public static function merge_exception_data(&$event, $overlay)
   {
     static $forbidden = array('id','uid','recurrence','recurrence_date','thisandfuture','organizer','_attachments');
 
+    // compute date offset from the exception
+    if ($overlay['start'] instanceof DateTime && $overlay['recurrence_date'] instanceof DateTime) {
+      $date_offset = $overlay['recurrence_date']->diff($overlay['start']);
+    }
+
     foreach ($overlay as $prop => $value) {
-      // adjust time of the recurring event instance
       if ($prop == 'start' || $prop == 'end') {
-        if (is_object($event[$prop]) && is_a($event[$prop], 'DateTime')) {
-          $event[$prop]->setTime($value->format('G'), intval($value->format('i')), intval($value->format('s')));
+        if (is_object($event[$prop]) && $event[$prop] instanceof DateTime) {
           // set date value if overlay is an exception of the current instance
           if (substr($overlay['_instance'], 0, 8) == substr($event['_instance'], 0, 8)) {
             $event[$prop]->setDate(intval($value->format('Y')), intval($value->format('n')), intval($value->format('j')));
           }
+          // apply date offset
+          else if ($date_offset) {
+            $event[$prop]->add($date_offset);
+          }
+          // adjust time of the recurring event instance
+          $event[$prop]->setTime($value->format('G'), intval($value->format('i')), intval($value->format('s')));
         }
       }
       else if ($prop == 'thisandfuture' && $overlay['_instance'] == $event['_instance']) {


commit 4d534ea7868538c517fc7af4ae80d6db411a961a
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date:   Tue Feb 17 15:47:12 2015 +0100

    Forward savemode when removing a cancelled event

diff --git a/plugins/libcalendaring/lib/libcalendaring_itip.php b/plugins/libcalendaring/lib/libcalendaring_itip.php
index 2eec27c..8038add 100644
--- a/plugins/libcalendaring/lib/libcalendaring_itip.php
+++ b/plugins/libcalendaring/lib/libcalendaring_itip.php
@@ -602,7 +602,11 @@ class libcalendaring_itip
         // for CANCEL messages, we can:
         else if ($method == 'CANCEL') {
             $title = $this->gettext('itipcancellation');
-            $event_prop = array_filter(array('uid' => $event['uid'], '_instance' => $event['_instance']));
+            $event_prop = array_filter(array(
+              'uid' => $event['uid'],
+              '_instance' => $event['_instance'],
+              '_savemode' => $event['_savemode'],
+            ));
 
             // 1. remove the event from our calendar
             $button_remove = html::tag('input', array(


commit 46866e76cc00433e34a8c6c7c2967d5dbf6be6d0
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date:   Tue Feb 17 15:03:39 2015 +0100

    Report cancellation to removed attendees with this-and-future parameter

diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php
index 571e68b..fc4bbff 100644
--- a/plugins/calendar/calendar.php
+++ b/plugins/calendar/calendar.php
@@ -1149,6 +1149,10 @@ class calendar extends rcube_plugin
       $event = $action == 'remove' ? $old : $this->driver->get_event($event);
       $event['_savemode'] = $_savemode;
 
+      if ($old) {
+        $old['thisandfuture'] = $_savemode == 'future';
+      }
+
       // send notification for the main event when savemode is 'all'
       if ($_savemode == 'all' && $event['recurrence_id']) {
         $event['id'] = $event['recurrence_id'];


commit 3ea6d4357926092de2080667cae7c6c516e33097
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date:   Tue Feb 17 14:54:12 2015 +0100

    Fix deletion/cancellation of this-and-future instances

diff --git a/plugins/calendar/calendar.php b/plugins/calendar/calendar.php
index 8e6a1a3..571e68b 100644
--- a/plugins/calendar/calendar.php
+++ b/plugins/calendar/calendar.php
@@ -1711,6 +1711,9 @@ class calendar extends rcube_plugin
       if ($attendee['status'] == 'DELEGATED' && $attendee['rsvp'] == false) {
         $event['attendees'][$i]['noreply'] = true;
       }
+      else {
+        unset($event['attendees'][$i]['noreply']);
+      }
     }
 
     if ($organizer === null && !empty($event['organizer'])) {
@@ -2432,12 +2435,14 @@ class calendar extends rcube_plugin
    */
   function event_itip_remove()
   {
-    $success = false;
-    $uid     = rcube_utils::get_input_value('uid', rcube_utils::INPUT_POST);
-    $inst    = rcube_utils::get_input_value('_instance', rcube_utils::INPUT_POST);
+    $success  = false;
+    $uid      = rcube_utils::get_input_value('uid', rcube_utils::INPUT_POST);
+    $instance = rcube_utils::get_input_value('_instance', rcube_utils::INPUT_POST);
+    $savemode = rcube_utils::get_input_value('_savemode', rcube_utils::INPUT_POST);
 
     // search for event if only UID is given
-    if ($event = $this->driver->get_event(array('uid' => $uid, '_instance' => $inst), true)) {
+    if ($event = $this->driver->get_event(array('uid' => $uid, '_instance' => $instance), true)) {
+      $event['_savemode'] = $savemode;
       $success = $this->driver->remove_event($event, true);
     }
 
diff --git a/plugins/calendar/skins/larry/print.css b/plugins/calendar/skins/larry/print.css
index ce6e8e7..fc5de97 100644
--- a/plugins/calendar/skins/larry/print.css
+++ b/plugins/calendar/skins/larry/print.css
@@ -76,6 +76,7 @@ body, td, th, div, p, h3, select, input, textarea {
 #calendarlist li div {
 	float: left;
 	padding-right: 3em;
+	padding-bottom: 1em;
 }
 
 #calendarlist input,




More information about the commits mailing list