Merge branch 'calendar' of git.kde.org:owncloud into calendar

This commit is contained in:
Georg Ehrke 2011-08-28 20:16:40 +02:00
commit 947216942a
2 changed files with 39 additions and 3 deletions

View File

@ -79,7 +79,7 @@ class OC_Calendar_Calendar{
return $result->fetchRow(); 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); $all = self::allCalendars($userid);
$uris = array(); $uris = array();
foreach($all as $i){ foreach($all as $i){
@ -279,6 +279,22 @@ class OC_Calendar_Calendar{
$use = $property; $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); } unset($property);
// find the data // find the data

View File

@ -235,7 +235,11 @@ class OC_Connector_Sabre_CalDAV extends Sabre_CalDAV_Backend_Abstract {
* @return array * @return array
*/ */
public function getCalendarObjects($calendarId) { 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 * @return array
*/ */
public function getCalendarObject($calendarId,$objectUri) { 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){ public function deleteCalendarObject($calendarId,$objectUri){
OC_Calendar_Calendar::deleteCalendarObjectFromDAVData($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;
}
} }