With readonly_webdav_collections set we should write nothing!

We were writing collection records to the database when the
configuration setting readonly_webdav_collections was set, even
though the actual events would not be written.
This commit is contained in:
Andrew McMillan 2010-03-05 14:26:58 +13:00
parent 31f8c6b17f
commit 03ff39fa33
2 changed files with 8 additions and 0 deletions

View File

@ -126,6 +126,7 @@ class Tools {
if ( check_string($ics) ) {
$path = "/".substr($file,0,-4).$path_ics;
dbg_error_log( "importFromDirectory", "importing to $path");
$c->readonly_webdav_collections = false; // Override this setting so we can create collections/events on import.
require_once("caldav-PUT-functions.php");
if ( $user = getUserByName(substr($file,0,-4),'importFromDirectory',__LINE__,__FILE__)) {
$user_no = $user->user_no;

View File

@ -56,6 +56,7 @@ function rollback_on_error( $caldav_context, $user_no, $path, $message='', $erro
* @param boolean $public Whether the collection will be public, should we need to create it
*/
function controlRequestContainer( $username, $user_no, $path, $caldav_context, $public = null ) {
global $c;
// Check to see if the path is like /foo /foo/bar or /foo/bar/baz etc. (not ending with a '/', but contains at least one)
if ( preg_match( '#^(.*/)([^/]+)$#', $path, $matches ) ) {//(
@ -81,6 +82,12 @@ function controlRequestContainer( $username, $user_no, $path, $caldav_context, $
if ( ! $qry->Exec('PUT') ) {
rollback_on_error( $caldav_context, $user_no, $path );
}
if ( !isset($c->readonly_webdav_collections) || $c->readonly_webdav_collections == true ) {
if ( $qry->rows == 0 ) {
$request->DoResponse( 405 ); // Method not allowed
}
return;
}
if ( $qry->rows == 0 ) {
if ( $public == null ) $public = false;
if ( preg_match( '#^(.*/)([^/]+)/$#', $request_container, $matches ) ) {//(