Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bug: 14214 Require a non-empty due date too.
While we enfore this in Nag's UI, it wasn't enforced when
adding tasks via the API - like from Kronolith, or external clients.
Even though that is now fixed, we still include this requirement
in the query to catch any existing tasks added like this.

Note: We could use a migration for this, but there already exists
newer migrations in master that make this difficult to handle.
  • Loading branch information
mrubinsk committed Jan 6, 2016
1 parent f4533f0 commit 8fbe715
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/Driver.php
Expand Up @@ -160,7 +160,7 @@ public function add(array $task)
$result = Nag::sendNotification('add', $task);

/* Add an alarm if necessary. */
if (!empty($task->alarm) &&
if (!empty($task->due) && !empty($task->alarm) &&
($alarm = $task->toAlarm())) {
$GLOBALS['injector']->getInstance('Horde_Alarm')->set($alarm);
}
Expand Down Expand Up @@ -302,7 +302,7 @@ public function modify($taskId, array $properties)
/* Update alarm if necessary. */
$horde_alarm = $GLOBALS['injector']->getInstance('Horde_Alarm');
if ((isset($properties['alarm']) && empty($properties['alarm'])) ||
!empty($properties['completed'])) {
!empty($properties['completed']) || empty($task->due)) {
$horde_alarm->delete($task->uid);
} else {
$task = $this->get($taskId);
Expand Down
4 changes: 3 additions & 1 deletion lib/Driver/Sql.php
Expand Up @@ -519,9 +519,11 @@ public function getChildren($parentId, $include_history = true)
*/
public function listAlarms($date)
{
// Check for non-empty alarm AND a non-empty due date.
// See Bug: 14214
$q = 'SELECT * FROM ' . $this->_params['table'] .
' WHERE task_owner = ?' .
' AND task_alarm > 0' .
' AND task_alarm > 0 AND task_due > 0' .
' AND (task_due - (task_alarm * 60) <= ?)' .
' AND task_completed = 0';
$values = array($this->_tasklist, $date);
Expand Down

0 comments on commit 8fbe715

Please sign in to comment.