Handle event exceptions in calendar app. Execeptions to recurring events are not shown anymore.
This commit is contained in:
parent
86893ea78c
commit
62da0bae43
|
@ -47,6 +47,17 @@ foreach($events as $event){
|
||||||
$start_dt->setTimezone(new DateTimeZone($user_timezone));
|
$start_dt->setTimezone(new DateTimeZone($user_timezone));
|
||||||
$end_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
|
//Repeating Events
|
||||||
if($event['repeating'] == 1){
|
if($event['repeating'] == 1){
|
||||||
$duration = (double) $end_dt->format('U') - (double) $start_dt->format('U');
|
$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']){
|
if($result->format('U') > $_GET['end']){
|
||||||
break;
|
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){
|
if($return_event['allDay'] == true){
|
||||||
$return_event['start'] = $result->format('Y-m-d');
|
$return_event['start'] = $result->format('Y-m-d');
|
||||||
$return_event['end'] = date('Y-m-d', $result->format('U') + --$duration);
|
$return_event['end'] = date('Y-m-d', $result->format('U') + --$duration);
|
||||||
|
@ -81,4 +100,4 @@ foreach($events as $event){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OC_JSON::encodedPrint($return);
|
OC_JSON::encodedPrint($return);
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue