mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 16:48:49 +01:00
- .ics extension for todos and events
- new GroupDAV v2 component-set attribute for collections - getlastmodified & getcontentlength properties for infolog propfind - fixed propfind on a single infolog entry to return just that entry - getcontenttype of vevent and vtodo collection returns extra component
This commit is contained in:
parent
448705bc3f
commit
7ce97ba699
@ -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']));
|
//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(
|
$props = array(
|
||||||
HTTP_WebDAV_Server::mkprop('getetag',$this->get_etag($event)),
|
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
|
// getlastmodified and getcontentlength are required by WebDAV and Cadaver eg. reports 404 Not found if not set
|
||||||
HTTP_WebDAV_Server::mkprop('getlastmodified', $event['modified']),
|
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
|
$props[] = HTTP_WebDAV_Server::mkprop('getcontentlength', ''); // expensive to calculate and no CalDAV client uses it
|
||||||
}
|
}
|
||||||
$files['files'][] = array(
|
$files['files'][] = array(
|
||||||
'path' => '/calendar/'.$event['id'],
|
'path' => '/calendar/'.$event['id'].'.ics',
|
||||||
'props' => $props,
|
'props' => $props,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -48,28 +48,34 @@ class infolog_groupdav extends groupdav_handler
|
|||||||
* @param int $user account_id
|
* @param int $user account_id
|
||||||
* @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found')
|
* @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
|
// ToDo: add parameter to only return id & etag
|
||||||
if (($tasks = $this->bo->search($params=array(
|
if (($tasks = $this->bo->search($params=array(
|
||||||
'order' => 'info_datemodified',
|
'order' => 'info_datemodified',
|
||||||
'sort' => 'DESC',
|
'sort' => 'DESC',
|
||||||
'filter' => 'own', // filter my: entries user is responsible for,
|
'filter' => 'own', // filter my: entries user is responsible for,
|
||||||
// filter own: entries the user own or is responsible for
|
// filter own: entries the user own or is responsible for
|
||||||
|
'col_filter' => $filter,
|
||||||
// todo add a filter to limit how far back entries from the past get synced
|
|
||||||
'col_filter' => Array (
|
|
||||||
'info_type' => 'task',
|
|
||||||
),
|
|
||||||
))))
|
))))
|
||||||
{
|
{
|
||||||
foreach($tasks as $task)
|
foreach($tasks as $task)
|
||||||
{
|
{
|
||||||
$files['files'][] = array(
|
$files['files'][] = array(
|
||||||
'path' => '/infolog/'.$task['info_id'],
|
'path' => '/infolog/'.$task['info_id'].'.ics',
|
||||||
'props' => array(
|
'props' => array(
|
||||||
HTTP_WebDAV_Server::mkprop('getetag',$this->get_etag($task)),
|
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',''),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -45,9 +45,18 @@ class groupdav extends HTTP_WebDAV_Server
|
|||||||
var $http_auth_realm = self::REALM;
|
var $http_auth_realm = self::REALM;
|
||||||
|
|
||||||
var $root = array(
|
var $root = array(
|
||||||
'calendar' => array(self::GROUPDAV => 'vevent-collection', self::CALDAV => 'calendar'),
|
'calendar' => array(
|
||||||
'addressbook' => array(self::GROUPDAV => 'vcard-collection', self::CARDDAV => 'addressbook'),
|
'resourcetype' => array(self::GROUPDAV => 'vevent-collection', self::CALDAV => 'calendar'),
|
||||||
'infolog' => array(self::GROUPDAV => 'vtodo-collection'),
|
'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
|
* 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
|
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(
|
$files['files'][] = array(
|
||||||
'path' => '/'.$app.'/',
|
'path' => '/'.$app.'/',
|
||||||
'props' => $props,
|
'props' => $this->_properties($app),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -203,11 +204,8 @@ class groupdav extends HTTP_WebDAV_Server
|
|||||||
{
|
{
|
||||||
$files['files'][] = array(
|
$files['files'][] = array(
|
||||||
'path' => '/'.$app.'/',
|
'path' => '/'.$app.'/',
|
||||||
'props' => $handler->extra_properties(array(
|
// KAddressbook doubles the folder, if the self URL contains the GroupDAV/CalDAV resourcetypes
|
||||||
self::mkprop('displayname',$this->translation->convert(lang($app),$this->egw_charset,'utf-8')),
|
'props' => $this->_properties($app,$app=='addressbook'&&strpos($_SERVER['HTTP_USER_AGENT'],'KHTML') !== false),
|
||||||
// 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)),
|
|
||||||
)),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (!$options['depth'] && !$id)
|
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 string $app
|
||||||
* @param boolean $no_extra_types=false should the GroupDAV and CalDAV types be added (KAddressbook has problems with it in self URL)
|
* @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(
|
$props = array(
|
||||||
self::mkprop('collection','collection'),
|
self::mkprop('displayname',$this->translation->convert(lang($app),$this->egw_charset,'utf-8')),
|
||||||
);
|
);
|
||||||
if (!$no_extra_types && isset($this->root[$app]))
|
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));
|
if (method_exists($app.'_groupdav','extra_properties'))
|
||||||
return $resourcetype;
|
{
|
||||||
|
$props = ExecMethod($app.'_groupdav::extra_properties',$props);
|
||||||
|
}
|
||||||
|
return $props;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user