From 03d9defaabdfdedd81dbbe7d3fce16932d2d4ee7 Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Mon, 19 Apr 2010 18:48:29 -0400 Subject: [PATCH] Delete exceptions to recurring events when deleting the recurring event. --- kronolith/docs/CHANGES | 2 ++ kronolith/lib/Driver/Sql.php | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/kronolith/docs/CHANGES b/kronolith/docs/CHANGES index ae9875ddb..250831672 100644 --- a/kronolith/docs/CHANGES +++ b/kronolith/docs/CHANGES @@ -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. diff --git a/kronolith/lib/Driver/Sql.php b/kronolith/lib/Driver/Sql.php index 7f98651a7..fc7b75b6d 100644 --- a/kronolith/lib/Driver/Sql.php +++ b/kronolith/lib/Driver/Sql.php @@ -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); + } + } } /** -- 2.11.0