From 46f3d19e1c9f1dace54bcb998b72537926a45a12 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 7 Jan 2010 02:07:33 +0000 Subject: [PATCH] supported-report-set as required for CardDAV and Sogo connector --- .../inc/class.addressbook_groupdav.inc.php | 16 ++++++++++++++++ egw-pear/HTTP/WebDAV/Server.php | 16 ++++++++++++---- phpgwapi/inc/class.groupdav.inc.php | 11 ++++++++++- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/addressbook/inc/class.addressbook_groupdav.inc.php b/addressbook/inc/class.addressbook_groupdav.inc.php index 6475630fbe..01b03250ff 100644 --- a/addressbook/inc/class.addressbook_groupdav.inc.php +++ b/addressbook/inc/class.addressbook_groupdav.inc.php @@ -325,6 +325,22 @@ class addressbook_groupdav extends groupdav_handler return '"'.$result[0]['modified'].'"'; } + /** + * Add extra properties for addressbook collections + * + * @param array $props=array() regular props by the groupdav handler + * @return array + */ + static function extra_properties(array $props=array()) + { + // 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'), + )); + return $props; + } + /** * Get the handler and set the supported fields * diff --git a/egw-pear/HTTP/WebDAV/Server.php b/egw-pear/HTTP/WebDAV/Server.php index 1bf7cc1bae..e68691c3cf 100644 --- a/egw-pear/HTTP/WebDAV/Server.php +++ b/egw-pear/HTTP/WebDAV/Server.php @@ -758,8 +758,9 @@ class HTTP_WebDAV_Server . "GMT\n"; break; case "resourcetype": + case "supported-report-set": if (!is_array($prop['val'])) { - echo " \n"; + echo " \n"; } else { // multiple resourcetypes from different namespaces as required by GroupDAV $vals = $extra_ns = ''; foreach($prop['val'] as $subprop) @@ -781,10 +782,17 @@ class HTTP_WebDAV_Server } else { $ns_name = ''; } - $vals .= "<$ns_name$subprop[val]/>"; + // check if $prop[val] should be returned as attribute or value + if ($subprop['name'] == $subprop['val'] || + $subprop['name'] == $prop['name']) { + $vals .= "<$ns_name$subprop[val]/>"; + } else { + $vals .= "<$ns_name$subprop[name]>$subprop[val]"; + } } - echo " $vals\n"; - //error_log("resourcetype: $vals"); + echo " $vals\n"; + //error_log(array2string($prop)); + //error_log("$vals"); } break; case "supportedlock": diff --git a/phpgwapi/inc/class.groupdav.inc.php b/phpgwapi/inc/class.groupdav.inc.php index 703823bf14..ddc2044b1f 100644 --- a/phpgwapi/inc/class.groupdav.inc.php +++ b/phpgwapi/inc/class.groupdav.inc.php @@ -497,7 +497,16 @@ class groupdav extends HTTP_WebDAV_Server default: $ns = $prop['ns']; } - $arr[$ns.':'.$prop['name']] = $prop['val']; + // 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']; + } } return $arr; }