From faae1ce6b6b38dda743780935cd75723033d2c69 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 6 May 2008 21:57:32 +0000 Subject: [PATCH] "allow to (optionally) pass etag to importVCal, to check and fail if event is changed (needed by GroupDAV/CalDAV)" --- calendar/inc/class.boical.inc.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/calendar/inc/class.boical.inc.php b/calendar/inc/class.boical.inc.php index 35ee80172a..a8afccd660 100644 --- a/calendar/inc/class.boical.inc.php +++ b/calendar/inc/class.boical.inc.php @@ -463,7 +463,15 @@ return $vcal->exportvCalendar(); } - function importVCal($_vcalData, $cal_id=-1) + /** + * Import an iCal + * + * @param string $_vcalData + * @param int $cal_id=-1 must be -1 for new entrys! + * @param string $etag=null if an etag is given, it has to match the current etag or the import will fail + * @return int|boolean cal_id > 0 on success, false on failure or 0 for a failed etag + */ + function importVCal($_vcalData, $cal_id=-1,$etag=null) { // our (patched) horde classes, do NOT unfold folded lines, which causes a lot trouble in the import $_vcalData = preg_replace("/[\r\n]+ /",'',$_vcalData); @@ -901,7 +909,13 @@ #error_log('ALARMS'); #error_log(print_r($event, true)); - if (!($Ok = $this->update($event, TRUE))) { + // if an etag is given, include it in the update + if (!is_null($etag)) + { + $event['etag'] = $etag; + } + if (!($Ok = $this->update($event, TRUE))) + { break; // stop with the first error } else