Fix brokenness after getting rid of crappy halfway namespaced tag handling.

This commit is contained in:
Andrew McMillan 2008-11-12 22:55:53 +13:00
parent 7ce12290cc
commit 964d0a1224
4 changed files with 34 additions and 43 deletions

View File

@ -288,7 +288,7 @@ class CalDAVPrincipal
case 'DAV::group-member-set':
$set = array();
foreach( $this->group_member_set AS $k => $url ) {
$set[] = new XMLElement('href', $url );
$set[] = $reply->href($url );
}
$prop->NewElement("group-member-set", $set );
break;
@ -296,41 +296,41 @@ class CalDAVPrincipal
case 'DAV::group-membership':
$set = array();
foreach( $this->group_membership AS $k => $url ) {
$set[] = new XMLElement('href', $url );
$set[] = $reply->href($url );
}
$prop->NewElement("group-membership", $set );
break;
case 'urn:ietf:params:xml:ns:caldav:schedule-inbox-URL':
$prop->NewElement($reply->Caldav("schedule-inbox-URL"), new XMLElement('href', $this->schedule_inbox_url) );
$reply->CalDAVElement($prop, "schedule-inbox-URL", $reply->href($this->schedule_inbox_url) );
break;
case 'urn:ietf:params:xml:ns:caldav:schedule-outbox-URL':
$prop->NewElement($reply->Caldav("schedule-outbox-URL"), new XMLElement('href', $this->schedule_outbox_url) );
$reply->CalDAVElement($prop, "schedule-outbox-URL", $reply->href($this->schedule_outbox_url) );
break;
case 'http://calendarserver.org/ns/:dropbox-home-URL':
$prop->NewElement($reply->Calendarserver("dropbox-home-URL"), new XMLElement('href', $this->dropbox_url) );
$reply->CalendarserverElement($prop, "dropbox-home-URL", $reply->href($this->dropbox_url) );
break;
case 'http://calendarserver.org/ns/:notifications-URL':
$prop->NewElement($reply->Calendarserver("notifications-URL"), new XMLElement('href', $this->notifications_url) );
$reply->CalendarserverElement($prop, "notifications-URL", $reply->href($this->notifications_url) );
break;
case 'urn:ietf:params:xml:ns:caldav:calendar-home-set':
$set = array();
foreach( $this->calendar_home_set AS $k => $url ) {
$set[] = new XMLElement('href', $url );
$set[] = $reply->href( $url );
}
$prop->NewElement($reply->Caldav("calendar-home-set"), $set );
$reply->CalDAVElement($prop, "calendar-home-set", $set );
break;
case 'urn:ietf:params:xml:ns:caldav:calendar-user-address-set':
$set = array();
foreach( $this->user_address_set AS $k => $v ) {
$set[] = new XMLElement('href', $v );
$set[] = $reply->href($v );
}
$prop->NewElement($reply->Caldav("calendar-user-address-set"), $set );
$reply->CalDAVElement($prop, "calendar-user-address-set", $set );
break;
case 'DAV::getcontentlanguage':
@ -391,7 +391,7 @@ class CalDAVPrincipal
$status = new XMLElement("status", "HTTP/1.1 200 OK" );
$propstat = new XMLElement( "propstat", array( $prop, $status) );
$href = new XMLElement("href", $this->url );
$href = $reply->href($this->url );
$elements = array($href,$propstat);

View File

@ -58,19 +58,19 @@ function handle_freebusy_request( $ic ) {
$qry = new PgQuery("SELECT get_permissions(?,user_no) AS p FROM usr WHERE usr.email = ?", $session->user_no, $attendee_email );
if ( !$qry->Exec("POST") ) $request->DoResponse( 501, 'Database error');
$response = new XMLElement( $reply->Caldav("response") );
$response->NewElement( $reply->Caldav("recipient"), new XMLElement("href",$attendee->Value()) );
$response = $reply->NewXMLElement("response", false, false, 'urn:ietf:params:xml:ns:caldav');
$reply->CalDAVElement($response, "recipient", $reply->href($attendee->Value()) );
if ( $qry->rows == 0 ) {
$response->NewElement( $reply->Caldav("request-status"), "3.7;Invalid Calendar User" );
$response->NewElement( $reply->Caldav("calendar-data") );
$reply->CalDAVElement($response, "request-status", "3.7;Invalid Calendar User" );
$reply->CalDAVElement($response, "calendar-data" );
$responses[] = $response;
continue;
}
if ( ! $userperms = $qry->Fetch() ) $request->DoResponse( 501, 'Database error');
if ( !preg_match( '/[AWRF]/', $userperms->p ) ) {
$response->NewElement( $reply->Caldav("request-status"), "3.8;No authority" );
$response->NewElement( $reply->Caldav("calendar-data") );
$reply->CalDAVElement($response, "request-status", "3.8;No authority" );
$reply->CalDAVElement($response, "calendar-data" );
$responses[] = $response;
continue;
}
@ -178,14 +178,14 @@ function handle_freebusy_request( $ic ) {
$vcal->VCalendar( array('METHOD' => 'REPLY') );
$vcal->AddComponent( $fb );
$response = new XMLElement( $reply->Caldav("response") );
$response->NewElement( $reply->Caldav("recipient"), new XMLElement("href",$attendee->Value()) );
$response->NewElement( $reply->Caldav("request-status"), "2.0;Success" ); // Cargo-cult setting
$response->NewElement( $reply->Caldav("calendar-data"), $vcal->Render() );
$response = $reply->NewXMLElement( "response", false, false, 'urn:ietf:params:xml:ns:caldav' );
$reply->CalDAVElement($response, "recipient", $reply->href($attendee->Value()) );
$reply->CalDAVElement($response, "request-status", "2.0;Success" ); // Cargo-cult setting
$reply->CalDAVElement($response, "calendar-data", $vcal->Render() );
$responses[] = $response;
}
$response = new XMLElement( "schedule-response", $responses, $reply->GetXmlNsArray() );
$response = $reply->NewXMLElement( "schedule-response", $responses, $reply->GetXmlNsArray() );
$request->XMLResponse( 200, $response );
}

