Add deleted recurrences as exceptions as well.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Fri, 2 Jul 2010 20:52:44 +0000 (16:52 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Fri, 2 Jul 2010 20:53:25 +0000 (16:53 -0400)
framework/ActiveSync/lib/Horde/ActiveSync/Message/Exception.php
kronolith/lib/Event.php

index 09db9df..130a2cd 100644 (file)
@@ -45,7 +45,11 @@ class Horde_ActiveSync_Message_Exception extends Horde_ActiveSync_Message_Appoin
     }
 
     /**
-     * Exception start time
+     * Exception start time. This field seems to have different usages depending
+     * on if this is a command request from the client or from the server. If
+     * it's part of a request from client, then it represents the date of the
+     * exception that is to be deleted. If it is from server, it represents the
+     * date of the *original* recurring event.
      *
      * @return Horde_Date  The exception's start time
      */
index cd9b351..096165a 100644 (file)
@@ -1064,13 +1064,13 @@ abstract class Kronolith_Event
 
         /* Recurrence */
         if ($rrule = $message->getRecurrence()) {
-            $this->recurrence = $rrule;
 
             /* Exceptions */
             /* Since AS keeps exceptions as part of the original event, we need to
              * delete all existing exceptions and re-create them. The only drawback
              * to this is that the UIDs will change.
              */
+            $this->recurrence = $rrule;
             if (!empty($this->uid)) {
                 $kronolith_driver = Kronolith::getDriver(null, $this->calendar);
                 $search = new StdClass();
@@ -1102,7 +1102,11 @@ abstract class Kronolith_Event
                     $event->exceptionoriginaldate = $original;
                     $event->initialized = true;
                     $event->save();
-                }
+                } else {
+                    /* For exceptions that are deletions, just add the exception */
+                    $exceptiondt = $rule->getExceptionStartTime();
+                    $this->recurrence->addException($exceptiondt->format('Y'), $exceptiondt->format('m'), $exceptiondt->format('d'));
+               }
             }
         }
 
@@ -1205,7 +1209,7 @@ abstract class Kronolith_Event
                             array('start' => $exception->start,
                                   'end' => $exception->end,
                                   'allday' => $exception->isAllDay()));
-                        /* The start time of the original recurring event */
+                        /* The start time of the *original* recurring event */
                         $e->setExceptionStartTime($exception->exceptionoriginaldate);
                         $originaldate = $exception->exceptionoriginaldate->format('Ymd');
                         $key = array_search($originaldate, $exceptions);