From 8d55e4800e13f788ec0e893ffe289eb177473eed Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 7 Jan 2010 04:24:45 +0000 Subject: [PATCH] fixed supported-report-set according to a calendarserver example and reorganized HTTP_WebDAV_Server to generally support hierachical properties --- .../inc/class.addressbook_groupdav.inc.php | 23 ++++++++++++++-- phpgwapi/inc/class.groupdav.inc.php | 26 +++++++------------ 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/addressbook/inc/class.addressbook_groupdav.inc.php b/addressbook/inc/class.addressbook_groupdav.inc.php index 01b03250ff..39f93fc189 100644 --- a/addressbook/inc/class.addressbook_groupdav.inc.php +++ b/addressbook/inc/class.addressbook_groupdav.inc.php @@ -328,6 +328,21 @@ class addressbook_groupdav extends groupdav_handler /** * Add extra properties for addressbook collections * + * Example for supported-report-set syntax from Apples Calendarserver: + * + * + * + * + * + * + * + * + * + * + * + * + * @link http://www.mail-archive.com/calendarserver-users@lists.macosforge.org/msg01156.html + * * @param array $props=array() regular props by the groupdav handler * @return array */ @@ -335,8 +350,12 @@ class addressbook_groupdav extends groupdav_handler { // supported reports (required property for CardDAV) $props[] = HTTP_WebDAV_Server::mkprop('supported-report-set',array( - HTTP_WebDAV_Server::mkprop('supported-report','addressbook-query'), - HTTP_WebDAV_Server::mkprop('supported-report','addressbook-multiget'), + HTTP_WebDAV_Server::mkprop('supported-report',array( + 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; } diff --git a/phpgwapi/inc/class.groupdav.inc.php b/phpgwapi/inc/class.groupdav.inc.php index ddc2044b1f..f4fa71d256 100644 --- a/phpgwapi/inc/class.groupdav.inc.php +++ b/phpgwapi/inc/class.groupdav.inc.php @@ -275,13 +275,13 @@ class groupdav extends HTTP_WebDAV_Server if ($prop == 'resourcetype') { $resourcetype = array( - self::mkprop('collection','collection'), + self::mkprop('collection',''), ); if (!$no_extra_types) { foreach($this->root[$app]['resourcetype'] as $ns => $type) { - $resourcetype[] = self::mkprop($ns,'resourcetype', $type); + $resourcetype[] = self::mkprop($ns,$type,''); } } $props[] = self::mkprop('resourcetype',$resourcetype); @@ -389,7 +389,7 @@ class groupdav extends HTTP_WebDAV_Server { if (!isset($collection_props)) { - $collection_props = self::props2array($file['props']); + $collection_props = $this->props2array($file['props']); echo '

'.lang('Collection listing').': '.htmlspecialchars($collection_props['DAV:displayname'])."

\n"; continue; // own entry --> displaying properies later } @@ -398,7 +398,7 @@ class groupdav extends HTTP_WebDAV_Server echo "\n\t\n"; } - $props = self::props2array($file['props']); + $props = $this->props2array($file['props']); //echo $file['path']; _debug_array($props); $class = $class == 'row_on' ? 'row_off' : 'row_on'; if (substr($file['path'],-1) == '/') @@ -448,13 +448,13 @@ class groupdav extends HTTP_WebDAV_Server * @param mixed $value * @return string */ - protected static function prop_value($value) + protected function prop_value($value) { if (is_array($value)) { if (isset($value[0]['ns'])) { - $value = self::props2array($value); + $value = $this->_hierarchical_prop_encode($value); } $value = htmlspecialchars(array2string($value)); } @@ -475,7 +475,7 @@ class groupdav extends HTTP_WebDAV_Server * @param array $props * @return array */ - protected static function props2array(array $props) + protected function props2array(array $props) { $arr = array(); foreach($props as $prop) @@ -497,16 +497,8 @@ class groupdav extends HTTP_WebDAV_Server default: $ns = $prop['ns']; } - // allow multiple values for same name - if (isset($arr[$ns.':'.$prop['name']])) - { - $arr[$ns.':'.$prop['name']] = (array)$arr[$ns.':'.$prop['name']]; - $arr[$ns.':'.$prop['name']][] = $prop['val']; - } - else - { - $arr[$ns.':'.$prop['name']] = $prop['val']; - } + $arr[$ns.':'.$prop['name']] = is_array($prop['val']) ? + $this->_hierarchical_prop_encode($prop['val']) : $prop['val']; } return $arr; }
#".lang('Name')."".lang('Size')."".lang('Last modified')."". lang('ETag')."".lang('Content type')."".lang('Resource type')."