View File

@ -132,15 +132,6 @@ foreach( $request->xml_tags AS $k => $v ) {
}
/**
* Return an href XML element
*/
function href($url) {
global $reply;
return $reply->NewXMLElement('href', $url, false, 'DAV:');
}
/**
* Returns the array of privilege names converted into XMLElements
*/
@ -186,7 +177,7 @@ function add_principal_properties( &$prop, &$denied ) {
$allprop = isset($prop_list['DAV::allprop']);
if ( isset($prop_list['DAV::principal-URL'] ) ) {
$reply->DAVElement( $prop, "principal-URL", href( $request->principal->url ) );
$reply->DAVElement( $prop, "principal-URL", $reply->href( $request->principal->url ) );
}
if ( isset($prop_list['DAV::alternate-URI-set'] ) ) {
$reply->DAVElement( $prop, "alternate-URI-set" ); // Empty - there are no alternatives!
@ -196,29 +187,29 @@ function add_principal_properties( &$prop, &$denied ) {
$home_set = array();
$chs = $request->principal->calendar_home_set;
foreach( $chs AS $k => $url ) {
$home_set[] = href( $url );
$home_set[] = $reply->href( $url );
}
$reply->CalDAVElement( $prop, "calendar-home-set", $home_set );
}
if ( isset($prop_list['urn:ietf:params:xml:ns:caldav:schedule-inbox-URL'] ) ) {
$reply->CalDAVElement( $prop, "schedule-inbox-URL", href( $request->principal->schedule_inbox_url) );
$reply->CalDAVElement( $prop, "schedule-inbox-URL", $reply->href( $request->principal->schedule_inbox_url) );
}
if ( isset($prop_list['urn:ietf:params:xml:ns:caldav:schedule-outbox-URL'] ) ) {
$reply->CalDAVElement( $prop, "schedule-outbox-URL", href( $request->principal->schedule_outbox_url) );
$reply->CalDAVElement( $prop, "schedule-outbox-URL", $reply->href( $request->principal->schedule_outbox_url) );
}
if ( isset($prop_list['http://calendarserver.org/ns/:dropbox-home-URL'] ) ) {
$reply->CalendarserverElement($prop, "dropbox-home-URL", href( $request->principal->dropbox_url) );
$reply->CalendarserverElement($prop, "dropbox-home-URL", $reply->href( $request->principal->dropbox_url) );
}
if ( isset($prop_list['http://calendarserver.org/ns/:notifications-URL'] ) ) {
$reply->CalendarserverElement($prop, "notifications-URL", href( $request->principal->notifications_url) );
$reply->CalendarserverElement($prop, "notifications-URL", $reply->href( $request->principal->notifications_url) );
}
if ( isset($prop_list['urn:ietf:params:xml:ns:caldav:calendar-user-address-set'] ) ) {
$addr_set = array();
$uas = $request->principal->user_address_set;
foreach( $uas AS $k => $v ) {
$addr_set[] = href( $v );
$addr_set[] = $reply->href( $v );
}
$reply->CalDAVElement( $prop, "calendar-user-address-set", $addr_set );
}
@ -245,10 +236,10 @@ function add_general_properties( &$prop, &$denied, $record ) {
if ( isset($prop_list['DAV::owner']) ) {
// After a careful reading of RFC3744 we see that this must be the principal-URL of the owner
$reply->DAVElement( $prop, "owner", href( $request->principal->url ) );
$reply->DAVElement( $prop, "owner", $reply->href( $request->principal->url ) );
}
if ( isset($prop_list['DAV::principal-collection-set']) ) {
$reply->DAVElement( $prop, "principal-collection-set", href( ConstructURL('/') ) );
$reply->DAVElement( $prop, "principal-collection-set", $reply->href( ConstructURL('/') ) );
}
if ( isset($prop_list['DAV::current-user-principal']) ) {
$reply->DAVElement( $prop, "current-user-principal", $request->current_user_principal_xml);
@ -296,7 +287,7 @@ function add_general_properties( &$prop, &$denied, $record ) {
function build_propstat_response( $prop, $denied, $url ) {
global $reply, $arbitrary, $prop_list;
$response = array( href($url),
$response = array( $reply->href($url),
$reply->NewXMLElement( "propstat", array( $prop,
$reply->NewXMLElement("status", "HTTP/1.1 200 OK" )
)
@ -423,7 +414,7 @@ function collection_to_xml( $collection ) {
if ( $collection->type == 'in' && $session->user_no == $collection->user_no ) {
$fb_set = array();
foreach( $request->principal->calendar_free_busy_set AS $k => $v ) {
$fb_set[] = href( $v, false, "DAV:" );
$fb_set[] = $reply->href( $v, false, "DAV:" );
}
$reply->CalDAVElement( $prop, "calendar-free-busy-set", $fb_set );
}

View File

@ -123,7 +123,7 @@ function calendar_to_xml( $properties, $item ) {
$prop->NewElement($k, $contentlength );
break;
case 'calendar-data':
$prop->NewElement($reply->Caldav($k), $caldav_data );
$reply->CalDAVElement($prop, $k, $caldav_data );
break;
case 'getcontenttype':
$prop->NewElement($k, "text/calendar" );