From ff1ff3c3c759e39956e6aa8fcbd2d5a176cd145d Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Mon, 5 Oct 2009 19:17:42 +0200 Subject: [PATCH] Fix browsing and GET. --- framework/Rpc/lib/Horde/Rpc/Webdav.php | 37 +++++++++++----------------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/framework/Rpc/lib/Horde/Rpc/Webdav.php b/framework/Rpc/lib/Horde/Rpc/Webdav.php index 3c502803d..55c7fa97e 100644 --- a/framework/Rpc/lib/Horde/Rpc/Webdav.php +++ b/framework/Rpc/lib/Horde/Rpc/Webdav.php @@ -278,7 +278,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc } else { // Ensure we only retrieve the exact item $options['depth'] = 0; - $result = $this->_list($options); + $result = $this->_list($options, false); if (is_a($result, 'PEAR_Error') && $result->getCode()) { // Allow called applications to set the result code return $this->_checkHTTPCode($result->getCode()) @@ -385,7 +385,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc */ function PROPFIND($options, &$files) { - $list = $this->_list($options); + $list = $this->_list($options, true); if ($list === false || is_a($list, 'PEAR_Error')) { // Always return '404 File Not Found'; // Work around HTTP_WebDAV_Server behavior. @@ -474,14 +474,16 @@ class Horde_Rpc_Webdav extends Horde_Rpc /** * Generates a response to a GET or PROPFIND request. * - * @param array $options Array of WebDAV options + * @param array $options Array of WebDAV options + * @param boolean $propperties Whether to only return properties or actual + * data. * * @return mixed Array of objects with properties if the request is a dir, * array of file metadata + data if request is a file, * false if the object is not found. * @throws Horde_Exception */ - function _list($options) + function _list($options, $properties) { global $registry; @@ -491,23 +493,6 @@ class Horde_Rpc_Webdav extends Horde_Rpc $path = $options['path']; $depth = $options['depth']; - // Collect the requested properties - if (!isset($options['props']) || empty($options['props'])) { - Horde::logMessage(('Invalid or missing properties requested by WebDAV client. Using a default list of properties.'), __FILE__, __LINE__, PEAR_LOG_INFO); - $properties = array('name', 'browseable', 'contenttype', 'contentlength', 'created', 'modified'); - } else { - // Construct an array of properties including the XML namespace - // if not part of the basic DAV namespace. - $properties = array(); - foreach ($options['props'] as $prop) { - if ($prop['xmlns'] == 'DAV:') { - $properties[] = $prop['name']; - } else { - $properties[] = $prop['xmlns'] . ':' . $prop['name']; - } - } - } - // $list will contain the data to return to the client $list = array(); @@ -542,7 +527,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc $pieces = explode('/', $path); try { - $items = $registry->callByPackage($pieces[0], 'browse', array('path' => $path, 'depth' => $options['depth'])); + $items = $registry->callByPackage($pieces[0], 'browse', array('path' => $path, 'properties' => array('name', 'browseable', 'contenttype', 'contentlength', 'created', 'modified'))); } catch (Horde_Exception $e) { Horde::logMessage($e, __FILE__, __LINE__, PEAR_LOG_ERR); return $e; @@ -559,9 +544,11 @@ class Horde_Rpc_Webdav extends Horde_Rpc if (!is_array(reset($items))) { /* A one-dimensional array means we have an actual object with * data to return to the client. */ - $props = $this->_getProps($options['props'], $items); - $items = array(array('path' => $this->path, - 'props' => $props)); + if ($properties) { + $props = $this->_getProps($options['props'], $items); + $items = array(array('path' => $this->path, + 'props' => $props)); + } return $items; } -- 2.11.0