diff --git a/inc/caldav-ACL.php b/inc/caldav-ACL.php index ace42c30..06cc40e8 100644 --- a/inc/caldav-ACL.php +++ b/inc/caldav-ACL.php @@ -104,32 +104,32 @@ $cache_delete_list = array(); $qry = new AwlQuery('BEGIN'); $qry->Exec('ACL',__LINE__,__FILE__); -function process_ace( $grantor, $by_principal, $by_collection, XMLElement $ace ) { +function process_ace( $grantor, $by_principal, $by_collection, $ace ) { global $cache_delete_list, $request; $elements = $ace->GetContent(); $principal_node = $elements[0]; $grant = $elements[1]; - if ( $principal_node->GetTag() != 'DAV::principal' ) $request->MalformedRequest('ACL request must contain a principal, not '.$principal->GetTag()); - $grant_tag = $grant->GetTag(); + if ( $principal_node->GetNSTag() != 'DAV::principal' ) $request->MalformedRequest('ACL request must contain a principal, not '.$principal->GetNSTag()); + $grant_tag = $grant->GetNSTag(); if ( $grant_tag == 'DAV::deny' ) $request->PreconditionFailed(403,'grant-only'); if ( $grant_tag == 'DAV::invert' ) $request->PreconditionFailed(403,'no-invert'); - if ( $grant->GetTag() != 'DAV::grant' ) $request->MalformedRequest('ACL request must contain a principal for each ACE'); + if ( $grant->GetNSTag() != 'DAV::grant' ) $request->MalformedRequest('ACL request must contain a principal for each ACE'); $privilege_names = array(); $xml_privs = $grant->GetPath("/DAV::grant/DAV::privilege/*"); foreach( $xml_privs AS $k => $priv ) { - $privilege_names[] = $priv->GetTag(); + $privilege_names[] = $priv->GetNSTag(); } $privileges = privilege_to_bits($privilege_names); $principal_content = $principal_node->GetContent(); if ( count($principal_content) != 1 ) $request->MalformedRequest('ACL request must contain exactly one principal per ACE'); $principal_content = $principal_content[0]; - switch( $principal_content->GetTag() ) { + switch( $principal_content->GetNSTag() ) { case 'DAV::property': $principal_property = $principal_content->GetContent(); - if ( $principal_property[0]->GetTag() != 'DAV::owner' ) $request->PreconditionFailed(403, 'recognized-principal' ); + if ( $principal_property[0]->GetNSTag() != 'DAV::owner' ) $request->PreconditionFailed(403, 'recognized-principal' ); if ( privilege_to_bits('all') != $privileges ) { $request->PreconditionFailed(403, 'no-protected-ace-conflict', 'Owner must always have all permissions' ); } diff --git a/inc/caldav-MKCOL.php b/inc/caldav-MKCOL.php index 805ed660..ea82aef1 100644 --- a/inc/caldav-MKCOL.php +++ b/inc/caldav-MKCOL.php @@ -54,17 +54,17 @@ if ( isset($request->xml_tags) ) { */ $position = 0; $xmltree = BuildXMLTree( $request->xml_tags, $position); - if ( $xmltree->GetTag() == 'DAV::mkcol' ) $request_type = 'extended-mkcol'; + if ( $xmltree->GetNSTag() == 'DAV::mkcol' ) $request_type = 'extended-mkcol'; - if ( $xmltree->GetTag() != 'urn:ietf:params:xml:ns:caldav:mkcalendar' && $request_type != 'extended-mkcol' ) { - $request->DoResponse( 406, sprintf('The XML is not a "DAV::mkcol" or "urn:ietf:params:xml:ns:caldav:mkcalendar" document (%s)', $xmltree->GetTag()) ); + if ( $xmltree->GetNSTag() != 'urn:ietf:params:xml:ns:caldav:mkcalendar' && $request_type != 'extended-mkcol' ) { + $request->DoResponse( 406, sprintf('The XML is not a "DAV::mkcol" or "urn:ietf:params:xml:ns:caldav:mkcalendar" document (%s)', $xmltree->GetNSTag()) ); } $setprops = $xmltree->GetContent(); // $setprops = $setprops[0]->GetContent(); // $setprops = $setprops[0]->GetContent(); // the array of properties. foreach( $setprops AS $k => $setting ) { - $tag = $setting->GetTag(); + $tag = $setting->GetNSTag(); $content = $setting->RenderContent(); dbg_error_log( 'MKCOL', 'Processing tag "%s"', $tag); @@ -85,7 +85,11 @@ if ( isset($request->xml_tags) ) { } else { $resourcetypes = $setting->GetPath('DAV::resourcetype/*'); - $resourcetypes = str_replace( "\n", "", implode('',$resourcetypes)); + $types = ''; + foreach( $resourcetypes AS $k => $v ) { + $types .= '<'.$v->GetNSTag().'/>'; + } + $resourcetypes = $types; $success[$tag] = 1; } break; diff --git a/inc/caldav-MKTICKET.php b/inc/caldav-MKTICKET.php index ad57c602..2f5717b0 100644 --- a/inc/caldav-MKTICKET.php +++ b/inc/caldav-MKTICKET.php @@ -35,8 +35,8 @@ if ( ! isset($request->xml_tags) ) { } $xmltree = BuildXMLTree( $request->xml_tags, $position); -if ( $xmltree->GetTag() != 'http://www.xythos.com/namespaces/StorageServer:ticketinfo' && - $xmltree->GetTag() != 'DAV::ticketinfo' ) { +if ( $xmltree->GetNSTag() != 'http://www.xythos.com/namespaces/StorageServer:ticketinfo' && + $xmltree->GetNSTag() != 'DAV::ticketinfo' ) { $request->XMLResponse( 400, new XMLElement( 'error', new XMLElement('invalid-xml-for-request'), $reply->GetXmlNsArray() ) ); } @@ -44,7 +44,7 @@ $ticket_timeout = 'Seconds-3600'; $ticket_privs_array = array('read-free-busy'); foreach( $xmltree->GetContent() AS $k => $v ) { // - switch( $v->GetTag() ) { + switch( $v->GetNSTag() ) { case 'DAV::timeout': case 'http://www.xythos.com/namespaces/StorageServer:timeout': $ticket_timeout = $v->GetContent(); @@ -55,7 +55,7 @@ foreach( $xmltree->GetContent() AS $k => $v ) { $ticket_privs_array = $v->GetElements(); // Ensure we always get an array back $ticket_privileges = 0; foreach( $ticket_privs_array AS $k1 => $v1 ) { - $ticket_privileges |= privilege_to_bits( $v1->GetTag() ); + $ticket_privileges |= privilege_to_bits( $v1->GetNSTag() ); } if ( $ticket_privileges & privilege_to_bits('write') ) $ticket_privileges |= privilege_to_bits( 'read' ); if ( $ticket_privileges & privilege_to_bits('read') ) $ticket_privileges |= privilege_to_bits( array('read-free-busy', 'read-current-user-privilege-set') ); diff --git a/inc/caldav-PROPFIND.php b/inc/caldav-PROPFIND.php index d5e053ce..2a040cf7 100644 --- a/inc/caldav-PROPFIND.php +++ b/inc/caldav-PROPFIND.php @@ -31,7 +31,7 @@ else { $allprop = $xmltree->GetPath('/DAV::propfind/*'); $property_list = array(); foreach( $allprop AS $k1 => $propwrap ) { - switch ( $propwrap->GetTag() ) { + switch ( $propwrap->GetNSTag() ) { case 'DAV::allprop': $property_list[] = 'DAV::allprop'; break; @@ -41,7 +41,7 @@ else { default: // prop, include $subprop = $propwrap->GetElements(); foreach( $subprop AS $k => $v ) { - if ( is_object($v) && method_exists($v,'GetTag') ) $property_list[] = $v->GetTag(); + if ( is_object($v) && method_exists($v,'GetTag') ) $property_list[] = $v->GetNSTag(); } } } diff --git a/inc/caldav-REPORT-calquery.php b/inc/caldav-REPORT-calquery.php index 5c01caea..0c7bc2c8 100644 --- a/inc/caldav-REPORT-calquery.php +++ b/inc/caldav-REPORT-calquery.php @@ -31,23 +31,23 @@ $qry_content = $xmltree->GetContent('urn:ietf:params:xml:ns:caldav:calendar-quer $properties = array(); while (list($idx, $qqq) = each($qry_content)) { - $proptype = $qry_content[$idx]->GetTag(); + $proptype = $qry_content[$idx]->GetNSTag(); switch( $proptype ) { case 'DAV::prop': $qry_props = $xmltree->GetPath('/urn:ietf:params:xml:ns:caldav:calendar-query/'.$proptype.'/*'); foreach( $qry_content[$idx]->GetElements() AS $k => $v ) { - $propertyname = preg_replace( '/^.*:/', '', $v->GetTag() ); + $propertyname = $v->GetTag(); $properties[$propertyname] = 1; - if ( $v->GetTag() == 'urn:ietf:params:xml:ns:caldav:calendar-data' ) check_for_expansion($v); + if ( $v->GetNSTag() == 'urn:ietf:params:xml:ns:caldav:calendar-data' ) check_for_expansion($v); } break; case 'DAV::allprop': $properties['allprop'] = 1; - if ( $qry_content[$idx]->GetTag() == 'DAV::include' ) { + if ( $qry_content[$idx]->GetNSTag() == 'DAV::include' ) { foreach( $qry_content[$idx]->GetElements() AS $k => $v ) { - $include_properties[] = $v->GetTag(); /** $include_properties is referenced in DAVResource where allprop is expanded */ - if ( $v->GetTag() == 'urn:ietf:params:xml:ns:caldav:calendar-data' ) check_for_expansion($v); + $include_properties[] = $v->GetNSTag(); /** $include_properties is referenced in DAVResource where allprop is expanded */ + if ( $v->GetNSTag() == 'urn:ietf:params:xml:ns:caldav:calendar-data' ) check_for_expansion($v); } } break; @@ -97,7 +97,7 @@ function SqlFilterFragment( $filter, $components, $property = null, $parameter = } foreach( $filter AS $k => $v ) { - $tag = $v->GetTag(); + $tag = $v->GetNSTag(); dbg_error_log("calquery", "Processing $tag into SQL - %d, '%s', %d\n", count($components), $property, isset($parameter) ); $not_defined = ""; @@ -274,10 +274,10 @@ function SqlFilterFragment( $filter, $components, $property = null, $parameter = */ function BuildSqlFilter( $filter ) { $components = array(); - if ( $filter->GetTag() == "urn:ietf:params:xml:ns:caldav:comp-filter" && $filter->GetAttribute("name") == "VCALENDAR" ) + if ( $filter->GetNSTag() == "urn:ietf:params:xml:ns:caldav:comp-filter" && $filter->GetAttribute("name") == "VCALENDAR" ) $filter = $filter->GetContent(); // Everything is inside a VCALENDAR AFAICS else { - dbg_error_log("calquery", "Got bizarre CALDAV:FILTER[%s=%s]] which does not contain comp-filter = VCALENDAR!!", $filter->GetTag(), $filter->GetAttribute("name") ); + dbg_error_log("calquery", "Got bizarre CALDAV:FILTER[%s=%s]] which does not contain comp-filter = VCALENDAR!!", $filter->GetNSTag(), $filter->GetAttribute("name") ); } return SqlFilterFragment( $filter, $components ); } diff --git a/inc/caldav-REPORT-cardquery.php b/inc/caldav-REPORT-cardquery.php index 4115ecd4..319e6f7c 100644 --- a/inc/caldav-REPORT-cardquery.php +++ b/inc/caldav-REPORT-cardquery.php @@ -17,24 +17,24 @@ function get_address_properties( $address_data_xml ) { * Build the array of properties to include in the report output */ $qry_content = $xmltree->GetContent('urn:ietf:params:xml:ns:carddav:addressbook-query'); -$proptype = $qry_content[0]->GetTag(); +$proptype = $qry_content[0]->GetNSTag(); $properties = array(); switch( $proptype ) { case 'DAV::prop': $qry_props = $xmltree->GetPath('/urn:ietf:params:xml:ns:carddav:addressbook-query/'.$proptype.'/*'); foreach( $qry_content[0]->GetElements() AS $k => $v ) { - $propertyname = preg_replace( '/^.*:/', '', $v->GetTag() ); + $propertyname = preg_replace( '/^.*:/', '', $v->GetNSTag() ); $properties[$propertyname] = 1; - if ( $v->GetTag() == 'urn:ietf:params:xml:ns:carddav:address-data' ) get_address_properties($v); + if ( $v->GetNSTag() == 'urn:ietf:params:xml:ns:carddav:address-data' ) get_address_properties($v); } break; case 'DAV::allprop': $properties['allprop'] = 1; - if ( $qry_content[1]->GetTag() == 'DAV::include' ) { + if ( $qry_content[1]->GetNSTag() == 'DAV::include' ) { foreach( $qry_content[1]->GetElements() AS $k => $v ) { - $include_properties[] = $v->GetTag(); /** $include_properties is referenced in DAVResource where allprop is expanded */ - if ( $v->GetTag() == 'urn:ietf:params:xml:ns:carddav:address-data' ) get_address_properties($v); + $include_properties[] = $v->GetNSTag(); /** $include_properties is referenced in DAVResource where allprop is expanded */ + if ( $v->GetNSTag() == 'urn:ietf:params:xml:ns:carddav:address-data' ) get_address_properties($v); } } break; @@ -90,7 +90,7 @@ function SqlFilterCardDAV( $filter, $components, $property = null, $parameter = } foreach( $filter AS $k => $v ) { - $tag = $v->GetTag(); + $tag = $v->GetNSTag(); dbg_error_log("cardquery", "Processing $tag into SQL - %d, '%s', %d\n", count($components), $property, isset($parameter) ); $not_defined = ""; diff --git a/inc/caldav-REPORT-expand-property.php b/inc/caldav-REPORT-expand-property.php index b72f23b5..53d50e46 100644 --- a/inc/caldav-REPORT-expand-property.php +++ b/inc/caldav-REPORT-expand-property.php @@ -53,8 +53,8 @@ function expand_properties( $urls, $ptree, &$reply, $recurse_again = true ) { foreach( $ptree AS $n => $property ) { if ( ! is_object($property) ) continue; $pname = $property->GetAttribute('name'); - $pns = $property->GetAttribute('namespace'); - if ( !isset($pns) || $pns == '' ) $pns = 'DAV:'; // Not sure if this is the correct way to default this. + $pns = $property->GetNamespace('namespace'); + if ( !isset($pns) || $pns == '' ) $pns = $property->GetNameSpace(); $pname = $pns .':'. $pname; $props[] = $pname; $subtrees[$pname] = $property->GetElements(); @@ -66,10 +66,7 @@ function expand_properties( $urls, $ptree, &$reply, $recurse_again = true ) { if ( isset($href_containers) ) { foreach( $href_containers AS $h => $property ) { $hrefs = $property->GetElements(); - $pname = $property->GetTag(); - $pns = $property->GetAttribute('xmlns'); - if ( !isset($pns) || $pns == '' ) $pns = 'DAV:'; // Not sure if this is the correct way to default this. - $pname = $pns .':'. $pname; + $pname = $property->GetNSTag(); $paths = array(); foreach( $hrefs AS $k => $v ) { $content = $v->GetContent(); diff --git a/inc/caldav-REPORT-multiget.php b/inc/caldav-REPORT-multiget.php index 639ac716..f93d51a0 100644 --- a/inc/caldav-REPORT-multiget.php +++ b/inc/caldav-REPORT-multiget.php @@ -26,24 +26,24 @@ function check_for_expansion( $calendar_data_node ) { * Build the array of properties to include in the report output */ -$proptype = $qry_content[0]->GetTag(); +$proptype = $qry_content[0]->GetNSTag(); $properties = array(); switch( $proptype ) { case 'DAV::prop': $qry_props = $xmltree->GetPath('/*/'.$proptype.'/*'); foreach( $qry_content[0]->GetElements() AS $k => $v ) { - $propertyname = preg_replace( '/^.*:/', '', $v->GetTag() ); + $propertyname = preg_replace( '/^.*:/', '', $v->GetNSTag() ); $properties[$propertyname] = 1; - if ( $v->GetTag() == 'urn:ietf:params:xml:ns:caldav:calendar-data' ) check_for_expansion($v); + if ( $v->GetNSTag() == 'urn:ietf:params:xml:ns:caldav:calendar-data' ) check_for_expansion($v); } break; case 'DAV::allprop': $properties['allprop'] = 1; - if ( $qry_content[1]->GetTag() == 'DAV::include' ) { + if ( $qry_content[1]->GetNSTag() == 'DAV::include' ) { foreach( $qry_content[1]->GetElements() AS $k => $v ) { - $include_properties[] = $v->GetTag(); /** $include_properties is referenced in DAVResource where allprop is expanded */ - if ( $v->GetTag() == 'urn:ietf:params:xml:ns:caldav:calendar-data' ) check_for_expansion($v); + $include_properties[] = $v->GetNSTag(); /** $include_properties is referenced in DAVResource where allprop is expanded */ + if ( $v->GetNSTag() == 'urn:ietf:params:xml:ns:caldav:calendar-data' ) check_for_expansion($v); } } break; diff --git a/inc/caldav-REPORT-principal-match.php b/inc/caldav-REPORT-principal-match.php index e86d4918..40310899 100644 --- a/inc/caldav-REPORT-principal-match.php +++ b/inc/caldav-REPORT-principal-match.php @@ -42,7 +42,7 @@ $qry = new AwlQuery($sql, $params); $get_props = $xmltree->GetPath('/DAV::principal-match/DAV::prop/*'); $properties = array(); foreach( $get_props AS $k1 => $v1 ) { - $properties[] = $v1->GetTag(); + $properties[] = $v1->GetNSTag(); } if ( $qry->Exec("REPORT",__LINE__,__FILE__) && $qry->rows() > 0 ) { diff --git a/inc/caldav-REPORT-principal.php b/inc/caldav-REPORT-principal.php index 3f6a4164..7cee9ccf 100644 --- a/inc/caldav-REPORT-principal.php +++ b/inc/caldav-REPORT-principal.php @@ -25,7 +25,7 @@ foreach( $searches AS $k => $search ) { $subwhere = ""; foreach( $qry_props AS $k1 => $v1 ) { if ( $subwhere != "" ) $subwhere .= " OR "; - switch( $v1->GetTag() ) { + switch( $v1->GetNSTag() ) { case 'DAV::displayname': $subwhere .= ' displayname ILIKE :displayname_match '; $params[':displayname_match'] = '%'.$match.'%'; @@ -49,7 +49,7 @@ foreach( $searches AS $k => $search ) { * @todo We should handle a lot more properties here. principal-URL seems a likely one to be used. * @todo We should catch the unsupported properties in the query and fire back an error indicating so. */ - dbg_error_log("principal", "Unhandled tag '%s' to match '%s'\n", $v1->GetTag(), $match ); + dbg_error_log("principal", "Unhandled tag '%s' to match '%s'\n", $v1->GetNSTag(), $match ); } } if ( $subwhere != "" ) { @@ -64,7 +64,7 @@ $qry = new AwlQuery($sql, $params); $get_props = $xmltree->GetPath('/DAV::principal-property-search/DAV::prop/*'); $properties = array(); foreach( $get_props AS $k1 => $v1 ) { - $properties[] = $v1->GetTag(); + $properties[] = $v1->GetNSTag(); } if ( $qry->Exec("REPORT",__LINE__,__FILE__) && $qry->rows() > 0 ) { diff --git a/inc/caldav-REPORT-sync-collection.php b/inc/caldav-REPORT-sync-collection.php index d1201721..f5ddced9 100644 --- a/inc/caldav-REPORT-sync-collection.php +++ b/inc/caldav-REPORT-sync-collection.php @@ -42,7 +42,7 @@ $v = $props[0]; $props = $v->GetContent(); $proplist = array(); foreach( $props AS $k => $v ) { - $proplist[] = $v->GetTag(); + $proplist[] = $v->GetNSTag(); } function display_status( $status_code ) { diff --git a/inc/caldav-REPORT.php b/inc/caldav-REPORT.php index 1da78f1f..f7dd4891 100644 --- a/inc/caldav-REPORT.php +++ b/inc/caldav-REPORT.php @@ -34,8 +34,8 @@ if ( !is_object($xmltree) ) { $target = new DAVResource($request->path); -if ( $xmltree->GetTag() != 'DAV::principal-property-search' - && $xmltree->GetTag() != 'DAV::principal-property-search-set' ) { +if ( $xmltree->GetNSTag() != 'DAV::principal-property-search' + && $xmltree->GetNSTag() != 'DAV::principal-property-search-set' ) { $target->NeedPrivilege( array('DAV::read', 'urn:ietf:params:xml:ns:caldav:read-free-busy'), true ); // They may have either } @@ -47,13 +47,13 @@ $denied = array(); $unsupported = array(); if ( isset($prop_filter) ) unset($prop_filter); -if ( $xmltree->GetTag() == 'urn:ietf:params:xml:ns:caldav:free-busy-query' ) { +if ( $xmltree->GetNSTag() == 'urn:ietf:params:xml:ns:caldav:free-busy-query' ) { include("caldav-REPORT-freebusy.php"); exit; // Not that the above include should return anyway } $reply = new XMLDocument( array( "DAV:" => "" ) ); -switch( $xmltree->GetTag() ) { +switch( $xmltree->GetNSTag() ) { case 'DAV::principal-property-search': include("caldav-REPORT-principal.php"); exit; // Not that it should return anyway. @@ -219,26 +219,26 @@ if ( $target->IsExternal() ) { update_external ( $target ); } -if ( $xmltree->GetTag() == "urn:ietf:params:xml:ns:caldav:calendar-query" ) { +if ( $xmltree->GetNSTag() == "urn:ietf:params:xml:ns:caldav:calendar-query" ) { $calquery = $xmltree->GetPath("/urn:ietf:params:xml:ns:caldav:calendar-query/*"); include("caldav-REPORT-calquery.php"); } -elseif ( $xmltree->GetTag() == "urn:ietf:params:xml:ns:caldav:calendar-multiget" ) { +elseif ( $xmltree->GetNSTag() == "urn:ietf:params:xml:ns:caldav:calendar-multiget" ) { $mode = 'caldav'; $qry_content = $xmltree->GetContent('urn:ietf:params:xml:ns:caldav:calendar-multiget'); include("caldav-REPORT-multiget.php"); } -elseif ( $xmltree->GetTag() == "urn:ietf:params:xml:ns:carddav:addressbook-multiget" ) { +elseif ( $xmltree->GetNSTag() == "urn:ietf:params:xml:ns:carddav:addressbook-multiget" ) { $mode = 'carddav'; $qry_content = $xmltree->GetContent('urn:ietf:params:xml:ns:carddav:addressbook-multiget'); include("caldav-REPORT-multiget.php"); } -elseif ( $xmltree->GetTag() == "urn:ietf:params:xml:ns:carddav:addressbook-query" ) { +elseif ( $xmltree->GetNSTag() == "urn:ietf:params:xml:ns:carddav:addressbook-query" ) { $cardquery = $xmltree->GetPath("/urn:ietf:params:xml:ns:carddav:addressbook-query/*"); include("caldav-REPORT-cardquery.php"); } else { - dbg_error_log( 'ERROR', "Request for unsupported report type '%s'.", $xmltree->GetTag() ); - $request->PreconditionFailed( 403, 'DAV::supported-report', sprintf( '"%s" is not a supported report type', $xmltree->GetTag()) ); + dbg_error_log( 'ERROR', "Request for unsupported report type '%s'.", $xmltree->GetNSTag() ); + $request->PreconditionFailed( 403, 'DAV::supported-report', sprintf( '"%s" is not a supported report type', $xmltree->GetNSTag()) ); }