Overview

Packages

  • awl
    • caldav-client-v2
    • RRule
  • davical
    • authentication
      • drivers
    • caldav
    • DAViCalSession
    • DAVTicket
    • external-bind
    • feed
    • HTTPAuthSession
    • iSchedule
    • iSchedule-POST
    • logging
    • metrics
    • Principal
    • propfind
    • PublicSession
    • Request
    • Resource
    • tzservice
  • None
  • PHP

Classes

  • CalDAVClient
  • CheckResult
  • setupFakeSession
  • VCard
  • VTimezone

Functions

  • access_ticket_browser
  • binding_row_editor
  • bindings_to_other_browser
  • bindings_to_us_browser
  • build_dependencies_table
  • build_privileges_html
  • build_site_statistics
  • BuildSqlFilter
  • calquery_apply_filter
  • cardquery_apply_filter
  • catch_setup_errors
  • check_awl_version
  • check_calendar
  • check_curl
  • check_database_connection
  • check_datetime
  • check_davical_version
  • check_gettext
  • check_iconv
  • check_ldap
  • check_magic_quotes_gpc
  • check_magic_quotes_runtime
  • check_pdo
  • check_pdo_pgsql
  • check_pgsql
  • check_real_php
  • check_schema_version
  • check_string
  • check_suhosin_server_strip
  • check_xml
  • collection_privilege_format_function
  • confirm_delete_bind_in
  • confirm_delete_binding
  • confirm_delete_collection
  • confirm_delete_principal
  • confirm_delete_ticket
  • do_error
  • edit_binding_row
  • edit_grant_row_collection
  • edit_grant_row_principal
  • edit_group_row
  • edit_ticket_row
  • errorResponse
  • expand_properties
  • fetch_external
  • get_address_properties
  • get_freebusy
  • get_href_containers
  • get_phpinfo
  • grant_row_editor
  • group_members_browser
  • group_memberships_browser
  • group_row_editor
  • handle_subaction
  • i18n
  • ischedule_get
  • log_setup_error
  • make_help_link
  • principal_collection_browser
  • principal_editor
  • principal_grants_browser
  • principal_privilege_format_function
  • send_page_header
  • SqlFilterCardDAV
  • SqlFilterFragment
  • ticket_row_editor
  • unicodeToUtf8
  • update_external
  • utf8ToUnicode
  • Overview
  • Package
  • Function
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: 
  3: /**
  4: * Given a <response><href>...</href><propstat><prop><someprop/></prop><status>HTTP/1.1 200 OK</status></propstat>...</response>
  5: * pull out the content of <someprop>content</someprop> and check to see if it has any href elements.  If it *does* then
  6: * recurse into them, looking for the next deeper nesting of properties.
  7: */
  8: function get_href_containers( &$multistatus_response ) {
  9:   $propstat_set = $multistatus_response->GetElements('DAV::propstat');
 10:   $propstat_200 = null;
 11:   foreach( $propstat_set AS $k => $v ) {
 12:     $status = $v->GetElements('DAV::status');
 13:     if ( preg_match( '{^HTTP/\S+\s+200}', $status[0]->GetContent() ) ) {
 14:       $propstat_200 = $v;
 15:       break;
 16:     }
 17:   }
 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());
 23:     }
 24:     $href_containers = array();
 25:     foreach( $properties AS $k => $property ) {
 26:       if ( !is_object($property) ) continue;
 27: //      dbg_error_log('REPORT',' get_href_containers: Checking property "%s" for hrefs.', $property->GetNSTag() );
 28:       $hrefs = $property->GetElements('DAV::href');
 29:       if ( count($hrefs) > 0 ) {
 30:         $href_containers[] = $property;
 31:       }
 32:     }
 33:     if ( count($href_containers) > 0 ) {
 34:       return $href_containers;
 35:     }
 36:   }
 37:   return null;
 38: }
 39: 
 40: 
 41: /**
 42: * Expand the properties, recursing only once
 43: */
 44: function expand_properties( $urls, $ptree, &$reply, $recurse_again = true ) {
 45:   if ( !is_array($urls) )  $urls = array($urls);
 46:   if ( !is_array($ptree) ) $ptree = array($ptree);
 47: 
 48:   $responses = array();
 49:   foreach( $urls AS $m => $url ) {
 50:     $resource = new DAVResource($url);
 51:     $props = array();
 52:     $subtrees = array();
 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;
 60:       $props[] = $pname;
 61:       $subtrees[$pname] = $property->GetElements();
 62:     }
 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();
 71:             $paths = array();
 72:             foreach( $hrefs AS $k => $v ) {
 73:               $content = $v->GetContent();
 74:               // prevent infinite recursion and recursion to the object itself (non-recursive getting request URL properties)
 75:               if($content[0]=='/' && $content!='/caldav.php'.str_replace( '%2F', '/', rawurlencode($url)))
 76:                 $paths[] = $content;
 77:             }
 78:             //            dbg_error_log('REPORT',' Found property "%s" contains hrefs "%s"', $pname, implode(', ',$paths) );
 79:             $property->SetContent( expand_properties($paths, $subtrees[$pname], $reply, false) );
 80:           }
 81:         }
 82: //      else {
 83: //        dbg_error_log('REPORT',' No href containers in response to "%s"', implode(', ', $props ) );
 84: //      }
 85:       }
 86:       $responses[] = $part_response;
 87:     }
 88:   }
 89: 
 90:   return $responses;
 91: }
 92: 
 93: 
 94: /**
 95:  * Build the array of properties to include in the report output
 96:  */
 97: $property_tree = $xmltree->GetPath('/DAV::expand-property/DAV::property');
 98: 
 99: $multistatus = new XMLElement( "multistatus", expand_properties( $request->path, $property_tree, $reply), $reply->GetXmlNsArray() );
100: 
101: $request->XMLResponse( 207, $multistatus );
102: 
DAViCal API documentation generated by ApiGen 2.8.0