"allow to (optionally) pass etag to importVCal, to check and fail if event is changed (needed by GroupDAV/CalDAV)"

This commit is contained in:
Ralf Becker 2008-05-06 21:57:32 +00:00
parent 36858cf2c2
commit faae1ce6b6

View File

@ -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