Delete exceptions to recurring events when deleting the recurring event.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Mon, 19 Apr 2010 22:48:29 +0000 (18:48 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Mon, 19 Apr 2010 22:48:29 +0000 (18:48 -0400)
kronolith/docs/CHANGES
kronolith/lib/Driver/Sql.php

index ae9875d..2508316 100644 (file)
@@ -2,6 +2,8 @@
 v3.0-git
 --------
 
+[mjr] Deleting a recurring event now also deletes all exceptions to that event.
+[mjr] Add support for inline maps to the Ajax interface.
 [jan] Add preference to limit the events per day in the month view.
 [jan] Add system calendars (Request #2059).
 [jan] Add URL field to events.
index 7f98651..fc7b75b 100644 (file)
@@ -712,6 +712,8 @@ class Kronolith_Driver_Sql extends Kronolith_Driver
     {
         /* Fetch the event for later use. */
         $event = $this->getEvent($eventId);
+        $original_uid = $event->uid;
+        $isRecurring = $event->recurs();
 
         $query = 'DELETE FROM ' . $this->_params['table'] . ' WHERE event_id = ? AND calendar_id = ?';
         $values = array($eventId, $this->calendar);
@@ -762,6 +764,22 @@ class Kronolith_Driver_Sql extends Kronolith_Driver
         if (!$silent) {
             Kronolith::sendNotification($event, 'delete');
         }
+
+        /* Now check for any exceptions */
+        if ($isRecurring) {
+            $query = 'SELECT event_id FROM ' . $this->_params['table'] . ' WHERE event_baseid = ? AND calendar_id = ?';
+            $values = array($original_uid, $this->calendar);
+
+            /* Log the query at a DEBUG log level. */
+            Horde::logMessage(sprintf('Kronolith_Driver_Sql::deleteEvent(): user = "%s"; query = "%s"; values = "%s"',
+                                      Horde_Auth::getAuth(), $query, implode(',', $values)), 'DEBUG');
+
+            $result = $this->_db->getCol($query, 0, $values);
+            $this->handleError($result);
+            foreach ($result as $id) {
+                $this->deleteEvent($id, $silent);
+            }
+        }
     }
 
     /**