diff --git a/addressbook/inc/class.addressbook_groupdav.inc.php b/addressbook/inc/class.addressbook_groupdav.inc.php index e0510f7e5b..4a29cb357b 100644 --- a/addressbook/inc/class.addressbook_groupdav.inc.php +++ b/addressbook/inc/class.addressbook_groupdav.inc.php @@ -101,13 +101,13 @@ class addressbook_groupdav extends groupdav_handler * Handle propfind in the addressbook folder * * @param string $path - * @param array $options + * @param array &$options * @param array &$files * @param int $user account_id * @param string $id='' * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') */ - function propfind($path,$options,&$files,$user,$id='') + function propfind($path,&$options,&$files,$user,$id='') { $filter = array(); // If "Sync selected addressbooks into one" is set diff --git a/calendar/inc/class.calendar_groupdav.inc.php b/calendar/inc/class.calendar_groupdav.inc.php index babf7fcfca..d755520954 100644 --- a/calendar/inc/class.calendar_groupdav.inc.php +++ b/calendar/inc/class.calendar_groupdav.inc.php @@ -127,13 +127,13 @@ class calendar_groupdav extends groupdav_handler * Handle propfind in the calendar folder * * @param string $path - * @param array $options + * @param array &$options * @param array &$files * @param int $user account_id * @param string $id='' * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') */ - function propfind($path,$options,&$files,$user,$id='') + function propfind($path,&$options,&$files,$user,$id='') { if ($this->debug) { diff --git a/infolog/inc/class.infolog_groupdav.inc.php b/infolog/inc/class.infolog_groupdav.inc.php index 6dda0072cd..b7dbdb3a12 100644 --- a/infolog/inc/class.infolog_groupdav.inc.php +++ b/infolog/inc/class.infolog_groupdav.inc.php @@ -137,12 +137,12 @@ class infolog_groupdav extends groupdav_handler * Handle propfind in the infolog folder * * @param string $path - * @param array $options + * @param array &$options * @param array &$files * @param int $user account_id * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') */ - function propfind($path,$options,&$files,$user,$id='') + function propfind($path,&$options,&$files,$user,$id='') { // todo add a filter to limit how far back entries from the past get synced $filter = $this->get_infolog_filter($path, $user); diff --git a/phpgwapi/inc/class.groupdav_handler.inc.php b/phpgwapi/inc/class.groupdav_handler.inc.php index 7566874e3b..7c592ea9ae 100644 --- a/phpgwapi/inc/class.groupdav_handler.inc.php +++ b/phpgwapi/inc/class.groupdav_handler.inc.php @@ -126,12 +126,12 @@ abstract class groupdav_handler * Handle propfind request for an application folder * * @param string $path - * @param array $options + * @param array &$options * @param array &$files * @param int $user account_id * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') */ - abstract function propfind($path,$options,&$files,$user); + abstract function propfind($path,&$options,&$files,$user); /** * Propfind callback, if interator is used diff --git a/phpgwapi/inc/class.groupdav_principals.inc.php b/phpgwapi/inc/class.groupdav_principals.inc.php index fb0ee12884..83d337749e 100644 --- a/phpgwapi/inc/class.groupdav_principals.inc.php +++ b/phpgwapi/inc/class.groupdav_principals.inc.php @@ -62,9 +62,9 @@ class groupdav_principals extends groupdav_handler 'principal-search-property-set' => array( 'method' => 'principal_search_property_set_report', ), - /*'expand-property' => array( - // an other report calendarserver announces - ),*/ + 'expand-property' => array( + 'method' => 'expand_property_report', + ), /* seems only be used 'til OS X 10.6, no longer in 10.7 'addressbook-findshared' => array( 'ns' => groupdav::ADDRESSBOOKSERVER, @@ -100,12 +100,12 @@ class groupdav_principals extends groupdav_handler * Handle propfind request for an application folder * * @param string $path - * @param array $options + * @param array &$options * @param array &$files * @param int $user account_id * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') */ - function propfind($path,$options,&$files,$user) + function propfind($path,&$options,&$files,$user) { if (($report = isset($_GET['report']) ? $_GET['report'] : $options['root']['name']) && $report != 'propfind') { @@ -183,6 +183,101 @@ class groupdav_principals extends groupdav_handler return true; }*/ + /** + * Handle expand-property report + * + * REPORT /egw/groupdav.php/principals/groups/Landesjugendleitung/ HTTP/1.1 + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * @param string $path + * @param array &$options + * @param array &$files + * @param int $user account_id + * @return mixed boolean true on success, false on failure or string with http status (eg. '404 Not Found') + */ + function expand_property_report($path,&$options,&$files,$user) + { + //error_log(__METHOD__."('$path', ".array2string($options).",, $user)"); + + $prop_name = $options['other'][0]['attrs']['name']; + // remove 'expanded-' prefix + if (strpos($prop_name, 'expanded-') === 0) $prop_name = substr($prop_name, 9); + + // run regular propfind for first property with depth=0 + $options['depth'] = '0'; + $options['root']['name'] = 'propfind'; + $options['props'] = array( + 'name' => $prop_name, + 'xmlns' => groupdav::DAV, + ); + $this->groupdav->options = $options; // also modify global variable + if (empty($prop_name) || $this->propfind($path, $options, $files, $user) !== true) + { + $this->groupdav->log('### NO expand-property report for '.$prop_name); + $files = array('files' => array()); + return true; + } + // find prop to expand + foreach($files['files'][0]['props'] as $name => $expand_prop) + { + if ($expand_prop['name'] === $prop_name) break; + } + $files = array('files' => array()); + if ($expand_prop['name'] !== $prop_name || !is_array($expand_prop['val']) || $expand_prop['val'][0]['name'] !== 'href') + { + $this->groupdav->log('### NO expand-property report for '.$prop_name); + return true; + } + // requested properties of each href are in depth=2 properties + // set them as regular propfind properties to $options['props'] + $options['props'] = 'all'; + foreach($options['other'] as $prop) + { + if ($prop['name'] == 'property' && $prop['depth'] == 2) + { + if (!is_array($options['props'])) // is "all" initially + { + $options['props'] = array(); + } + $options['props'][] = array( + 'name' => $prop['attrs']['name'], + 'xmlns' => $prop['attrs']['namespace'], + ); + } + } + $this->groupdav->options = $options; // also modify global variable + + // run regular profind to get requested properties for each href + $expanded = array(); + foreach($expand_prop['val'] as $prop) + { + if ($prop['name'] == 'href') + { + list(,$path) = explode($this->groupdav->base_uri, $prop['val']); + if ($this->propfind($path, $options, $files, $user) !== true || !isset($files['files'][0])) + { + throw new egw_exception_assertion_failed('no propfind for '.$path); + } + $expanded[] = $files['files'][0]; + } + } + $files['files'] = $expanded; + + return true; + } + /** * Handle principal-property-search report *