Fix displaying calendar alarms
This commit is contained in:
parent
bca2a7d314
commit
f3761f1d02
3 changed files with 20 additions and 24 deletions
|
@ -1797,10 +1797,6 @@ class kolab_driver extends calendar_driver
|
|||
}
|
||||
|
||||
foreach ($candidates as $id => $alarm) {
|
||||
if (!array_key_exists($id, $dbdata)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// skip dismissed alarms
|
||||
if (!empty($dbdata[$id]['dismissed'])) {
|
||||
continue;
|
||||
|
|
|
@ -696,11 +696,9 @@ class libcalendaring extends rcube_plugin
|
|||
}
|
||||
}
|
||||
|
||||
// alarm ID eq. record ID by default to keep backwards compatibility
|
||||
$alarm_id = $rec['id'] ?? null;
|
||||
$alarm_prop = null;
|
||||
$expires = new DateTime('now - 12 hours');
|
||||
$notify_at = null;
|
||||
$expires = new DateTime('now - 12 hours');
|
||||
$result = null;
|
||||
$notify_at = null;
|
||||
|
||||
// handle multiple alarms
|
||||
foreach ($rec['valarms'] as $alarm) {
|
||||
|
@ -730,24 +728,24 @@ class libcalendaring extends rcube_plugin
|
|||
}
|
||||
|
||||
if ($notify_time && (!$notify_at || ($notify_time > $notify_at && $notify_time > $expires))) {
|
||||
$notify_at = $notify_time;
|
||||
$action = $alarm['action'] ?? null;
|
||||
$alarm_prop = $alarm;
|
||||
$alarm_id = substr(md5($rec['id'] ?? ($rec['uid'] ?? 'none')), 0, 16);
|
||||
$notify_at = $notify_time;
|
||||
|
||||
// generate a unique alarm ID if multiple alarms are set
|
||||
if (count($rec['valarms']) > 1) {
|
||||
$rec_id = substr(md5($rec['id'] ?? 'none'), 0, 16);
|
||||
$alarm_id = $rec_id . '-' . $notify_at->format('Ymd\THis');
|
||||
$alarm_id = $alarm_id . '-' . $notify_at->format('Ymd\THis');
|
||||
}
|
||||
|
||||
$result = [
|
||||
'time' => $notify_at->format('U'),
|
||||
'action' => !empty($alarm['action']) ? strtoupper($alarm['action']) : 'DISPLAY',
|
||||
'id' => $alarm_id,
|
||||
'prop' => $alarm,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return !$notify_at ? null : [
|
||||
'time' => $notify_at->format('U'),
|
||||
'action' => !empty($action) ? strtoupper($action) : 'DISPLAY',
|
||||
'id' => $alarm_id,
|
||||
'prop' => $alarm_prop,
|
||||
];
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -776,10 +774,11 @@ class libcalendaring extends rcube_plugin
|
|||
*/
|
||||
public function alarms_action()
|
||||
{
|
||||
// $action = rcube_utils::get_input_value('action', rcube_utils::INPUT_GPC);
|
||||
$data = rcube_utils::get_input_value('data', rcube_utils::INPUT_POST, true);
|
||||
$data = rcube_utils::get_input_value('data', rcube_utils::INPUT_POST, true);
|
||||
|
||||
$data['ids'] = explode(',', $data['id']);
|
||||
$data['success'] = false;
|
||||
|
||||
$plugin = $this->rc->plugins->exec_hook('dismiss_alarms', $data);
|
||||
|
||||
if (!empty($plugin['success'])) {
|
||||
|
@ -803,8 +802,7 @@ class libcalendaring extends rcube_plugin
|
|||
'allDay' => !empty($alarm['allday']),
|
||||
'action' => $alarm['action'],
|
||||
'title' => $alarm['title'],
|
||||
'location' => $alarm['location'],
|
||||
'calendar' => $alarm['calendar'],
|
||||
'location' => $alarm['location'] ?? null,
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -1540,6 +1540,7 @@ class tasklist extends rcube_plugin
|
|||
public function pending_alarms($p)
|
||||
{
|
||||
$this->load_driver();
|
||||
|
||||
if ($alarms = $this->driver->pending_alarms($p['time'] ?: time())) {
|
||||
foreach ($alarms as $alarm) {
|
||||
// encode alarm object to suit the expectations of the calendaring code
|
||||
|
@ -1562,6 +1563,7 @@ class tasklist extends rcube_plugin
|
|||
public function dismiss_alarms($p)
|
||||
{
|
||||
$this->load_driver();
|
||||
|
||||
foreach ((array)$p['ids'] as $id) {
|
||||
if (strpos($id, 'task:') === 0) {
|
||||
$p['success'] |= $this->driver->dismiss_alarm(substr($id, 5), $p['snooze']);
|
||||
|
|
Loading…
Add table
Reference in a new issue