Fix event fetching and alarms handling in Kolab backend
This commit is contained in:
parent
35ea790ff5
commit
ab3801d67f
2 changed files with 12 additions and 13 deletions
|
@ -356,6 +356,7 @@ class kolab_calendar
|
||||||
'end' => $rec['end-date'],
|
'end' => $rec['end-date'],
|
||||||
'allday' => $allday,
|
'allday' => $allday,
|
||||||
'recurrence' => $rrule,
|
'recurrence' => $rrule,
|
||||||
|
'_alarm' => $rec['alarm'],
|
||||||
'alarms' => $alarm_value . $alarm_unit,
|
'alarms' => $alarm_value . $alarm_unit,
|
||||||
'categories' => $rec['categories'],
|
'categories' => $rec['categories'],
|
||||||
'free_busy' => $rec['show-time-as'],
|
'free_busy' => $rec['show-time-as'],
|
||||||
|
|
|
@ -291,7 +291,7 @@ class kolab_driver extends calendar_driver
|
||||||
if ($calendars && !in_array($cid, $calendars))
|
if ($calendars && !in_array($cid, $calendars))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
$events = array_merge($this->folders[$cid]->list_events($start, $end, $search));
|
$events = array_merge($events, $this->folders[$cid]->list_events($start, $end, $search));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $events;
|
return $events;
|
||||||
|
@ -317,9 +317,9 @@ class kolab_driver extends calendar_driver
|
||||||
public function pending_alarms($time, $calendars = null)
|
public function pending_alarms($time, $calendars = null)
|
||||||
{
|
{
|
||||||
$events = array();
|
$events = array();
|
||||||
foreach ($this->load_events($time, $time + 86400 * 365) as $e) {
|
foreach ($this->load_events($time, $time + 86400 * 365, $calendars) as $e) {
|
||||||
// add to list if alarm is set
|
// add to list if alarm is set
|
||||||
if ($e['alarm'] && ($notifyat = $e['start'] - $e['alarm'] * 60) <= $time) {
|
if ($e['_alarm'] && ($notifyat = $e['start'] - $e['_alarm'] * 60) <= $time) {
|
||||||
$id = $e['id'];
|
$id = $e['id'];
|
||||||
$events[$id] = $e;
|
$events[$id] = $e;
|
||||||
$events[$id]['notifyat'] = $notifyat;
|
$events[$id]['notifyat'] = $notifyat;
|
||||||
|
@ -328,12 +328,10 @@ class kolab_driver extends calendar_driver
|
||||||
|
|
||||||
// get alarm information stored in local database
|
// get alarm information stored in local database
|
||||||
if (!empty($events)) {
|
if (!empty($events)) {
|
||||||
$event_ids = array_keys($events);
|
$event_ids = array_map(array($this->rc->db, 'quote'), array_keys($events));
|
||||||
array_walk($event_ids, array($this->rc->db, 'quote'));
|
|
||||||
$result = $this->rc->db->query(sprintf(
|
$result = $this->rc->db->query(sprintf(
|
||||||
"SELECT * FROM kolab_alarms
|
"SELECT * FROM kolab_alarms
|
||||||
WHERE event_id IN (%s)
|
WHERE event_id IN (%s)",
|
||||||
AND notifyat <= %s",
|
|
||||||
join(',', $event_ids),
|
join(',', $event_ids),
|
||||||
$this->rc->db->now()
|
$this->rc->db->now()
|
||||||
));
|
));
|
||||||
|
@ -350,7 +348,7 @@ class kolab_driver extends calendar_driver
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// snooze function may have shifted alarm time
|
// snooze function may have shifted alarm time
|
||||||
$notifyat = $dbdata['notifyat'] ? strtotime($notifyat) : $e['notifyat'];
|
$notifyat = $dbdata[$id]['notifyat'] ? strtotime($dbdata[$id]['notifyat']) : $e['notifyat'];
|
||||||
if ($notifyat <= $time)
|
if ($notifyat <= $time)
|
||||||
$alarms[] = $e;
|
$alarms[] = $e;
|
||||||
}
|
}
|
||||||
|
@ -369,12 +367,12 @@ class kolab_driver extends calendar_driver
|
||||||
$notifyat = $snooze > 0 ? date('Y-m-d H:i:s', time() + $snooze) : null;
|
$notifyat = $snooze > 0 ? date('Y-m-d H:i:s', time() + $snooze) : null;
|
||||||
|
|
||||||
$query = $this->rc->db->query(
|
$query = $this->rc->db->query(
|
||||||
"UPDATE kolab_alarms
|
"REPLACE INTO kolab_alarms
|
||||||
SET dismissed=?, notifyat=?
|
(event_id, dismissed, notifyat)
|
||||||
WHERE event_id=?",
|
VALUES(?, ?, ?)",
|
||||||
|
$event_id,
|
||||||
$snooze > 0 ? 0 : 1,
|
$snooze > 0 ? 0 : 1,
|
||||||
$notifyat,
|
$notifyat
|
||||||
$event_id
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this->rc->db->affected_rows($query);
|
return $this->rc->db->affected_rows($query);
|
||||||
|
|
Loading…
Add table
Reference in a new issue