From 551183893664a0304a5cf926c7da9229a7a5c3d3 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 8 Oct 2012 11:14:07 +0000 Subject: [PATCH] new CalendarServer:(created|updated)-by properties used in iOS6 --- calendar/inc/class.calendar_groupdav.inc.php | 52 ++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/calendar/inc/class.calendar_groupdav.inc.php b/calendar/inc/class.calendar_groupdav.inc.php index 4922ddad77..1bcc880c03 100644 --- a/calendar/inc/class.calendar_groupdav.inc.php +++ b/calendar/inc/class.calendar_groupdav.inc.php @@ -18,6 +18,10 @@ require_once EGW_SERVER_ROOT.'/phpgwapi/inc/horde/lib/core.php'; * * Permanent error_log() calls should use $this->groupdav->log($str) instead, to be send to PHP error_log() * and our request-log (prefixed with "### " after request and response, like exceptions). + * + * @ToDo: new properties on calendars and it's ressources specially from sharing: + * - for the invite property: 5.2.2 in https://trac.calendarserver.org/browser/CalendarServer/trunk/doc/Extensions/caldav-sharing.txt + * - https://trac.calendarserver.org/browser/CalendarServer/trunk/doc/Extensions/caldav-schedulingchanges.txt */ class calendar_groupdav extends groupdav_handler { @@ -261,11 +265,17 @@ class calendar_groupdav extends groupdav_handler continue; } $etag = $this->get_etag($event, $schedule_tag); + //header('X-EGROUPWARE-EVENT-'.$event['id'].': '.$event['title'].': '.date('Y-m-d H:i:s',$event['start']).' - '.date('Y-m-d H:i:s',$event['end'])); $props = array( 'getcontenttype' => $this->agent != 'kde' ? 'text/calendar; charset=utf-8; component=VEVENT' : 'text/calendar', 'getetag' => '"'.$etag.'"', 'getlastmodified' => $event['modified'], + // user and timestamp of creation or last modification of event, used in calendarserver only for shared calendars + 'created-by' => HTTP_WebDAV_Server::mkprop(groupdav::CALENDARSERVER, 'created-by', + $this->_created_updated_by_prop($event['creator'], $event['created'])), + 'updated-by' => HTTP_WebDAV_Server::mkprop(groupdav::CALENDARSERVER, 'updated-by', + $this->_created_updated_by_prop($event['modifier'], $event['modified'])), ); if ($this->use_schedule_tag) { @@ -308,6 +318,48 @@ class calendar_groupdav extends groupdav_handler return $files; } + /** + * Return Calendarserver:(created|updated)-by sub-properties for a given user and time + * + * + * Ralf + * Becker + * 20121002T092006Z + * mailto:farktronix@me.com + * + * + * @param int $user + * @param int $time + * @return array with subprops + */ + private function _created_updated_by_prop($user, $time) + { + $props = array(); + foreach(array( + 'first-name' => 'account_firstname', + 'last-name' => 'account_lastname', + 'href' => 'account_email', + ) as $prop => $name) + { + if ($user && ($val = $this->accounts->id2name($user, $name))) + { + $ns = groupdav::CALENDARSERVER; + if ($prop == 'href') + { + $ns = ''; + $val = 'mailto:'.$val; + } + $props[$prop] = $ns ? HTTP_WebDAV_Server::mkprop($ns, $prop, $val) : HTTP_WebDAV_Server::mkprop($prop, $val); + } + } + if ($time) + { + $props['dtstamp'] = HTTP_WebDAV_Server::mkprop(groupdav::CALENDARSERVER, 'dtstamp', gmdate('Ymd\\This\\Z', $time)); + } + //error_log(__METHOD__."($user, $time) returning ".array2string($props)); + return $props ? $props : ''; + } + /** * Process the filters from the CalDAV REPORT request *