mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-22 16:03:47 +01:00
patch from Achim Koenigs <achim-at-tratschtante.de> to shift alarms of recurring events to first future recurrent, so they get stored, modified to not doublicate code
This commit is contained in:
parent
99d11f58b3
commit
5bab15b433
@ -1443,6 +1443,10 @@ class calendar_ical extends calendar_boupdate
|
||||
// if no edit rights, allow participants to set alarms directly (like status)
|
||||
if ($event_info['stored_event'] && !$event_info['acl_edit'])
|
||||
{
|
||||
if ($alarm['time'] < time() && !calendar_so::shift_alarm($event, $alarm))
|
||||
{
|
||||
continue; //pgoerzen: don't add an alarm in the past
|
||||
}
|
||||
$this->save_alarm($event_info['stored_event']['id'], $alarm);
|
||||
}
|
||||
|
||||
|
@ -1263,22 +1263,9 @@ ORDER BY cal_user_type, cal_usre_id
|
||||
$alarm['time'] = $event['cal_start'] - $alarm['offset'];
|
||||
}
|
||||
|
||||
if ($alarm['time'] < time())
|
||||
if ($alarm['time'] < time() && !self::shift_alarm($event, $alarm))
|
||||
{
|
||||
//pgoerzen: don't add an alarm in the past
|
||||
if ($event['recur_type'] == MCAL_RECUR_NONE) continue;
|
||||
$start = (int)time() + $alarm['offset'];
|
||||
$event['start'] = $event['cal_start'];
|
||||
$event['end'] = $event['cal_end'];
|
||||
$event['tzid'] = $event['cal_tzid'];
|
||||
$rrule = calendar_rrule::event2rrule($event, false);
|
||||
foreach ($rrule as $time)
|
||||
{
|
||||
if ($start < ($ts = egw_time::to($time,'server'))) break;
|
||||
$ts = 0;
|
||||
}
|
||||
if (!$ts) continue;
|
||||
$alarm['time'] = $ts - $alarm['offset'];
|
||||
continue; // pgoerzen: don't add alarm in the past
|
||||
}
|
||||
$this->save_alarm($cal_id,$alarm);
|
||||
}
|
||||
@ -1290,6 +1277,33 @@ ORDER BY cal_user_type, cal_usre_id
|
||||
return $cal_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shift alarm on recurring events to next future recurrence
|
||||
*
|
||||
* @param array $event event with optional 'cal_' prefix in keys
|
||||
* @param array &$alarm
|
||||
* @return boolean true if alarm could be shifted, false if not
|
||||
*/
|
||||
public static function shift_alarm(array $event, array &$alarm)
|
||||
{
|
||||
if ($event['recur_type'] == MCAL_RECUR_NONE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$start = (int)time() + $alarm['offset'];
|
||||
egw_db::strip_array_keys($event, 'cal_');
|
||||
$rrule = calendar_rrule::event2rrule($event, false);
|
||||
foreach ($rrule as $time)
|
||||
{
|
||||
if ($start < ($ts = egw_time::to($time,'server')))
|
||||
{
|
||||
$alarm['time'] = $ts - $alarm['offset'];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* moves an event to an other start- and end-time taken into account the evtl. recurrences of the event(!)
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user