fix birthday calendar

This commit is contained in:
Georg Ehrke 2012-06-29 15:40:46 +02:00
parent b95996c02c
commit bda0026374
2 changed files with 12 additions and 10 deletions

View File

@ -368,12 +368,14 @@ class OC_Calendar_App{
* @return (array) $output - readable output * @return (array) $output - readable output
*/ */
public static function generateEventOutput($event, $start, $end){ public static function generateEventOutput($event, $start, $end){
if(isset($event['calendardata'])){ if(!isset($event['calendardata']) && !isset($event['vevent'])){
$object = OC_VObject::parse($event['calendardata']); return false;
$vevent = $object->VEVENT;
}else{
$vevent = $event['vevent'];
} }
if(!isset($event['calendardata']) && isset($event['vevent'])){
$event['calendardata'] = "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:ownCloud's Internal iCal System\n" . $event['vevent']->serialize() . "END:VCALENDAR";
}
$object = OC_VObject::parse($event['calendardata']);
$vevent = $object->VEVENT;
$return = array(); $return = array();
$id = $event['id']; $id = $event['id'];
$allday = ($vevent->DTSTART->getDateType() == Sabre_VObject_Element_DateTime::DATE)?true:false; $allday = ($vevent->DTSTART->getDateType() == Sabre_VObject_Element_DateTime::DATE)?true:false;
@ -404,15 +406,13 @@ class OC_Calendar_App{
$return[] = array_merge($staticoutput, $dynamicoutput); $return[] = array_merge($staticoutput, $dynamicoutput);
} }
}else{ }else{
if(OC_Calendar_Object::isrepeating($id)){ $object->expand($start, $end);
$object->expand($start, $end);
}
foreach($object->getComponents() as $singleevent){ foreach($object->getComponents() as $singleevent){
if(!($singleevent instanceof Sabre_VObject_Component_VEvent)){ if(!($singleevent instanceof Sabre_VObject_Component_VEvent)){
continue; continue;
} }
$dynamicoutput = OC_Calendar_Object::generateStartEndDate($singleevent->DTSTART, OC_Calendar_Object::getDTEndFromVEvent($singleevent), $allday, self::$tz); $dynamicoutput = OC_Calendar_Object::generateStartEndDate($singleevent->DTSTART, OC_Calendar_Object::getDTEndFromVEvent($singleevent), $allday, self::$tz);
$return[] = array_merge($staticoutput, $dynamicoutput); $return[] = array_merge($staticoutput, $dynamicoutput);
} }
} }
return $return; return $return;

View File

@ -90,9 +90,10 @@ class OC_Contacts_Hooks{
if ($birthday) { if ($birthday) {
$date = new DateTime($birthday); $date = new DateTime($birthday);
$vevent = new OC_VObject('VEVENT'); $vevent = new OC_VObject('VEVENT');
$vevent->setDateTime('LAST-MODIFIED', new DateTime($vcard->REV)); //$vevent->setDateTime('LAST-MODIFIED', new DateTime($vcard->REV));
$vevent->setDateTime('DTSTART', $date, Sabre_VObject_Element_DateTime::DATE); $vevent->setDateTime('DTSTART', $date, Sabre_VObject_Element_DateTime::DATE);
$vevent->setString('DURATION', 'P1D'); $vevent->setString('DURATION', 'P1D');
$vevent->setString('UID', substr(md5(rand().time()),0,10));
// DESCRIPTION? // DESCRIPTION?
$vevent->setString('RRULE', 'FREQ=YEARLY'); $vevent->setString('RRULE', 'FREQ=YEARLY');
$title = str_replace('{name}', $vcard->getAsString('FN'), OC_Contacts_App::$l10n->t('{name}\'s Birthday')); $title = str_replace('{name}', $vcard->getAsString('FN'), OC_Contacts_App::$l10n->t('{name}\'s Birthday'));
@ -101,6 +102,7 @@ class OC_Contacts_Hooks{
'vevent' => $vevent, 'vevent' => $vevent,
'repeating' => true, 'repeating' => true,
'summary' => $title, 'summary' => $title,
'calendardata' => "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:ownCloud Contacts " . OCP\App::getAppVersion('contacts') . "\n" . $vevent->serialize() . "END:VCALENDAR"
); );
} }
} }