Reset alarms when re-iterating recurring events; fix computing of weekly recurrence dates
This commit is contained in:
parent
a0ac82793b
commit
8a613b5b11
4 changed files with 41 additions and 4 deletions
|
@ -470,6 +470,16 @@ class tasklist_database_driver extends tasklist_driver
|
|||
return $this->rc->db->affected_rows($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove alarm dismissal or snooze state
|
||||
*
|
||||
* @param string Task identifier
|
||||
*/
|
||||
public function clear_alarms($id)
|
||||
{
|
||||
// Nothing to do here. Alarms are reset in edit_task()
|
||||
}
|
||||
|
||||
/**
|
||||
* Map some internal database values to match the generic "API"
|
||||
*/
|
||||
|
|
|
@ -572,6 +572,24 @@ class tasklist_kolab_driver extends tasklist_driver
|
|||
return $this->rc->db->affected_rows($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove alarm dismissal or snooze state
|
||||
*
|
||||
* @param string Task identifier
|
||||
*/
|
||||
public function clear_alarms($id)
|
||||
{
|
||||
// delete alarm entry
|
||||
$this->rc->db->query(
|
||||
"DELETE FROM kolab_alarms
|
||||
WHERE alarm_id=? AND user_id=?",
|
||||
$id,
|
||||
$this->rc->user->ID
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert from Kolab_Format to internal representation
|
||||
*/
|
||||
|
|
|
@ -152,6 +152,13 @@ abstract class tasklist_driver
|
|||
*/
|
||||
abstract function dismiss_alarm($id, $snooze = 0);
|
||||
|
||||
/**
|
||||
* Remove alarm dismissal or snooze state
|
||||
*
|
||||
* @param string Task identifier
|
||||
*/
|
||||
abstract public function clear_alarms($id);
|
||||
|
||||
/**
|
||||
* Return data of a specific task
|
||||
*
|
||||
|
|
|
@ -205,6 +205,7 @@ class tasklist extends rcube_plugin
|
|||
// add clone from recurring task
|
||||
if ($clone && $this->driver->create_task($clone)) {
|
||||
$refresh[] = $this->driver->get_task($clone);
|
||||
$this->driver->clear_alarms($rec['id']);
|
||||
}
|
||||
|
||||
// move all childs if list assignment was changed
|
||||
|
@ -526,13 +527,15 @@ class tasklist extends rcube_plugin
|
|||
if ($rec['complete'] == 1.0 && $old && $old['complete'] < 1.0 && is_array($rec['recurrence'])) {
|
||||
$engine = libcalendaring::get_recurrence();
|
||||
$rrule = $rec['recurrence'];
|
||||
$engine->init($rrule);
|
||||
$updates = array();
|
||||
|
||||
// compute the next occurrence of date attributes
|
||||
foreach (array('date'=>'time', 'startdate'=>'starttime') as $date_key => $time_key) {
|
||||
if (empty($rec[$date_key]))
|
||||
continue;
|
||||
|
||||
$date = new DateTime($rec[$date_key] . ' ' . $rec[$time_key], $this->timezone);
|
||||
$engine->set_start($date);
|
||||
$engine->init($rrule, $date);
|
||||
if ($next = $engine->next()) {
|
||||
$updates[$date_key] = $next->format('Y-m-d');
|
||||
if (!empty($rec[$time_key]))
|
||||
|
@ -544,11 +547,10 @@ class tasklist extends rcube_plugin
|
|||
if (!empty($updates) && is_array($rec['valarms'])) {
|
||||
$updates['valarms'] = array();
|
||||
unset($rrule['UNTIL'], $rrule['COUNT']); // make recurrence rule unlimited
|
||||
$engine->init($rrule);
|
||||
|
||||
foreach ($rec['valarms'] as $i => $alarm) {
|
||||
if ($alarm['trigger'] instanceof DateTime) {
|
||||
$engine->set_start($alarm['trigger']);
|
||||
$engine->init($rrule, $alarm['trigger']);
|
||||
if ($next = $engine->next()) {
|
||||
$alarm['trigger'] = $next;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue