mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-05-27 02:54:27 +00:00
Fix REPORT to use the request object.
This commit is contained in:
parent
c26ae36b93
commit
d9b22134f1
@ -10,12 +10,8 @@
|
||||
*/
|
||||
dbg_error_log("REPORT", "method handler");
|
||||
|
||||
if ( ! isset($permissions['read']) ) {
|
||||
header("HTTP/1.1 403 Forbidden");
|
||||
header("Content-type: text/plain");
|
||||
echo "You may not access that calendar.";
|
||||
dbg_error_log("GET", "Access denied for User: %d, Path: %s", $session->user_no, $request_path);
|
||||
return;
|
||||
if ( ! $request->AllowedTo('read') ) {
|
||||
$request->DoResponse( 403, translate("You may not access that calendar") );
|
||||
}
|
||||
|
||||
|
||||
@ -23,7 +19,7 @@ require_once("XMLElement.php");
|
||||
|
||||
$reportnum = -1;
|
||||
$report = array();
|
||||
foreach( $xml_tags AS $k => $v ) {
|
||||
foreach( $request->xml_tags AS $k => $v ) {
|
||||
|
||||
$fulltag = $v['tag'];
|
||||
if ( preg_match('/^(.*):([^:]+)$/', $fulltag, $matches) ) {
|
||||
@ -167,7 +163,7 @@ foreach( $xml_tags AS $k => $v ) {
|
||||
* Return XML for a single calendar (or todo) entry from the DB
|
||||
*/
|
||||
function calendar_to_xml( $properties, $item ) {
|
||||
global $session, $c;
|
||||
global $session, $c, $request;
|
||||
|
||||
dbg_error_log("REPORT","Building XML Response for item '%s'", $item->dav_name );
|
||||
|
||||
@ -193,7 +189,7 @@ function calendar_to_xml( $properties, $item ) {
|
||||
$prop->NewElement("getetag", '"'.$item->dav_etag.'"' );
|
||||
}
|
||||
if ( isset($properties['CURRENT-USER-PRIVILEGE-SET']) ) {
|
||||
$prop->NewElement("current-user-privilege-set", privileges($GLOBALS['permissions']) );
|
||||
$prop->NewElement("current-user-privilege-set", privileges($request->permissions) );
|
||||
}
|
||||
$status = new XMLElement("status", "HTTP/1.1 200 OK" );
|
||||
|
||||
@ -208,14 +204,9 @@ function calendar_to_xml( $properties, $item ) {
|
||||
|
||||
|
||||
if ( isset($unsupported) && count($unsupported) > 0 ) {
|
||||
|
||||
/**
|
||||
* That's a *BAD* request!
|
||||
*/
|
||||
|
||||
header('HTTP/1.1 501 Not Implemented');
|
||||
header('Content-Type: application/xml; charset="utf-8"');
|
||||
|
||||
$badprops = new XMLElement( "prop" );
|
||||
foreach( $unsupported AS $k => $v ) {
|
||||
dbg_error_log("ERROR", " REPORT: Support for $v::$k properties is not implemented yet");
|
||||
@ -223,9 +214,7 @@ if ( isset($unsupported) && count($unsupported) > 0 ) {
|
||||
}
|
||||
$error = new XMLElement("error", new XMLElement( "propfind",$badprops), array("xmlns" => "DAV:") );
|
||||
|
||||
echo $error->Render(0,'<?xml version="1.0" ?>');
|
||||
|
||||
exit(0);
|
||||
$request->DoResponse( 403, $error->Render(0,'<?xml version="1.0" ?>'), 'text/xml; charset="utf-8"');
|
||||
}
|
||||
else {
|
||||
|
||||
@ -239,7 +228,7 @@ else {
|
||||
// dbg_error_log("REPORT", "Report[%d] Start:%s, End: %s, Events: %d, Todos: %d, Freebusy: %d",
|
||||
// $i, $report[$i]['start'], $report[$i]['end'], $report[$i]['filters']['VEVENT'], $report[$i]['filters']['VTODO'], $report[$i]['filters']['VFREEBUSY']);
|
||||
|
||||
$where .= " WHERE caldav_data.dav_name ~ ".qpg("^".$request_path)." ";
|
||||
$where .= " WHERE caldav_data.dav_name ~ ".qpg("^".$request->path)." ";
|
||||
switch( $report[$i]['type'] ) {
|
||||
case 'CALENDAR-QUERY':
|
||||
if ( isset( $report[$i]['start'] ) ) {
|
||||
@ -290,14 +279,9 @@ else {
|
||||
}
|
||||
$multistatus = new XMLElement( "multistatus", $responses, array('xmlns'=>'DAV:') );
|
||||
|
||||
$xmldoc = $multistatus->Render();
|
||||
$xmldoc = $multistatus->Render( 0, '<?xml version="1.0" encoding="UTF-8" ?>');
|
||||
$etag = md5($xmldoc);
|
||||
|
||||
header("HTTP/1.1 207 Multi-Status");
|
||||
header("Content-type: text/xml;charset=UTF-8");
|
||||
header("ETag: \"$etag\"");
|
||||
|
||||
echo'<?xml version="1.0" encoding="UTF-8" ?>'."\n";
|
||||
echo $xmldoc;
|
||||
$request->DoResponse( 207, $xmldoc, 'text/xml; charset="utf-8"' );
|
||||
|
||||
?>
|
||||
@ -1,9 +1,9 @@
|
||||
HTTP/1.1 207 Multi-Status
|
||||
Date: Dow, 01 Jan 2000 00:00:00 GMT
|
||||
Server: Apache/2.2.3 (Debian) DAV/2
|
||||
ETag: "9af8e0a0b4fe1d20dd7b016d8916a1c0"
|
||||
ETag: "f9fa1b47eff2ea9f94e6fa54b07198d8"
|
||||
Content-Length: 341
|
||||
Content-Type: text/xml;charset=UTF-8
|
||||
Content-Type: text/xml; charset="utf-8"
|
||||
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<multistatus xmlns="DAV:">
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
HTTP/1.1 207 Multi-Status
|
||||
Date: Dow, 01 Jan 2000 00:00:00 GMT
|
||||
Server: Apache/2.2.3 (Debian) DAV/2
|
||||
ETag: "0ebe2932552a8091e8d9e941663d6b44"
|
||||
ETag: "9d3605b5b78ea1f7f2273b3251f23b61"
|
||||
Content-Length: 582
|
||||
Content-Type: text/xml;charset=UTF-8
|
||||
Content-Type: text/xml; charset="utf-8"
|
||||
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<multistatus xmlns="DAV:">
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
HTTP/1.1 207 Multi-Status
|
||||
Date: Dow, 01 Jan 2000 00:00:00 GMT
|
||||
Server: Apache/2.2.3 (Debian) DAV/2
|
||||
ETag: "5b96765475e589f86d394a09499d000e"
|
||||
ETag: "9a2b860b7650f72b1e0760312adac2b4"
|
||||
Content-Length: 2420
|
||||
Content-Type: text/xml;charset=UTF-8
|
||||
Content-Type: text/xml; charset="utf-8"
|
||||
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<multistatus xmlns="DAV:">
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
HTTP/1.1 207 Multi-Status
|
||||
Date: Dow, 01 Jan 2000 00:00:00 GMT
|
||||
Server: Apache/2.2.3 (Debian) DAV/2
|
||||
ETag: "f6d6b5d2136d5389ced4ca2e75c96323"
|
||||
ETag: "e111c4ad26b709f9f5010d8767e66660"
|
||||
Content-Length: 1110
|
||||
Content-Type: text/xml;charset=UTF-8
|
||||
Content-Type: text/xml; charset="utf-8"
|
||||
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<multistatus xmlns="DAV:">
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
HTTP/1.1 207 Multi-Status
|
||||
Date: Dow, 01 Jan 2000 00:00:00 GMT
|
||||
Server: Apache/2.2.3 (Debian) DAV/2
|
||||
ETag: "53825def7704819be31ec548b2c30e38"
|
||||
ETag: "3c6079aca32c2bbcff3f4091dcd38168"
|
||||
Content-Length: 1358
|
||||
Content-Type: text/xml;charset=UTF-8
|
||||
Content-Type: text/xml; charset="utf-8"
|
||||
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<multistatus xmlns="DAV:">
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
HTTP/1.1 207 Multi-Status
|
||||
Date: Dow, 01 Jan 2000 00:00:00 GMT
|
||||
Server: Apache/2.2.3 (Debian) DAV/2
|
||||
ETag: "de17ff152eecec653d5490dc6a820256"
|
||||
ETag: "bd7f155447f7ae232ebf4093b2c7dbc6"
|
||||
Content-Length: 68
|
||||
Content-Type: text/xml;charset=UTF-8
|
||||
Content-Type: text/xml; charset="utf-8"
|
||||
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<multistatus xmlns="DAV:"/>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user