mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-02-10 02:53:36 +00:00
Have now converted MKCALENDAR to use new request object.
This commit is contained in:
parent
6a6f147f75
commit
367462fb67
@ -10,44 +10,34 @@
|
||||
*/
|
||||
dbg_error_log("MKCALENDAR", "method handler");
|
||||
|
||||
if ( ! isset($permissions['write']) ) {
|
||||
header("HTTP/1.1 403 Forbidden");
|
||||
header("Content-type: text/plain");
|
||||
echo "You may not create a calendar there.";
|
||||
dbg_error_log("ERROR", "MKCALENDAR Access denied for User: %d, Path: %s", $session->user_no, $request_path);
|
||||
exit(0);
|
||||
if ( ! $request->AllowedTo('write') ) {
|
||||
$request->DoResponse( 403, translate("You may not create a calendar there.") );
|
||||
}
|
||||
|
||||
$displayname = $request_path;
|
||||
$displayname = $request->path;
|
||||
$parent_container = '/';
|
||||
if ( preg_match( '#^(.*/)([^/]+)(/)?$#', $request_path, $matches ) ) {
|
||||
if ( preg_match( '#^(.*/)([^/]+)(/)?$#', $request->path, $matches ) ) {
|
||||
$parent_container = $matches[1];
|
||||
$displayname = $matches[2];
|
||||
}
|
||||
$sql = "SELECT * FROM collection WHERE user_no = ? AND dav_name = ?;";
|
||||
$qry = new PgQuery( $sql, $path_user_no, $request_path );
|
||||
$qry = new PgQuery( $sql, $request->user_no, $request->path );
|
||||
if ( ! $qry->Exec("MKCALENDAR") ) {
|
||||
header("HTTP/1.1 500 Infernal Server Error");
|
||||
dbg_error_log( "ERROR", " MKCALENDAR Failed (database error) for '%s' named '%s', user '%d' in parent '%s'", $request_path, $displayname, $session->user_no, $parent_container);
|
||||
exit(0);
|
||||
$request->DoResponse( 500, "Error querying database." );
|
||||
}
|
||||
if ( $qry->rows != 0 ) {
|
||||
header("HTTP/1.1 412 Calendar Already Exists");
|
||||
dbg_error_log( "ERROR", " MKCALENDAR Failed (already exists) for '%s' named '%s', user '%d' in parent '%s'", $request_path, $displayname, $session->user_no, $parent_container);
|
||||
exit(0);
|
||||
$request->DoResponse( 412, "A collection already exists at that location." );
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO collection ( user_no, parent_container, dav_name, dav_etag, dav_displayname, is_calendar, created, modified ) VALUES( ?, ?, ?, ?, ?, TRUE, current_timestamp, current_timestamp );";
|
||||
$qry = new PgQuery( $sql, $path_user_no, $parent_container, $request_path, md5($path_user_no. $request_path), $displayname );
|
||||
$qry = new PgQuery( $sql, $request->user_no, $parent_container, $request->path, md5($request->user_no. $request->path), $displayname );
|
||||
|
||||
if ( $qry->Exec("MKCALENDAR",__LINE__,__FILE__) ) {
|
||||
header("HTTP/1.1 200 Created");
|
||||
dbg_error_log( "MKCALENDAR", "New calendar '%s' created named '%s' for user '%d' in parent '%s'", $request_path, $displayname, $session->user_no, $parent_container);
|
||||
dbg_error_log( "MKCALENDAR", "New calendar '%s' created named '%s' for user '%d' in parent '%s'", $request->path, $displayname, $session->user_no, $parent_container);
|
||||
$request->DoResponse( 200, "" );
|
||||
}
|
||||
else {
|
||||
header("HTTP/1.1 500 Infernal Server Error");
|
||||
dbg_error_log( "ERROR", " MKCALENDAR Failed for '%s' named '%s', user '%d' in parent '%s'", $request_path, $displayname, $session->user_no, $parent_container);
|
||||
exit(0);
|
||||
$request->DoResponse( 500, "Error writing calendar details to database." );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
HTTP/1.1 200 Created
|
||||
HTTP/1.1 200 OK
|
||||
Date: Dow, 01 Jan 2000 00:00:00 GMT
|
||||
Server: Apache/2.2.3 (Debian) DAV/2
|
||||
Content-Length: 0
|
||||
Content-Type: text/html; charset=UTF-8
|
||||
Content-Type: text/plain; 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: "e898d6c4a9951794a9f7147f432570d0"
|
||||
ETag: "a2f9456e10ec204df8badf8526eddca8"
|
||||
Content-Length: 708
|
||||
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: "37e795bc0198358d27e006b91dc75aa7"
|
||||
ETag: "f86e4358f5d14ec9e61ee57ae97696d9"
|
||||
Content-Length: 483
|
||||
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,6 +1,7 @@
|
||||
HTTP/1.1 412 Calendar Already Exists
|
||||
HTTP/1.1 412 Precondition Failed
|
||||
Date: Dow, 01 Jan 2000 00:00:00 GMT
|
||||
Server: Apache/2.2.3 (Debian) DAV/2
|
||||
Content-Length: 0
|
||||
Content-Type: text/html; charset=UTF-8
|
||||
Content-Length: 45
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
|
||||
A collection already exists at that location.
|
||||
Loading…
x
Reference in New Issue
Block a user