Final changes to really get iCal working.

This commit is contained in:
Andrew McMillan 2007-11-04 23:10:52 +13:00
parent 6faae5361b
commit 3c3990546a
2 changed files with 17 additions and 6 deletions

View File

@ -100,13 +100,18 @@ class CalDAVPrincipal
}
$script = (preg_match('#/$#', $c->protocol_server_port_script) ? 'caldav.php' : '');
$this->url = sprintf( "%s%s/%s/", $c->protocol_server_port_script, $script, $this->username);
$script = $c->protocol_server_port_script . $script;
if ( preg_match( '/ iCal 3\.0/', $_SERVER['HTTP_USER_AGENT'] ) ) {
$script = preg_replace('#^https?://[^/]+#', '', $script );
}
$this->url = sprintf( "%s/%s/", $script, $this->username);
// $this->url = sprintf( "%s%s/__uuids__/%s/", $c->protocol_server_port_script, $script, $this->username);
$this->calendar_home_set = sprintf( "%s%s/%s/", $c->protocol_server_port_script, $script, $this->username);
$this->calendar_home_set = sprintf( "%s/%s/", $script, $this->username);
$this->user_address_set = array(
sprintf( "%s%s/%s/", $c->protocol_server_port_script, $script, $this->username),
sprintf( "%s/%s/", $script, $this->username),
// sprintf( "%s%s/~%s/", $c->protocol_server_port_script, $script, $this->username),
// sprintf( "%s%s/__uuids__/%s/", $c->protocol_server_port_script, $script, $this->username),
);

View File

@ -216,9 +216,11 @@ function add_principal_properties( &$prop, &$not_found, &$denied ) {
if ( isset($attribute_list['CALENDAR-USER-ADDRESS-SET'] ) ) {
add_namespace("C", "urn:ietf:params:xml:ns:caldav");
$email = new XMLElement('href', 'mailto:'.$request->principal->email );
$calendar = new XMLElement('href', $request->principal->calendar_home_set );
$prop->NewElement("C:calendar-user-address-set", array( $calendar, $email) );
$addr_set = array();
foreach( $request->principal->user_address_set AS $k => $v ) {
$addr_set[] = new XMLElement('href', $v );
}
$prop->NewElement("C:calendar-user-address-set", $addr_set );
}
}
@ -236,6 +238,10 @@ function collection_to_xml( $collection ) {
$url = $c->protocol_server_port_script . $collection->dav_name;
$url = preg_replace( '#^(https?://.+)//#', '$1/', $url ); // Ensure we don't double any '/'
if ( preg_match( '/ iCal 3\.0/', $_SERVER['HTTP_USER_AGENT'] ) ) {
$url = preg_replace('#^https?://[^/]+#', '', $url );
}
$resourcetypes = array( new XMLElement("collection") );
$contentlength = false;