diff --git a/calendar/inc/class.calendar_groupdav.inc.php b/calendar/inc/class.calendar_groupdav.inc.php index 46273f2664..b6d7a029cd 100644 --- a/calendar/inc/class.calendar_groupdav.inc.php +++ b/calendar/inc/class.calendar_groupdav.inc.php @@ -99,7 +99,8 @@ class calendar_groupdav extends groupdav_handler //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( HTTP_WebDAV_Server::mkprop('getetag',$this->get_etag($event)), - HTTP_WebDAV_Server::mkprop('getcontenttype', 'text/calendar'), + HTTP_WebDAV_Server::mkprop('getcontenttype', strpos($_SERVER['HTTP_USER_AGENT'],'KHTML') === false ? + 'text/calendar; charset=utf-8; component=VEVENT' : 'text/calendar'), // getlastmodified and getcontentlength are required by WebDAV and Cadaver eg. reports 404 Not found if not set HTTP_WebDAV_Server::mkprop('getlastmodified', $event['modified']), ); @@ -114,7 +115,7 @@ class calendar_groupdav extends groupdav_handler $props[] = HTTP_WebDAV_Server::mkprop('getcontentlength', ''); // expensive to calculate and no CalDAV client uses it } $files['files'][] = array( - 'path' => '/calendar/'.$event['id'], + 'path' => '/calendar/'.$event['id'].'.ics', 'props' => $props, ); } diff --git a/infolog/inc/class.infolog_groupdav.inc.php b/infolog/inc/class.infolog_groupdav.inc.php index bb9bc08d0b..40f71229e4 100644 --- a/infolog/inc/class.infolog_groupdav.inc.php +++ b/infolog/inc/class.infolog_groupdav.inc.php @@ -48,28 +48,34 @@ class infolog_groupdav extends groupdav_handler * @param int $user account_id * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') */ - function propfind($path,$options,&$files,$user) + function propfind($path,$options,&$files,$user,$id='') { + // todo add a filter to limit how far back entries from the past get synced + $filter = array( + 'info_type' => 'task', + ); + if ($id) $filter['info_id'] = $id; // propfind on a single id + // ToDo: add parameter to only return id & etag if (($tasks = $this->bo->search($params=array( 'order' => 'info_datemodified', 'sort' => 'DESC', 'filter' => 'own', // filter my: entries user is responsible for, // filter own: entries the user own or is responsible for - - // todo add a filter to limit how far back entries from the past get synced - 'col_filter' => Array ( - 'info_type' => 'task', - ), + 'col_filter' => $filter, )))) { foreach($tasks as $task) { $files['files'][] = array( - 'path' => '/infolog/'.$task['info_id'], + 'path' => '/infolog/'.$task['info_id'].'.ics', 'props' => array( HTTP_WebDAV_Server::mkprop('getetag',$this->get_etag($task)), - HTTP_WebDAV_Server::mkprop('getcontenttype', 'text/calendar'), + HTTP_WebDAV_Server::mkprop('getcontenttype', strpos($_SERVER['HTTP_USER_AGENT'],'KHTML') === false ? + 'text/calendar; charset=utf-8; component=VTODO' : 'text/calendar'), // Konqueror (3.5) dont understand it otherwise + // getlastmodified and getcontentlength are required by WebDAV and Cadaver eg. reports 404 Not found if not set + HTTP_WebDAV_Server::mkprop('getlastmodified', $task['info_datemodified']), + HTTP_WebDAV_Server::mkprop('getcontentlength',''), ), ); } diff --git a/phpgwapi/inc/class.groupdav.inc.php b/phpgwapi/inc/class.groupdav.inc.php index 1198c623b3..bf00c35f13 100644 --- a/phpgwapi/inc/class.groupdav.inc.php +++ b/phpgwapi/inc/class.groupdav.inc.php @@ -45,9 +45,18 @@ class groupdav extends HTTP_WebDAV_Server var $http_auth_realm = self::REALM; var $root = array( - 'calendar' => array(self::GROUPDAV => 'vevent-collection', self::CALDAV => 'calendar'), - 'addressbook' => array(self::GROUPDAV => 'vcard-collection', self::CARDDAV => 'addressbook'), - 'infolog' => array(self::GROUPDAV => 'vtodo-collection'), + 'calendar' => array( + 'resourcetype' => array(self::GROUPDAV => 'vevent-collection', self::CALDAV => 'calendar'), + 'component-set' => array(self::GROUPDAV => 'VEVENT'), + ), + 'addressbook' => array( + 'resourcetype' => array(self::GROUPDAV => 'vcard-collection', self::CARDDAV => 'addressbook'), + 'component-set' => array(self::GROUPDAV => 'VCARD'), + ), + 'infolog' => array( + 'resourcetype' => array(self::GROUPDAV => 'vtodo-collection'), + 'component-set' => array(self::GROUPDAV => 'VTODO'), + ), ); /** * Debug level: 0 = nothing, 1 = function calls, 2 = more info, 3 = complete $_SERVER array @@ -176,17 +185,9 @@ class groupdav extends HTTP_WebDAV_Server { if (!$GLOBALS['egw_info']['user']['apps'][$app]) continue; // no rights for the given app - $props = array( - self::mkprop('displayname',$this->translation->convert(lang($app),$this->egw_charset,'utf-8')), - self::mkprop('resourcetype',$this->_resourcetype($app)), - ); - if (method_exists($app.'_groupdav','extra_properties')) - { - $props = ExecMethod($app.'_groupdav::extra_properties',$props); - } $files['files'][] = array( 'path' => '/'.$app.'/', - 'props' => $props, + 'props' => $this->_properties($app), ); } } @@ -203,11 +204,8 @@ class groupdav extends HTTP_WebDAV_Server { $files['files'][] = array( 'path' => '/'.$app.'/', - 'props' => $handler->extra_properties(array( - self::mkprop('displayname',$this->translation->convert(lang($app),$this->egw_charset,'utf-8')), - // KAddressbook doubles the folder, if the self URL contains the GroupDAV/CalDAV resourcetypes - self::mkprop('resourcetype', $this->_resourcetype($app,$app=='addressbook'&&strpos($_SERVER['HTTP_USER_AGENT'],'KHTML') !== false)), - )), + // KAddressbook doubles the folder, if the self URL contains the GroupDAV/CalDAV resourcetypes + 'props' => $this->_properties($app,$app=='addressbook'&&strpos($_SERVER['HTTP_USER_AGENT'],'KHTML') !== false), ); } if (!$options['depth'] && !$id) @@ -220,26 +218,46 @@ class groupdav extends HTTP_WebDAV_Server } /** - * Return resourcetype(s) for a given app + * Get the properties of a collection * * @param string $app * @param boolean $no_extra_types=false should the GroupDAV and CalDAV types be added (KAddressbook has problems with it in self URL) - * @return array or DAV properties generated via + * @return array of DAV properties */ - function _resourcetype($app,$no_extra_types=false) + function _properties($app,$no_extra_types=false) { - $resourcetype = array( - self::mkprop('collection','collection'), - ); - if (!$no_extra_types && isset($this->root[$app])) + $props = array( + self::mkprop('displayname',$this->translation->convert(lang($app),$this->egw_charset,'utf-8')), + ); + foreach($this->root[$app] as $prop => $values) { - foreach($this->root[$app] as $ns => $type) + if ($prop == 'resourcetype') { - $resourcetype[] = self::mkprop($ns,'resourcetype', $type); + $resourcetype = array( + self::mkprop('collection','collection'), + ); + if (!$no_extra_types) + { + foreach($this->root[$app]['resourcetype'] as $ns => $type) + { + $resourcetype[] = self::mkprop($ns,'resourcetype', $type); + } + } + $props[] = self::mkprop('resourcetype',$resourcetype); + } + else + { + foreach($values as $ns => $value) + { + $props[] = self::mkprop($ns,$prop,$value); + } } } - //error_log(__METHOD__."($app,$no_extra_types)=".array2string($resourcetype)); - return $resourcetype; + if (method_exists($app.'_groupdav','extra_properties')) + { + $props = ExecMethod($app.'_groupdav::extra_properties',$props); + } + return $props; } /**