mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-06-08 04:50:55 +00:00
Fix the GET to use the request object.
This commit is contained in:
parent
d9b22134f1
commit
674ca88ea8
@ -10,15 +10,11 @@
|
||||
*/
|
||||
dbg_error_log("get", "GET 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") );
|
||||
}
|
||||
|
||||
$qry = new PgQuery( "SELECT * FROM caldav_data WHERE user_no = ? AND dav_name = ? ;", $path_user_no, $request_path);
|
||||
$qry = new PgQuery( "SELECT * FROM caldav_data WHERE user_no = ? AND dav_name = ? ;", $request->user_no, $request->path);
|
||||
dbg_error_log("get", "%s", $qry->querystring );
|
||||
if ( $qry->Exec("GET") && $qry->rows == 1 ) {
|
||||
$event = $qry->Fetch();
|
||||
@ -28,34 +24,16 @@ if ( $qry->Exec("GET") && $qry->rows == 1 ) {
|
||||
* an If-Match or If-None-Match header. I'm not sure what that means here,
|
||||
* so we will leave it unimplemented at this point.
|
||||
*/
|
||||
|
||||
header("HTTP/1.1 200 OK");
|
||||
header("ETag: \"$event->dav_etag\"");
|
||||
header("Content-type: text/calendar");
|
||||
|
||||
if ( $request_method != "HEAD" )
|
||||
echo $event->caldav_data;
|
||||
|
||||
dbg_error_log( "GET", "User: %d, ETag: %s, Path: %s", $session->user_no, $event->dav_etag, $get_path);
|
||||
|
||||
$request->DoResponse( 200, ($request_method == "HEAD" ? "" : $event->caldav_data), "text/calendar; charset=UTF-8" );
|
||||
}
|
||||
else if ( $qry->rows < 1 ) {
|
||||
header("HTTP/1.1 404 Not Found");
|
||||
header("Content-type: text/plain");
|
||||
echo "Calendar Resource Not Found.";
|
||||
dbg_error_log("ERROR", "No rows match for User: %d, ETag: %s, Path: %s", $session->user_no, $event->dav_etag, $get_path);
|
||||
$request->DoResponse( 404, "Calendar Resource Not Found." );
|
||||
}
|
||||
else if ( $qry->rows > 1 ) {
|
||||
header("HTTP/1.1 500 Internal Server Error");
|
||||
header("Content-type: text/plain");
|
||||
echo "Database Error - Multiple Rows Match";
|
||||
dbg_error_log("ERROR", "Multiple rows match for User: %d, ETag: %s, Path: %s", $session->user_no, $event->dav_etag, $get_path);
|
||||
$request->DoResponse( 500, "Database Error - Multiple Rows Match." );
|
||||
}
|
||||
else {
|
||||
header("HTTP/1.1 500 Infernal Server Error");
|
||||
header("Content-type: text/plain");
|
||||
echo "Database Error";
|
||||
dbg_error_log("get", "Database Error");
|
||||
$request->DoResponse( 500, "Database Error." );
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1,9 +1,8 @@
|
||||
HTTP/1.1 200 OK
|
||||
Date: Dow, 01 Jan 2000 00:00:00 GMT
|
||||
Server: Apache/2.2.3 (Debian) DAV/2
|
||||
ETag: "2c32a2f8aba853654eb17fe037a4db4d"
|
||||
Content-Length: 747
|
||||
Content-Type: text/calendar
|
||||
Content-Type: text/calendar; charset=UTF-8
|
||||
|
||||
BEGIN:VCALENDAR
|
||||
CALSCALE:GREGORIAN
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
HTTP/1.1 200 OK
|
||||
Date: Dow, 01 Jan 2000 00:00:00 GMT
|
||||
Server: Apache/2.2.3 (Debian) DAV/2
|
||||
ETag: "c3658901fd4689d4a1e1d6f08601ef4f"
|
||||
Content-Length: 1059
|
||||
Content-Type: text/calendar
|
||||
Content-Type: text/calendar; charset=UTF-8
|
||||
|
||||
BEGIN:VCALENDAR
|
||||
CALSCALE:GREGORIAN
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user