forked from extern/egroupware
fixed supported-report-set according to a calendarserver example and reorganized HTTP_WebDAV_Server to generally support hierachical properties
This commit is contained in:
parent
b446f6de4e
commit
8d55e4800e
@ -328,6 +328,21 @@ class addressbook_groupdav extends groupdav_handler
|
|||||||
/**
|
/**
|
||||||
* Add extra properties for addressbook collections
|
* Add extra properties for addressbook collections
|
||||||
*
|
*
|
||||||
|
* Example for supported-report-set syntax from Apples Calendarserver:
|
||||||
|
* <D:supported-report-set>
|
||||||
|
* <supported-report>
|
||||||
|
* <report>
|
||||||
|
* <addressbook-query xmlns='urn:ietf:params:xml:ns:carddav'/>
|
||||||
|
* </report>
|
||||||
|
* </supported-report>
|
||||||
|
* <supported-report>
|
||||||
|
* <report>
|
||||||
|
* <addressbook-multiget xmlns='urn:ietf:params:xml:ns:carddav'/>
|
||||||
|
* </report>
|
||||||
|
* </supported-report>
|
||||||
|
* </D:supported-report-set>
|
||||||
|
* @link http://www.mail-archive.com/calendarserver-users@lists.macosforge.org/msg01156.html
|
||||||
|
*
|
||||||
* @param array $props=array() regular props by the groupdav handler
|
* @param array $props=array() regular props by the groupdav handler
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
@ -335,8 +350,12 @@ class addressbook_groupdav extends groupdav_handler
|
|||||||
{
|
{
|
||||||
// supported reports (required property for CardDAV)
|
// supported reports (required property for CardDAV)
|
||||||
$props[] = HTTP_WebDAV_Server::mkprop('supported-report-set',array(
|
$props[] = HTTP_WebDAV_Server::mkprop('supported-report-set',array(
|
||||||
HTTP_WebDAV_Server::mkprop('supported-report','addressbook-query'),
|
HTTP_WebDAV_Server::mkprop('supported-report',array(
|
||||||
HTTP_WebDAV_Server::mkprop('supported-report','addressbook-multiget'),
|
HTTP_WebDAV_Server::mkprop('report',
|
||||||
|
HTTP_WebDAV_Server::mkprop(groupdav::CARDDAV,'addressbook-query','')))),
|
||||||
|
HTTP_WebDAV_Server::mkprop('supported-report',array(
|
||||||
|
HTTP_WebDAV_Server::mkprop('report',
|
||||||
|
HTTP_WebDAV_Server::mkprop(groupdav::CARDDAV,'addressbook-multiget','')))),
|
||||||
));
|
));
|
||||||
return $props;
|
return $props;
|
||||||
}
|
}
|
||||||
|
@ -275,13 +275,13 @@ class groupdav extends HTTP_WebDAV_Server
|
|||||||
if ($prop == 'resourcetype')
|
if ($prop == 'resourcetype')
|
||||||
{
|
{
|
||||||
$resourcetype = array(
|
$resourcetype = array(
|
||||||
self::mkprop('collection','collection'),
|
self::mkprop('collection',''),
|
||||||
);
|
);
|
||||||
if (!$no_extra_types)
|
if (!$no_extra_types)
|
||||||
{
|
{
|
||||||
foreach($this->root[$app]['resourcetype'] as $ns => $type)
|
foreach($this->root[$app]['resourcetype'] as $ns => $type)
|
||||||
{
|
{
|
||||||
$resourcetype[] = self::mkprop($ns,'resourcetype', $type);
|
$resourcetype[] = self::mkprop($ns,$type,'');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$props[] = self::mkprop('resourcetype',$resourcetype);
|
$props[] = self::mkprop('resourcetype',$resourcetype);
|
||||||
@ -389,7 +389,7 @@ class groupdav extends HTTP_WebDAV_Server
|
|||||||
{
|
{
|
||||||
if (!isset($collection_props))
|
if (!isset($collection_props))
|
||||||
{
|
{
|
||||||
$collection_props = self::props2array($file['props']);
|
$collection_props = $this->props2array($file['props']);
|
||||||
echo '<h3>'.lang('Collection listing').': '.htmlspecialchars($collection_props['DAV:displayname'])."</h3>\n";
|
echo '<h3>'.lang('Collection listing').': '.htmlspecialchars($collection_props['DAV:displayname'])."</h3>\n";
|
||||||
continue; // own entry --> displaying properies later
|
continue; // own entry --> displaying properies later
|
||||||
}
|
}
|
||||||
@ -398,7 +398,7 @@ class groupdav extends HTTP_WebDAV_Server
|
|||||||
echo "<table>\n\t<tr class='th'><th>#</th><th>".lang('Name')."</th><th>".lang('Size')."</th><th>".lang('Last modified')."</th><th>".
|
echo "<table>\n\t<tr class='th'><th>#</th><th>".lang('Name')."</th><th>".lang('Size')."</th><th>".lang('Last modified')."</th><th>".
|
||||||
lang('ETag')."</th><th>".lang('Content type')."</th><th>".lang('Resource type')."</th></tr>\n";
|
lang('ETag')."</th><th>".lang('Content type')."</th><th>".lang('Resource type')."</th></tr>\n";
|
||||||
}
|
}
|
||||||
$props = self::props2array($file['props']);
|
$props = $this->props2array($file['props']);
|
||||||
//echo $file['path']; _debug_array($props);
|
//echo $file['path']; _debug_array($props);
|
||||||
$class = $class == 'row_on' ? 'row_off' : 'row_on';
|
$class = $class == 'row_on' ? 'row_off' : 'row_on';
|
||||||
if (substr($file['path'],-1) == '/')
|
if (substr($file['path'],-1) == '/')
|
||||||
@ -448,13 +448,13 @@ class groupdav extends HTTP_WebDAV_Server
|
|||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected static function prop_value($value)
|
protected function prop_value($value)
|
||||||
{
|
{
|
||||||
if (is_array($value))
|
if (is_array($value))
|
||||||
{
|
{
|
||||||
if (isset($value[0]['ns']))
|
if (isset($value[0]['ns']))
|
||||||
{
|
{
|
||||||
$value = self::props2array($value);
|
$value = $this->_hierarchical_prop_encode($value);
|
||||||
}
|
}
|
||||||
$value = htmlspecialchars(array2string($value));
|
$value = htmlspecialchars(array2string($value));
|
||||||
}
|
}
|
||||||
@ -475,7 +475,7 @@ class groupdav extends HTTP_WebDAV_Server
|
|||||||
* @param array $props
|
* @param array $props
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected static function props2array(array $props)
|
protected function props2array(array $props)
|
||||||
{
|
{
|
||||||
$arr = array();
|
$arr = array();
|
||||||
foreach($props as $prop)
|
foreach($props as $prop)
|
||||||
@ -497,16 +497,8 @@ class groupdav extends HTTP_WebDAV_Server
|
|||||||
default:
|
default:
|
||||||
$ns = $prop['ns'];
|
$ns = $prop['ns'];
|
||||||
}
|
}
|
||||||
// allow multiple values for same name
|
$arr[$ns.':'.$prop['name']] = is_array($prop['val']) ?
|
||||||
if (isset($arr[$ns.':'.$prop['name']]))
|
$this->_hierarchical_prop_encode($prop['val']) : $prop['val'];
|
||||||
{
|
|
||||||
$arr[$ns.':'.$prop['name']] = (array)$arr[$ns.':'.$prop['name']];
|
|
||||||
$arr[$ns.':'.$prop['name']][] = $prop['val'];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$arr[$ns.':'.$prop['name']] = $prop['val'];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return $arr;
|
return $arr;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user