use native sabredav functions to generate repeating events
This commit is contained in:
parent
c6a03ec6d8
commit
ece1162949
|
@ -381,6 +381,12 @@ class OC_Calendar_App{
|
|||
'description' => isset($vevent->DESCRIPTION)?htmlspecialchars($vevent->DESCRIPTION->value):'',
|
||||
'lastmodified'=>$lastmodified);
|
||||
|
||||
$object->expand($start, $end);
|
||||
foreach($object->getComponents() as $child){
|
||||
if(get_class($child) != 'Sabre_VObject_Component_VEvent'){
|
||||
continue;
|
||||
}
|
||||
$vevent = $child;
|
||||
$dtstart = $vevent->DTSTART;
|
||||
$start_dt = $dtstart->getDateTime();
|
||||
$dtend = OC_Calendar_Object::getDTEndFromVEvent($vevent);
|
||||
|
@ -395,49 +401,14 @@ class OC_Calendar_App{
|
|||
}
|
||||
|
||||
// Handle exceptions to recurring events
|
||||
$exceptionDateObjects = $vevent->select('EXDATE');
|
||||
/*$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;
|
||||
}
|
||||
}
|
||||
|
||||
$return = array();
|
||||
if($event['repeating'] == 1){
|
||||
$duration = (double) $end_dt->format('U') - (double) $start_dt->format('U');
|
||||
$r = new When();
|
||||
$r->recur($start_dt)->rrule((string) $vevent->RRULE);
|
||||
/*$r = new iCal_Repeat_Generator(array('RECUR' => $start_dt,
|
||||
* 'RRULE' => (string)$vevent->RRULE
|
||||
* 'RDATE' => (string)$vevent->RDATE
|
||||
* 'EXRULE' => (string)$vevent->EXRULE
|
||||
* 'EXDATE' => (string)$vevent->EXDATE));*/
|
||||
while($result = $r->next()){
|
||||
if($result < $start){
|
||||
continue;
|
||||
}
|
||||
if($result > $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($output['allDay'] == true){
|
||||
$output['start'] = $result->format('Y-m-d');
|
||||
$output['end'] = date('Y-m-d', $result->format('U') + --$duration);
|
||||
}else{
|
||||
$output['start'] = $result->format('Y-m-d H:i:s');
|
||||
$output['end'] = date('Y-m-d H:i:s', $result->format('U') + $duration);
|
||||
}
|
||||
$return[] = $output;
|
||||
}
|
||||
}else{
|
||||
}*/
|
||||
if($output['allDay'] == true){
|
||||
$output['start'] = $start_dt->format('Y-m-d');
|
||||
$end_dt->modify('-1 sec');
|
||||
|
|
Loading…
Reference in New Issue