fixed alarm on series got lost, if creating an exception

This commit is contained in:
Ralf Becker 2011-11-11 12:46:34 +00:00
parent 78aa854a60
commit 89ed7d49d1
2 changed files with 14 additions and 5 deletions

View File

@ -980,7 +980,7 @@ class calendar_boupdate extends calendar_bo
} }
} }
// same with the alarms // same with the alarms
if (isset($event['alarm']) && is_array($event['alarm'])) if (isset($event['alarm']) && is_array($event['alarm']) && isset($event['start']))
{ {
foreach($event['alarm'] as $id => $alarm) foreach($event['alarm'] as $id => $alarm)
{ {
@ -989,14 +989,17 @@ class calendar_boupdate extends calendar_bo
} }
} }
// update all existing alarm times, in case alarm got moved and alarms are not include in $event // update all existing alarm times, in case alarm got moved and alarms are not include in $event
if ($old_event && is_array($old_event['alarm'])) if ($old_event && is_array($old_event['alarm']) && isset($event['start']))
{ {
foreach($old_event['alarm'] as $alarm) foreach($old_event['alarm'] as $id => $alarm)
{
if (!isset($event['alarm'][$id]))
{ {
$alarm['time'] = $event['start'] - $alarm['offset']; $alarm['time'] = $event['start'] - $alarm['offset'];
$this->so->save_alarm($event['id'],$alarm, $this->now); $this->so->save_alarm($event['id'],$alarm, $this->now);
} }
} }
}
// always update modification time (ctag depends on it!) // always update modification time (ctag depends on it!)
$event['modified'] = $this->now; $event['modified'] = $this->now;

View File

@ -557,6 +557,11 @@ class calendar_uiforms extends calendar_ui
$event['reference'] = $event['id']; $event['reference'] = $event['id'];
$event['recurrence'] = $content['edit_single']; $event['recurrence'] = $content['edit_single'];
unset($event['id']); unset($event['id']);
// modifiy alarms for the exception, unsetting alarm-id to create new alarms
foreach($event['alarm'] as $n => &$alarm)
{
unset($alarm['id']);
}
$conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']); $conflicts = $this->bo->update($event,$ignore_conflicts,true,false,true,$messages,$content['no_notifications']);
if (!is_array($conflicts) && $conflicts) if (!is_array($conflicts) && $conflicts)
{ {
@ -564,6 +569,7 @@ class calendar_uiforms extends calendar_ui
$recur_event = $this->bo->read($event['reference']); $recur_event = $this->bo->read($event['reference']);
$recur_event['recur_exception'][] = $content['edit_single']; $recur_event['recur_exception'][] = $content['edit_single'];
unset($recur_event['start']); unset($recur_event['end']); // no update necessary unset($recur_event['start']); unset($recur_event['end']); // no update necessary
unset($recur_event['alarm']); // unsetting alarms too, as they cant be updated without start!
$this->bo->update($recur_event,true); // no conflict check here $this->bo->update($recur_event,true); // no conflict check here
unset($recur_event); unset($recur_event);
unset($event['edit_single']); // if we further edit it, it's just a single event unset($event['edit_single']); // if we further edit it, it's just a single event