From 62da0bae432485d1fdec8c09ef96580332d2d43b Mon Sep 17 00:00:00 2001 From: Henning Becker Date: Fri, 17 Feb 2012 14:32:02 +0100 Subject: [PATCH] Handle event exceptions in calendar app. Execeptions to recurring events are not shown anymore. --- apps/calendar/ajax/events.php | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/apps/calendar/ajax/events.php b/apps/calendar/ajax/events.php index dd593ddec9..977afdd51b 100755 --- a/apps/calendar/ajax/events.php +++ b/apps/calendar/ajax/events.php @@ -47,6 +47,17 @@ foreach($events as $event){ $start_dt->setTimezone(new DateTimeZone($user_timezone)); $end_dt->setTimezone(new DateTimeZone($user_timezone)); } + + // Handle exceptions to recurring events + $exceptionDateObjects = $vevent->select('EXDATE'); + $exceptionDateMap = Array(); + foreach ($exceptionDateObjects as $exceptionObject) { + foreach($exceptionObject->getDateTimes() as $datetime) { + $ts = $datetime->getTimestamp(); + $exceptionDateMap[idate('Y',$ts)][idate('m', $ts)][idate('d', $ts)] = true; + } + } + //Repeating Events if($event['repeating'] == 1){ $duration = (double) $end_dt->format('U') - (double) $start_dt->format('U'); @@ -56,6 +67,14 @@ foreach($events as $event){ if($result->format('U') > $_GET['end']){ break; } + + // Check for exceptions to recurring events + $ts = $result->getTimestamp(); + if (isset($exceptionDateMap[idate('Y',$ts)][idate('m', $ts)][idate('d', $ts)])) { + continue; + } + unset($ts); + if($return_event['allDay'] == true){ $return_event['start'] = $result->format('Y-m-d'); $return_event['end'] = date('Y-m-d', $result->format('U') + --$duration); @@ -81,4 +100,4 @@ foreach($events as $event){ } } OC_JSON::encodedPrint($return); -?> \ No newline at end of file +?>