From 0601d40bd39aef42b709cba3af9df1af6a68a501 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 24 Sep 2013 12:29:17 +0000 Subject: [PATCH] fix Prefer header to use return=(minimal|representation) instead of older draft dash, enable add-member property, and add Location header to action=attachment-add --- phpgwapi/inc/class.groupdav.inc.php | 30 ++++++++++++++------- phpgwapi/inc/class.groupdav_handler.inc.php | 2 +- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/phpgwapi/inc/class.groupdav.inc.php b/phpgwapi/inc/class.groupdav.inc.php index 1b4009c759..99b0d26111 100644 --- a/phpgwapi/inc/class.groupdav.inc.php +++ b/phpgwapi/inc/class.groupdav.inc.php @@ -835,11 +835,11 @@ class groupdav extends HTTP_WebDAV_Server } // rfc 5995 (Use POST to add members to WebDAV collections): we use collection path with add-member query param - /* leaving it switched off, until further testing, because OS X iCal seem to ignore it and OS X Addressbook uses POST to full URL without ?add-member + // leaving it switched off, until further testing, because OS X iCal seem to ignore it and OS X Addressbook uses POST to full URL without ?add-member if ($app && !in_array($app,array('inbox','outbox','principals'))) // not on inbox, outbox or principals { $props['add-member'][] = self::mkprop('href',$this->base_uri.$path.'?add-member'); - }*/ + } // add props modifyable via proppatch from client, eg. calendar-color, see self::$proppatch_props foreach((array)$GLOBALS['egw_info']['user']['preferences'][$app] as $name => $value) @@ -1268,6 +1268,7 @@ class groupdav extends HTTP_WebDAV_Server error_log(__METHOD__."() content-type=$options[content_type], filename=$filename: $path created $copied bytes copied"); $ret = '201 Created'; header(self::MANAGED_ID_HEADER.': '.self::path2managed_id($path)); + header('Location: '.self::path2location($path)); break; case 'attachment-remove': @@ -1422,14 +1423,12 @@ class groupdav extends HTTP_WebDAV_Server } /** - * Add ATTACH attribute(s) for iCal + * Get attachment location from path * - * @param string $app eg. 'calendar' - * @param int|string $id - * @param array &$attributes - * @param array &$parameters + * @param string $path + * @return string */ - public static function add_attach($app, $id, array &$attributes, array &$parameters) + protected static function path2location($path) { static $url_prefix; if (!isset($url_prefix)) @@ -1440,12 +1439,25 @@ class groupdav extends HTTP_WebDAV_Server $url_prefix = ($_SERVER['HTTPS'] ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST']; } } + return $url_prefix.egw::link(egw_vfs::download_url($path)); + } + + /** + * Add ATTACH attribute(s) for iCal + * + * @param string $app eg. 'calendar' + * @param int|string $id + * @param array &$attributes + * @param array &$parameters + */ + public static function add_attach($app, $id, array &$attributes, array &$parameters) + { foreach(egw_vfs::find(egw_link::vfs_path($app, $id, '', true), array( 'type' => 'F', 'need_mime' => true, ), true) as $path => $stat) { - $attributes['ATTACH'][] = $url_prefix.egw::link(egw_vfs::download_url($path)); + $attributes['ATTACH'][] = self::path2location($path); $parameters['ATTACH'][] = array( 'MANAGED-ID' => groupdav::path2managed_id($path), 'FMTTYP' => $stat['mime'], diff --git a/phpgwapi/inc/class.groupdav_handler.inc.php b/phpgwapi/inc/class.groupdav_handler.inc.php index 7d261ce615..1688453c67 100644 --- a/phpgwapi/inc/class.groupdav_handler.inc.php +++ b/phpgwapi/inc/class.groupdav_handler.inc.php @@ -344,7 +344,7 @@ abstract class groupdav_handler */ public function check_return_representation($options, $id, $user=null) { - if (isset($_SERVER['HTTP_PREFER']) && in_array('return-representation', explode(',', $_SERVER['HTTP_PREFER']))) + if (isset($_SERVER['HTTP_PREFER']) && in_array('return=representation', explode(',', $_SERVER['HTTP_PREFER']))) { if ($_SERVER['REQUEST_METHOD'] == 'POST') {