mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-08-22 17:16:06 +00:00
Write & use utility function for URL construction.
This commit is contained in:
parent
89c7a33694
commit
6d3a0abd4c
@ -254,6 +254,20 @@ 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:
|
||||
* 1. if the path is '/', the request has read privileges
|
||||
|
||||
@ -320,10 +320,7 @@ function collection_to_xml( $collection ) {
|
||||
$arbitrary_results = get_arbitrary_properties($collection->dav_name);
|
||||
$collection->properties = $arbitrary_results->found;
|
||||
|
||||
$url = $c->protocol_server_port_script . $collection->dav_name;
|
||||
$url = preg_replace( '#^(https?://.+)//#', '$1/', $url ); // Ensure we don't double any '/'
|
||||
$url = preg_replace('#^https?://[^/]+#', '', $url );
|
||||
|
||||
$url = $request->ConstructURL($collection->dav_name);
|
||||
|
||||
$resourcetypes = array( new XMLElement("collection") );
|
||||
$contentlength = false;
|
||||
@ -479,9 +476,7 @@ function item_to_xml( $item ) {
|
||||
|
||||
$item->properties = get_arbitrary_properties($item->dav_name);
|
||||
|
||||
$url = $c->protocol_server_port_script . $item->dav_name;
|
||||
$url = preg_replace( '#^(https?://.+)//#', '$1/', $url ); // Ensure we don't double any '/'
|
||||
$url = preg_replace('#^https?://[^/]+#', '', $url );
|
||||
$url = $request->ConstructURL($item->dav_name);
|
||||
|
||||
$prop = new XMLElement("prop");
|
||||
$not_found = new XMLElement("prop");
|
||||
|
||||
@ -96,9 +96,7 @@ function calendar_to_xml( $properties, $item ) {
|
||||
}
|
||||
}
|
||||
|
||||
$url = $c->protocol_server_port_script . $item->dav_name;
|
||||
$url = preg_replace( '#^(https?://.+)//#', '$1/', $url ); // Ensure we don't double any '/'
|
||||
$url = preg_replace('#^https?://[^/]+#', '', $url );
|
||||
$url = $request->ConstructURL($item->dav_name);
|
||||
|
||||
$prop = new XMLElement("prop");
|
||||
foreach( $properties AS $k => $v ) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user