8function get_href_containers( &$multistatus_response ) {
9 $propstat_set = $multistatus_response->GetElements(
'DAV::propstat');
11 foreach( $propstat_set AS $k => $v ) {
12 $status = $v->GetElements(
'DAV::status');
13 if ( preg_match(
'{^HTTP/\S+\s+200}', $status[0]->GetContent() ) ) {
18 if ( isset($propstat_200) ) {
19 $props = $propstat_200->GetElements(
'DAV::prop');
20 $properties = array();
21 foreach( $props AS $k => $p ) {
22 $properties = array_merge($properties,$p->GetElements());
24 $href_containers = array();
25 foreach( $properties AS $k => $property ) {
26 if ( !is_object($property) )
continue;
28 $hrefs = $property->GetElements(
'DAV::href');
29 if ( count($hrefs) > 0 ) {
30 $href_containers[] = $property;
33 if ( count($href_containers) > 0 ) {
34 return $href_containers;
44function expand_properties( $urls, $ptree, &$reply, $recurse_again =
true ) {
45 if ( !is_array($urls) ) $urls = array($urls);
46 if ( !is_array($ptree) ) $ptree = array($ptree);
49 foreach( $urls AS $m => $url ) {
53 foreach( $ptree AS $n => $property ) {
54 if ( ! is_object($property) )
continue;
55 $pname = $property->GetAttribute(
'name');
56 $pns = $property->GetAttribute(
'namespace');
57 if ( empty($pns) ) $pns = $property->GetAttribute(
'xmlns');
58 if ( empty($pns) ) $pns = $reply->DefaultNamespace();
59 $pname = (empty($pns)?
'':$pns .
':'). $pname;
61 $subtrees[$pname] = $property->GetElements();
63 $part_response = $resource->RenderAsXML( $props, $reply );
64 if ( isset($part_response) ) {
65 if ( $recurse_again ) {
66 $href_containers = get_href_containers($part_response);
67 if ( isset($href_containers) ) {
68 foreach( $href_containers AS $h => $property ) {
69 $hrefs = $property->GetElements();
70 $pname = $property->GetNSTag();
72 foreach( $hrefs AS $k => $v ) {
73 $content = $v->GetContent();
75 if($content[0]==
'/' && $content!=
'/caldav.php'.str_replace(
'%2F',
'/', rawurlencode($url)))
79 $property->SetContent( expand_properties($paths, $subtrees[$pname], $reply,
false) );
86 $responses[] = $part_response;
97$property_tree = $xmltree->GetPath(
'/DAV::expand-property/DAV::property');
99$multistatus =
new XMLElement(
"multistatus", expand_properties( $request->path, $property_tree, $reply), $reply->GetXmlNsArray() );
101$request->XMLResponse( 207, $multistatus );