open patch from inf-it website: support for bulk addressbook import
Today I stumbled over a patch mentioned at http://www.inf-it.com/davical/, all the way at the bottom under the heading "additional (not included) patches - these need more testing/review", which has not been integrated into git yet:
- support for bulk addressbook import (thanks Jorge López Pérez)
batch_addressbook_import.diff:
--- caldav-PUT-vcard.php.orig 2013-04-22 13:20:41.000000000 +0200
+++ caldav-PUT-vcard.php 2013-04-22 14:26:38.000000000 +0200
@@ -12,6 +12,8 @@
require_once('DAVResource.php');
+include_once('caldav-PUT-functions.php');
+
if ( ! ini_get('open_basedir') && (isset($c->dbg['ALL']) || (isset($c->dbg['put']) && $c->dbg['put'])) ) {
$fh = fopen('/tmp/PUT.txt','w');
if ( $fh ) {
@@ -60,7 +62,6 @@
if ( ! isset($c->readonly_webdav_collections) || $c->readonly_webdav_collections ) {
$request->PreconditionFailed(405,'method-not-allowed',translate('You may not PUT to a collection URL'));
}
- $request->DoResponse(403,translate('PUT on a collection is only allowed for text/vcard content against an addressbook collection'));
}
$dest->NeedPrivilege('DAV::write-content');
}
@@ -73,9 +74,6 @@
$original_etag = md5($request->raw_post);
-$qry = new AwlQuery();
-$qry->Begin();
-
$uid = $vcard->GetPValue('UID');
if ( empty($uid) ) {
$uid = uuid();
@@ -109,6 +107,25 @@
':session_user' => $session->user_no,
':modified' => $last_modified
);
+
+if ($dest->IsCollection()) {
+ if ( $dest->IsPrincipal() || $dest->IsBinding() || !isset($c->readonly_webdav_collections) || $c->readonly_webdav_collections == true ) {
+ $request->DoResponse( 405 ); // Method not allowed
+ return;
+ }
+
+ $appending = (isset($_GET['mode']) && $_GET['mode'] == 'append' );
+
+ import_collection($request->raw_post, $request->user_no, $request->path, true, $appending);
+
+ $request->DoResponse( 200 );
+ return;
+}
+
+$qry = new AwlQuery();
+$qry->Begin();
+
+
if ( $dest->Exists() ) {
$sql = 'UPDATE caldav_data SET caldav_data=:dav_data, dav_etag=:etag, logged_user=:session_user,
modified=:modified, user_no=:user_no, caldav_type=\'VCARD\' WHERE dav_name=:dav_name';
What's added looks similar to code that can be found in caldav-PUT-vcalendar.php (how can these two files look so different??); I'm not sure about the deleted 403 response, though, it has been in there from the beginning, and exists in a similar form in caldav-PUT-default.php, but seems to be absent in caldav-PUT-vcalendar.php...
Jan, perhaps you can shed some light on the issues you see with this patch, where it comes from, what issue (which client?) the submitter wanted to fix etc.