mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-03-13 08:00:15 +00:00
The functionality between MKCOL and MKCALENDAR is so similar there need not
be two separate includes for them.
This commit is contained in:
parent
367462fb67
commit
bffb535e42
@ -21,7 +21,7 @@ switch ( $request->method ) {
|
||||
case 'PROPFIND': include_once("caldav-PROPFIND.php"); break;
|
||||
case 'PROPPATCH': include_once("caldav-PROPPATCH.php"); break;
|
||||
case 'MKCALENDAR': include_once("caldav-MKCALENDAR.php"); break;
|
||||
case 'MKCOL': include_once("caldav-MKCOL.php"); break;
|
||||
case 'MKCOL': include_once("caldav-MKCALENDAR.php"); break;
|
||||
case 'PUT': include_once("caldav-PUT.php"); break;
|
||||
case 'GET': include_once("caldav-GET.php"); break;
|
||||
case 'HEAD': include_once("caldav-GET.php"); break;
|
||||
|
||||
@ -29,8 +29,8 @@ if ( $qry->rows != 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, $request->user_no, $parent_container, $request->path, md5($request->user_no. $request->path), $displayname );
|
||||
$sql = "INSERT INTO collection ( user_no, parent_container, dav_name, dav_etag, dav_displayname, is_calendar, created, modified ) VALUES( ?, ?, ?, ?, ?, ?, current_timestamp, current_timestamp );";
|
||||
$qry = new PgQuery( $sql, $request->user_no, $parent_container, $request->path, md5($request->user_no. $request->path), $displayname, ($request->method == 'MKCALENDAR') );
|
||||
|
||||
if ( $qry->Exec("MKCALENDAR",__LINE__,__FILE__) ) {
|
||||
dbg_error_log( "MKCALENDAR", "New calendar '%s' created named '%s' for user '%d' in parent '%s'", $request->path, $displayname, $session->user_no, $parent_container);
|
||||
|
||||
@ -1,53 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* CalDAV Server - handle MKCOL method
|
||||
*
|
||||
* @package rscds
|
||||
* @subpackage caldav
|
||||
* @author Andrew McMillan <andrew@catalyst.net.nz>
|
||||
* @copyright Catalyst .Net Ltd
|
||||
* @license http://gnu.org/copyleft/gpl.html GNU GPL v2
|
||||
*/
|
||||
dbg_error_log("MKCOL", "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", "MKCOL Access denied for User: %d, Path: %s", $session->user_no, $request_path);
|
||||
return;
|
||||
}
|
||||
|
||||
$displayname = $request_path;
|
||||
$parent_container = '/';
|
||||
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 );
|
||||
if ( ! $qry->Exec("MKCOL") ) {
|
||||
header("HTTP/1.1 500 Infernal Server Error");
|
||||
dbg_error_log( "ERROR", " MKCOL Failed (database error) for '%s' named '%s', user '%d' in parent '%s'", $request_path, $displayname, $session->user_no, $parent_container);
|
||||
exit(0);
|
||||
}
|
||||
if ( $qry->rows != 0 ) {
|
||||
header("HTTP/1.1 412 Collection Already Exists");
|
||||
dbg_error_log( "ERROR", " MKCOL Failed (already exists) for '%s' named '%s', user '%d' in parent '%s'", $request_path, $displayname, $session->user_no, $parent_container);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO collection ( user_no, parent_container, dav_name, dav_etag, dav_displayname, is_calendar, created, modified ) VALUES( ?, ?, ?, ?, ?, FALSE, current_timestamp, current_timestamp );";
|
||||
$qry = new PgQuery( $sql, $path_user_no, $parent_container, $request_path, md5($path_user_no. $request_path), $displayname );
|
||||
|
||||
if ( $qry->Exec("MKCOL",__LINE__,__FILE__) ) {
|
||||
header("HTTP/1.1 200 Created");
|
||||
dbg_error_log( "MKCOL", "New collection '%s' created named '%s' for user '%d' in parent '%s'", $request_path, $displayname, $session->user_no, $parent_container);
|
||||
}
|
||||
else {
|
||||
header("HTTP/1.1 500 Infernal Server Error");
|
||||
dbg_error_log( "ERROR", " MKCOL Failed for '%s' named '%s', user '%d' in parent '%s'", $request_path, $displayname, $session->user_no, $parent_container);
|
||||
}
|
||||
|
||||
?>
|
||||
@ -46,7 +46,6 @@
|
||||
<item url="htdocs/js/browse.js" uploadstatus="1" />
|
||||
<item url="htdocs/css/browse.css" uploadstatus="1" />
|
||||
<item url="htdocs/css/" uploadstatus="1" />
|
||||
<item url="inc/caldav-MKCOL.php" uploadstatus="1" />
|
||||
<item url="testing/" uploadstatus="1" />
|
||||
<item url="testing/dav_test" uploadstatus="1" />
|
||||
<item url="testing/tests/chandler/" uploadstatus="1" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user