mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-05-23 02:14:16 +00:00
support for bulk addressbook import (thanks Jorge Lpez Prez) - fixes #74
This commit is contained in:
parent
4d689f8539
commit
e245b8d1fb
@ -12,6 +12,8 @@ dbg_error_log("PUT", "method handler");
|
|||||||
|
|
||||||
require_once('DAVResource.php');
|
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'])) ) {
|
if ( ! ini_get('open_basedir') && (isset($c->dbg['ALL']) || (isset($c->dbg['put']) && $c->dbg['put'])) ) {
|
||||||
$fh = fopen('/var/log/davical/PUT.debug','w');
|
$fh = fopen('/var/log/davical/PUT.debug','w');
|
||||||
if ( $fh ) {
|
if ( $fh ) {
|
||||||
@ -60,7 +62,6 @@ else {
|
|||||||
if ( ! isset($c->readonly_webdav_collections) || $c->readonly_webdav_collections ) {
|
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->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');
|
$dest->NeedPrivilege('DAV::write-content');
|
||||||
}
|
}
|
||||||
@ -72,10 +73,6 @@ $collection_id = $container->GetProperty('collection_id');
|
|||||||
|
|
||||||
$original_etag = md5($request->raw_post);
|
$original_etag = md5($request->raw_post);
|
||||||
|
|
||||||
|
|
||||||
$qry = new AwlQuery();
|
|
||||||
$qry->Begin();
|
|
||||||
|
|
||||||
$uid = $vcard->GetPValue('UID');
|
$uid = $vcard->GetPValue('UID');
|
||||||
if ( empty($uid) ) {
|
if ( empty($uid) ) {
|
||||||
$uid = uuid();
|
$uid = uuid();
|
||||||
@ -121,6 +118,25 @@ $params = array(
|
|||||||
':session_user' => $session->user_no,
|
':session_user' => $session->user_no,
|
||||||
':modified' => $last_modified
|
':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() ) {
|
if ( $dest->Exists() ) {
|
||||||
$sql = 'UPDATE caldav_data SET caldav_data=:dav_data, dav_etag=:etag, logged_user=:session_user,
|
$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';
|
modified=:modified, user_no=:user_no, caldav_type=\'VCARD\' WHERE dav_name=:dav_name';
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user