From 880b801afc78c5832fd7a4a5fded41fe55f9f8e1 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 29 Oct 2007 20:04:33 +0000 Subject: [PATCH] backported GroupDAV support from trunk to 1.4, can be used eg. with the thunderbird GroupDAV plugin from inverse.ca (sogo-connector) to access the eGW addressbook from thunderbird --- egw-pear/HTTP/WebDAV/Server.php | 37 +++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/egw-pear/HTTP/WebDAV/Server.php b/egw-pear/HTTP/WebDAV/Server.php index c916888e42..bfb0e7abbb 100644 --- a/egw-pear/HTTP/WebDAV/Server.php +++ b/egw-pear/HTTP/WebDAV/Server.php @@ -144,7 +144,7 @@ class HTTP_WebDAV_Server // default uri is the complete request uri $uri = (@$this->_SERVER["HTTPS"] === "on" ? "https:" : "http:"); - $uri.= "//$this->_SERVER[HTTP_HOST]$this->_SERVER[SCRIPT_NAME]"; + $uri.= '//'.$this->_SERVER['HTTP_HOST'].$this->_SERVER['SCRIPT_NAME']; $path_info = empty($this->_SERVER["PATH_INFO"]) ? "/" : $this->_SERVER["PATH_INFO"]; @@ -689,8 +689,10 @@ class HTTP_WebDAV_Server /* TODO right now the user implementation has to make sure collections end in a slash, this should be done in here by checking the resource attribute */ - $href = $this->_mergePathes($this->_SERVER['SCRIPT_NAME'], $path); - + //$href = $this->_mergePathes($this->_SERVER['SCRIPT_NAME'], $path); + // href needs protocol and host too + $href = $this->_mergePathes($this->base_uri, $path); + echo " $href\n"; // report all found properties and their values (if any) @@ -726,7 +728,34 @@ class HTTP_WebDAV_Server . "GMT\n"; break; case "resourcetype": - echo " \n"; + if (!is_array($prop['val'])) { + echo " \n"; + } else { // multiple resourcetypes from different namespaces as required by GroupDAV + $vals = $extra_ns = ''; + foreach($prop['val'] as $subprop) + { + if ($subprop['ns'] && $subprop['ns'] != 'DAV:') { + // register property namespace if not known yet + if (!isset($ns_hash[$subprop['ns']])) { + $ns_name = "ns".(count($ns_hash) + 1); + $ns_hash[$subprop['ns']] = $ns_name; + } else { + $ns_name = $ns_hash[$subprop['ns']]; + } + if (strchr($extra_ns,$extra=' xmlns:'.$ns_name.'="'.$subprop['ns'].'"') === false) { + $extra_ns .= $extra; + } + $ns_name .= ':'; + } elseif ($subprop['ns'] == 'DAV:') { + $ns_name = 'D:'; + } else { + $ns_name = ''; + } + $vals .= "<$ns_name$subprop[val]/>"; + } + echo " $vals\n"; + //error_log("resourcetype: $vals"); + } break; case "supportedlock": echo " $prop[val]\n";