Delete recurring events also, if we are past the last recurrence.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Wed, 2 Jun 2010 15:49:07 +0000 (11:49 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Wed, 2 Jun 2010 15:52:59 +0000 (11:52 -0400)
Ticket: 9071
Author: patrick.abiven@apitech.fr
Signed Off By: mrubinsk@horde.org

kronolith/lib/LoginTasks/Task/PurgeEvents.php

index 43cb6c3..c009e7f 100644 (file)
@@ -44,7 +44,7 @@ class Kronolith_LoginTasks_Task_PurgeEvents extends Horde_LoginTasks_Task
          * from it */
         $calendars = Kronolith::listCalendars(true, Horde_Perms::DELETE);
 
-        /* Start building an event object to use for the search */
+        /* Start building the search */
         $kronolith_driver = Kronolith::getDriver();
         $query = new StdClass();
         $query->start = null;
@@ -58,7 +58,10 @@ class Kronolith_LoginTasks_Task_PurgeEvents extends Horde_LoginTasks_Task
         $count = 0;
         foreach ($days as $events) {
             foreach ($events as $event) {
-                if (!$event->recurs()) {
+                /* Delete if no recurrence, or if we are past the last occurence */
+                if (!$event->recurs() ||
+                    $event->recurrence->nextRecurrence($del_time) == false) {
+
                     if ($event->calendar != $kronolith_driver->calendar) {
                         $kronolith_driver->open($event->calendar);
                     }