mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-05-25 02:34:17 +00:00
Almost entirely switched to root-relative URLs now.
This commit is contained in:
parent
96e579910b
commit
2cacc8aa1c
@ -99,21 +99,15 @@ class CalDAVPrincipal
|
|||||||
$this->{$k} = $v;
|
$this->{$k} = $v;
|
||||||
}
|
}
|
||||||
|
|
||||||
$script = (preg_match('#/$#', $c->protocol_server_port_script) ? 'caldav.php' : '');
|
$this->url = ConstructURL( "/".$this->username."/" );
|
||||||
$script = $c->protocol_server_port_script . $script;
|
// $this->url = ConstructURL( "/__uuids__/" . $this->username . "/" );
|
||||||
if ( preg_match( '/ iCal 3\.0/', $_SERVER['HTTP_USER_AGENT'] ) ) {
|
|
||||||
$script = preg_replace('#^https?://[^/]+#', '', $script );
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->url = sprintf( "%s/%s/", $script, $this->username);
|
$this->calendar_home_set = ConstructURL( "/".$this->username."/" );
|
||||||
// $this->url = sprintf( "%s%s/__uuids__/%s/", $c->protocol_server_port_script, $script, $this->username);
|
|
||||||
|
|
||||||
$this->calendar_home_set = sprintf( "%s/%s/", $script, $this->username);
|
|
||||||
|
|
||||||
$this->user_address_set = array(
|
$this->user_address_set = array(
|
||||||
sprintf( "%s/%s/", $script, $this->username),
|
ConstructURL( "/".$this->username."/" ),
|
||||||
// sprintf( "%s%s/~%s/", $c->protocol_server_port_script, $script, $this->username),
|
// ConstructURL( "/~".$this->username."/" ),
|
||||||
// sprintf( "%s%s/__uuids__/%s/", $c->protocol_server_port_script, $script, $this->username),
|
// ConstructURL( "/__uuids__/".$this->username."/" ),
|
||||||
);
|
);
|
||||||
$this->schedule_inbox_url = sprintf( "%s.in/", $this->calendar_home_set);
|
$this->schedule_inbox_url = sprintf( "%s.in/", $this->calendar_home_set);
|
||||||
$this->schedule_outbox_url = sprintf( "%s.out/", $this->calendar_home_set);
|
$this->schedule_outbox_url = sprintf( "%s.out/", $this->calendar_home_set);
|
||||||
|
|||||||
@ -72,15 +72,6 @@ class CalDAVRequest
|
|||||||
|
|
||||||
$this->user_agent = ((isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : "Probably Mulberry"));
|
$this->user_agent = ((isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : "Probably Mulberry"));
|
||||||
|
|
||||||
/**
|
|
||||||
* In general we systematically return Absolute URI hrefs. Unfortunately some
|
|
||||||
* software doesn't expect this to happen (iCal, SOHO Organizer, ???) and so we
|
|
||||||
* need to hack around these programs. RFC4918 section 8.3 gives details.
|
|
||||||
*/
|
|
||||||
if ( preg_match( '/(iCal 3.0|SOHO Organizer|ChronosCalendarsService)/', $this->user_agent ) ) {
|
|
||||||
$c->protocol_server_port_script = preg_replace('#^(http|caldav)s?://[^/]+#', '', $c->protocol_server_port_script );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A variety of requests may set the "Depth" header to control recursion
|
* A variety of requests may set the "Depth" header to control recursion
|
||||||
*/
|
*/
|
||||||
@ -254,20 +245,6 @@ class CalDAVRequest
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct a URL from the supplied dav_name
|
|
||||||
* @param string $partial_path The part of the path after the script name
|
|
||||||
*/
|
|
||||||
function ConstructURL( $partial_path ) {
|
|
||||||
global $c;
|
|
||||||
|
|
||||||
$url = $c->protocol_server_port_script . $partial_path;
|
|
||||||
$url = preg_replace( '#^(https?://.+)//#', '$1/', $url ); // Ensure we don't double any '/'
|
|
||||||
$url = preg_replace('#^https?://[^/]+#', '', $url );
|
|
||||||
return $url;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Permissions are controlled as follows:
|
* Permissions are controlled as follows:
|
||||||
* 1. if the path is '/', the request has read privileges
|
* 1. if the path is '/', the request has read privileges
|
||||||
|
|||||||
@ -213,4 +213,24 @@ function getStatusMessage($status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a URL from the supplied dav_name
|
||||||
|
* @param string $partial_path The part of the path after the script name
|
||||||
|
*/
|
||||||
|
function ConstructURL( $partial_path ) {
|
||||||
|
global $c;
|
||||||
|
|
||||||
|
if ( ! isset($c->_url_script_path) ) {
|
||||||
|
$c->_url_script_path = (preg_match('#/$#', $c->protocol_server_port_script) ? 'caldav.php' : '');
|
||||||
|
$c->_url_script_path = $c->protocol_server_port_script . $c->_url_script_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
$url = $c->_url_script_path . $partial_path;
|
||||||
|
$url = preg_replace( '#^(https?://.+)//#', '$1/', $url ); // Ensure we don't double any '/'
|
||||||
|
$url = preg_replace('#^https?://[^/]+#', '', $url );
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@ -213,4 +213,21 @@ function getStatusMessage($status) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
?>
|
/**
|
||||||
|
* Construct a URL from the supplied dav_name
|
||||||
|
* @param string $partial_path The part of the path after the script name
|
||||||
|
*/
|
||||||
|
function ConstructURL( $partial_path ) {
|
||||||
|
global $c;
|
||||||
|
|
||||||
|
if ( ! isset($c->_url_script_path) ) {
|
||||||
|
$c->_url_script_path = (preg_match('#/$#', $c->protocol_server_port_script) ? 'caldav.php' : '');
|
||||||
|
$c->_url_script_path = $c->protocol_server_port_script . $c->_url_script_path;
|
||||||
|
}
|
||||||
|
|
||||||
|
$url = $c->_url_script_path . $partial_path;
|
||||||
|
$url = preg_replace( '#^(https?://.+)//#', '$1/', $url ); // Ensure we don't double any '/'
|
||||||
|
$url = preg_replace('#^https?://[^/]+#', '', $url );
|
||||||
|
return $url;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -320,7 +320,7 @@ function collection_to_xml( $collection ) {
|
|||||||
$arbitrary_results = get_arbitrary_properties($collection->dav_name);
|
$arbitrary_results = get_arbitrary_properties($collection->dav_name);
|
||||||
$collection->properties = $arbitrary_results->found;
|
$collection->properties = $arbitrary_results->found;
|
||||||
|
|
||||||
$url = $request->ConstructURL($collection->dav_name);
|
$url = ConstructURL($collection->dav_name);
|
||||||
|
|
||||||
$resourcetypes = array( new XMLElement("collection") );
|
$resourcetypes = array( new XMLElement("collection") );
|
||||||
$contentlength = false;
|
$contentlength = false;
|
||||||
@ -476,7 +476,7 @@ function item_to_xml( $item ) {
|
|||||||
|
|
||||||
$item->properties = get_arbitrary_properties($item->dav_name);
|
$item->properties = get_arbitrary_properties($item->dav_name);
|
||||||
|
|
||||||
$url = $request->ConstructURL($item->dav_name);
|
$url = ConstructURL($item->dav_name);
|
||||||
|
|
||||||
$prop = new XMLElement("prop");
|
$prop = new XMLElement("prop");
|
||||||
$not_found = new XMLElement("prop");
|
$not_found = new XMLElement("prop");
|
||||||
|
|||||||
@ -195,7 +195,7 @@ if ( count($failure) > 0 ) {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$url = $request->ConstructURL($request->path);
|
$url = ConstructURL($request->path);
|
||||||
array_unshift( $failure, new XMLElement('href', $url ) );
|
array_unshift( $failure, new XMLElement('href', $url ) );
|
||||||
$failure[] = new XMLElement('responsedescription', translate("Some properties were not able to be changed.") );
|
$failure[] = new XMLElement('responsedescription', translate("Some properties were not able to be changed.") );
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ if ( count($failure) > 0 ) {
|
|||||||
$sql .= "COMMIT;";
|
$sql .= "COMMIT;";
|
||||||
$qry = new PgQuery( $sql );
|
$qry = new PgQuery( $sql );
|
||||||
if ( $qry->Exec() ) {
|
if ( $qry->Exec() ) {
|
||||||
$url = $request->ConstructURL($request->path);
|
$url = ConstructURL($request->path);
|
||||||
$href = new XMLElement('href', $url );
|
$href = new XMLElement('href', $url );
|
||||||
$desc = new XMLElement('responsedescription', translate("All requested changes were made.") );
|
$desc = new XMLElement('responsedescription', translate("All requested changes were made.") );
|
||||||
|
|
||||||
|
|||||||
@ -96,7 +96,7 @@ function calendar_to_xml( $properties, $item ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$url = $request->ConstructURL($item->dav_name);
|
$url = ConstructURL($item->dav_name);
|
||||||
|
|
||||||
$prop = new XMLElement("prop");
|
$prop = new XMLElement("prop");
|
||||||
foreach( $properties AS $k => $v ) {
|
foreach( $properties AS $k => $v ) {
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
HTTP/1.1 200 OK
|
HTTP/1.1 200 OK
|
||||||
Date: Dow, 01 Jan 2000 00:00:00 GMT
|
Date: Dow, 01 Jan 2000 00:00:00 GMT
|
||||||
DAV: 1, 2, access-control, calendar-access
|
DAV: 1, 2, access-control, calendar-access
|
||||||
Content-Length: 239
|
Content-Length: 224
|
||||||
Content-Type: text/xml; charset="utf-8"
|
Content-Type: text/xml; charset="utf-8"
|
||||||
|
|
||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<multistatus xmlns="DAV:">
|
<multistatus xmlns="DAV:">
|
||||||
<response>
|
<response>
|
||||||
<href>http://mycaldav/caldav.php/user1/home/</href>
|
<href>/caldav.php/user1/home/</href>
|
||||||
<responsedescription>All requested changes were made.</responsedescription>
|
<responsedescription>All requested changes were made.</responsedescription>
|
||||||
</response>
|
</response>
|
||||||
</multistatus>
|
</multistatus>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user