From ac7424612e29d33529edeab01325a50c46258f8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Lehrke?= Date: Tue, 5 Jan 2010 11:24:27 +0000 Subject: [PATCH] Calculate the EGw recur_enddate properly --- calendar/inc/class.calendar_ical.inc.php | 29 ++++++++++++++---------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/calendar/inc/class.calendar_ical.inc.php b/calendar/inc/class.calendar_ical.inc.php index 0930be8ba0..bf2a21503f 100644 --- a/calendar/inc/class.calendar_ical.inc.php +++ b/calendar/inc/class.calendar_ical.inc.php @@ -72,7 +72,7 @@ class calendar_ical extends calendar_boupdate 5 => 2, // normal 4 => 3, 3 => 3, 2 => 3, 1 => 3, // high ); - + /** * @var array $priority_egw2funambol conversion of the priority egw => funambol */ @@ -776,7 +776,7 @@ class calendar_ical extends calendar_boupdate // check if we are importing an event series with exceptions in CalDAV // only first event / series master get's cal_id from URL // other events are exceptions and need to be checked if they are new - // and for real (not status only) exceptions their recurrence-id need + // and for real (not status only) exceptions their recurrence-id need // to be included as recur_exception to the master if ($this->productManufacturer == 'groupdav' && $cal_id > 0 && count($events) > 1 && !$events[1]['id'] && @@ -2072,16 +2072,6 @@ class calendar_ical extends calendar_boupdate } } - if (!empty($vcardData['recur_enddate'])) - { - // reset recure_enddate to 00:00:00 on the last day - $vcardData['recur_enddate'] = mktime(0, 0, 0, - date('m', $vcardData['recur_enddate']), - date('d', $vcardData['recur_enddate']), - date('Y', $vcardData['recur_enddate']) - ); - } - $event['priority'] = 2; // default $event['alarm'] = $alarms; @@ -2121,6 +2111,21 @@ class calendar_ical extends calendar_boupdate break; } } + if (!empty($event['recur_enddate'])) + { + // reset recure_enddate to 00:00:00 on the last day + $rriter = calendar_rrule::event2rrule($event, false); + $rriter->rewind(); + $last = clone $rriter->time; + while ($rriter->current <= $rriter->enddate) + { + $last = clone $rriter->current; + $rriter->next_no_exception(); + } + $last->setTime(0, 0, 0); + $event['recur_enddate'] = $this->date2ts($last); + } + if ($this->calendarOwner) $event['owner'] = $this->calendarOwner; //Horde::logMessage("vevent2egw:\n" . print_r($event, true), // __FILE__, __LINE__, PEAR_LOG_DEBUG);