fixed alarm on series got lost, if creating an exception

This commit is contained in:
Ralf Becker 2011-11-11 12:47:04 +00:00
parent 30bb12b0ea
commit 92a1cf4354
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
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)
{
@ -989,12 +989,15 @@ class calendar_boupdate extends calendar_bo
}
}
// 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)
{
$alarm['time'] = $event['start'] - $alarm['offset'];
$this->so->save_alarm($event['id'],$alarm, $this->now);
if (!isset($event['alarm'][$id]))
{
$alarm['time'] = $event['start'] - $alarm['offset'];
$this->so->save_alarm($event['id'],$alarm, $this->now);
}
}
}

View File

@ -557,6 +557,11 @@ class calendar_uiforms extends calendar_ui
$event['reference'] = $event['id'];
$event['recurrence'] = $content['edit_single'];
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']);
if (!is_array($conflicts) && $conflicts)
{
@ -564,6 +569,7 @@ class calendar_uiforms extends calendar_ui
$recur_event = $this->bo->read($event['reference']);
$recur_event['recur_exception'][] = $content['edit_single'];
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
unset($recur_event);
unset($event['edit_single']); // if we further edit it, it's just a single event