mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-02-16 03:53:40 +00:00
Add facility to append to a calendar with ?mode=append on PUT
This commit is contained in:
parent
6cb50958c8
commit
f844d6b692
@ -384,7 +384,7 @@ function update_scheduling_requests( &$resource ) {
|
||||
*
|
||||
* Any VEVENTs with the same UID will be concatenated together
|
||||
*/
|
||||
function import_collection( $ics_content, $user_no, $path, $caldav_context ) {
|
||||
function import_collection( $ics_content, $user_no, $path, $caldav_context, $appending = false ) {
|
||||
global $c, $session, $tz_regex;
|
||||
|
||||
if ( ! ini_get('open_basedir') && (isset($c->dbg['ALL']) || isset($c->dbg['put'])) ) {
|
||||
@ -400,7 +400,7 @@ function import_collection( $ics_content, $user_no, $path, $caldav_context ) {
|
||||
$components = $calendar->GetComponents('VTIMEZONE',false);
|
||||
|
||||
$displayname = $calendar->GetPValue('X-WR-CALNAME');
|
||||
if ( isset($displayname) ) {
|
||||
if ( !$appending && isset($displayname) ) {
|
||||
$sql = 'UPDATE collection SET dav_displayname = :displayname WHERE dav_name = :dav_name';
|
||||
$qry = new AwlQuery( $sql, array( ':displayname' => $displayname, ':dav_name' => $path) );
|
||||
if ( ! $qry->Exec('PUT',__LINE__,__FILE__) ) rollback_on_error( $caldav_context, $user_no, $path );
|
||||
@ -439,9 +439,11 @@ function import_collection( $ics_content, $user_no, $path, $caldav_context ) {
|
||||
|
||||
if ( !(isset($c->skip_bad_event_on_import) && $c->skip_bad_event_on_import) ) $qry->Begin();
|
||||
$base_params = array( ':collection_id' => $collection->collection_id );
|
||||
if ( !$qry->QDo('DELETE FROM calendar_item WHERE collection_id = :collection_id', $base_params)
|
||||
if ( !$appending ) {
|
||||
if ( !$qry->QDo('DELETE FROM calendar_item WHERE collection_id = :collection_id', $base_params)
|
||||
|| !$qry->QDo('DELETE FROM caldav_data WHERE collection_id = :collection_id', $base_params) )
|
||||
rollback_on_error( $caldav_context, $user_no, $collection->collection_id );
|
||||
rollback_on_error( $caldav_context, $user_no, $collection->collection_id );
|
||||
}
|
||||
|
||||
$dav_data_insert = <<<EOSQL
|
||||
INSERT INTO caldav_data ( user_no, dav_name, dav_etag, caldav_data, caldav_type, logged_user, created, modified, collection_id )
|
||||
|
||||
@ -41,11 +41,13 @@ if ( $dav_resource->IsCollection() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$appending = (isset($_GET['mode']) && $_GET['mode'] == 'append' );
|
||||
|
||||
/**
|
||||
* CalDAV does not define the result of a PUT on a collection. We treat that
|
||||
* as an import. The code is in caldav-PUT-functions.php
|
||||
*/
|
||||
import_collection($request->raw_post,$request->user_no,$request->path,true);
|
||||
import_collection($request->raw_post,$request->user_no,$request->path,true, $appending);
|
||||
$request->DoResponse( 200 );
|
||||
return;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user