From 03ff39fa33263ab26a22c0046c90e903e9fce42e Mon Sep 17 00:00:00 2001 From: Andrew McMillan Date: Fri, 5 Mar 2010 14:26:58 +1300 Subject: [PATCH] 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. --- htdocs/tools.php | 1 + inc/caldav-PUT-functions.php | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/htdocs/tools.php b/htdocs/tools.php index 3f04f920..70fe17cc 100644 --- a/htdocs/tools.php +++ b/htdocs/tools.php @@ -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; diff --git a/inc/caldav-PUT-functions.php b/inc/caldav-PUT-functions.php index e99d66cd..c1b8b884 100644 --- a/inc/caldav-PUT-functions.php +++ b/inc/caldav-PUT-functions.php @@ -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 ) ) {//(