* Calendar: if deleting next recurrance of an event series containing alarms, move alarms to next recurrance, to not alarm for deleted recurance

This commit is contained in:
Ralf Becker 2012-08-14 17:02:34 +00:00
parent 89a10f6234
commit df83423ca3

View File

@ -1447,6 +1447,26 @@ class calendar_boupdate extends calendar_bo
}
else // delete an exception
{
// check if deleted recurrance has alarms (because it's the next recurrance) --> move it to next recurrance
if ($event['alarm'])
{
foreach($event['alarm'] as &$alarm)
{
if ($alarm['time'] == $recur_date)
{
if (is_null($next_recurrance))
{
foreach(calendar_rrule::event2rrule($event, true) as $time)
{
$time->setUser(); // $time is in timezone of event, convert it to usertime used here
if (($next_recurrance = $this->date2ts($time)) > $recur_date) break;
}
}
$alarm['time'] = $this->date2ts($next_recurrance, true); // user to server-time
$this->so->save_alarm($event['id'], $alarm);
}
}
}
// need to read series master, as otherwise existing exceptions will be lost!
$recur_date = $this->date2ts($event['start']);
$event = $this->read($cal_id);