* Calendar: fixed in some cases not updated alarms, if event got moved

- sending alarms to CalDAV/GroupDAV clients as offset, not fixed time like before
- only exception to the above are alarms for recuring events to Lightning, which must be absolute, as offset lead to infinit poping up alarms in Lightning
- update all alarm times of other users alarms too, when storing events, as they might not be included in the stored event
This commit is contained in:
Ralf Becker 2011-03-07 13:49:08 +00:00
parent 7e094f9e67
commit 63e61442c9
2 changed files with 20 additions and 5 deletions

View File

@ -965,7 +965,17 @@ class calendar_boupdate extends calendar_bo
{
foreach($event['alarm'] as $id => $alarm)
{
$event['alarm'][$id]['time'] = $this->date2ts($alarm['time'],true);
// recalculate alarms to also cope with moved events (beside server time adjustment)
$event['alarm'][$id]['time'] = $event['start'] - $alarm['offset'];
}
}
// 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']))
{
foreach($old_event['alarm'] as $alarm)
{
$alarm['time'] = $event['start'] - $alarm['offset'];
$this->so->save_alarm($event['id'],$alarm, $this->now);
}
}
if (!isset($event['modified']) || $event['modified'] > $this->now)

View File

@ -918,7 +918,8 @@ class calendar_ical extends calendar_boupdate
// RFC requires DESCRIPTION for DISPLAY
if (!$event['title'] && !$description) continue;
if ($this->productName == 'lightning')
// Lightning infinitly pops up alarms for recuring events, if the only use an offset
if ($this->productName == 'lightning' && $event['recur_type'] != MCAL_RECUR_NONE)
{
// return only future alarms to lightning
if (($nextOccurence = $this->read($event['id'], $this->now_su + $alarmData['offset'], false, 'server')))
@ -932,14 +933,18 @@ class calendar_ical extends calendar_boupdate
}
}
if (!empty($event['whole_day']) && $alarmData['offset'])
// for SyncML non-whole-day events always use absolute times
// (probably because some devices have no clue about timezones)
// GroupDAV uses offsets, as web UI assumes alarms are relative too
// (with absolute times GroupDAV clients do NOT move alarms, if events move!)
if ($this->productManufacturer != 'GroupDAV' &&
!empty($event['whole_day']) && $alarmData['offset'])
{
$alarmData['time'] = $event['start'] - $alarmData['offset'];
$alarmData['offset'] = false;
}
$valarm = Horde_iCalendar::newComponent('VALARM',$vevent);
if ($alarmData['offset'])
if ($alarmData['offset'] !== false)
{
$valarm->setAttribute('TRIGGER', -$alarmData['offset'],
array('VALUE' => 'DURATION', 'RELATED' => 'START'));