diff --git a/apps/calendar/lib/calendar.php b/apps/calendar/lib/calendar.php index 5e93d784a8..76f6b253b5 100644 --- a/apps/calendar/lib/calendar.php +++ b/apps/calendar/lib/calendar.php @@ -79,7 +79,7 @@ class OC_Calendar_Calendar{ return $result->fetchRow(); } - public static function addCalendar($userid,$name,$description,$components='VEVENT,VTODO',$timezone=null,$order=0,$color=null){ + public static function addCalendar($userid,$name,$description,$components='VEVENT,VTODO,VJOURNAL',$timezone=null,$order=0,$color=null){ $all = self::allCalendars($userid); $uris = array(); foreach($all as $i){ @@ -279,6 +279,22 @@ class OC_Calendar_Calendar{ $use = $property; } } + elseif($property->name == 'VTODO' || $property->name == 'VJOURNAL'){ + $return[0] = $use->name; + foreach($property->children as &$element){ + if($property->name == 'SUMMARY'){ + $return[3] = $property->value; + } + elseif($property->name == 'UID'){ + $return[5] = $property->value; + } + }; + + // Only one VTODO or VJOURNAL per object + // (only one UID per object but a UID is required by a VTODO => + // one VTODO per object) + break; + } } unset($property); // find the data diff --git a/apps/calendar/lib/connector_sabre.php b/apps/calendar/lib/connector_sabre.php index 199f5011f9..aff1941688 100644 --- a/apps/calendar/lib/connector_sabre.php +++ b/apps/calendar/lib/connector_sabre.php @@ -235,7 +235,11 @@ class OC_Connector_Sabre_CalDAV extends Sabre_CalDAV_Backend_Abstract { * @return array */ public function getCalendarObjects($calendarId) { - return OC_Calendar_Calendar::allCalendarObjects($calendarId); + $data = array(); + foreach(OC_Calendar_Calendar::allCalendarObjects($calendarId) as $row){ + $data[] = $this->OCAddETag($row); + } + return $data; } /** @@ -251,7 +255,11 @@ class OC_Connector_Sabre_CalDAV extends Sabre_CalDAV_Backend_Abstract { * @return array */ public function getCalendarObject($calendarId,$objectUri) { - return OC_Calendar_Calendar::findCalendarObjectWhereDAVDataIs($calendarId,$objectUri); + $data = OC_Calendar_Calendar::findCalendarObjectWhereDAVDataIs($calendarId,$objectUri); + if(is_array($data)){ + $data = $this->OCAddETag($data); + } + return $data; } /** @@ -288,4 +296,16 @@ class OC_Connector_Sabre_CalDAV extends Sabre_CalDAV_Backend_Abstract { public function deleteCalendarObject($calendarId,$objectUri){ OC_Calendar_Calendar::deleteCalendarObjectFromDAVData($calendarID,$objectUri); } + + /** + * @brief Creates a etag + * @param array $row Database result + * @returns associative array + * + * Adds a key "etag" to the row + */ + private function OCAddETag($row){ + $row['etag'] = '"'.md5($row['calendarid'].$row['uri'].$row['calendardata'].$row['lastmodified']).'"'; + return $row; + } }