Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 34 additions & 3 deletions lib/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -803,20 +803,26 @@ public function path_delete($path)
* Returns an array of UIDs for all tasks that the current user is authorized
* to see.
*
* @param mixed $tasklists The tasklist or an array of taskslists to list.
* @param mixed $tasklists The tasklist or an array of taskslists to list.
* @param integer $completed Which tasks to retrieve. One of the
* Nag::VIEW_* constants. Defaults to all.
*
* @return array An array of UIDs for all tasks
* the user can access.
*
* @throws Horde_Exception_PermissionDenied
* @throws Nag_Exception
*/
public function listUids($tasklists = null)
public function listUids($tasklists = null, $completed = null)
{
if (!isset($GLOBALS['conf']['storage']['driver'])) {
throw new Nag_Exception(_("Not configured"));
}

if ($completed === null) {
$completed = Nag::VIEW_ALL;
}

if (empty($tasklists)) {
$tasklists = Nag::getSyncLists();
} else {
Expand All @@ -833,7 +839,7 @@ public function listUids($tasklists = null)
$tasks = Nag::listTasks(
[
'tasklists' => $tasklists,
'completed' => Nag::VIEW_ALL,
'completed' => $completed,
'include_history' => false]
);
$uids = [];
Expand All @@ -845,6 +851,31 @@ public function listUids($tasklists = null)
return $uids;
}

/**
* Returns whether the specified task is marked complete.
*
* @param string $uid The task uid.
* @param string $tasklist The tasklist id, or null to search sync lists.
*
* @return boolean
*/
public function isComplete($uid, $tasklist = null)
{
if ($tasklist === null) {
foreach (Nag::getSyncLists() as $list) {
try {
return Nag::getTask($list, $uid)->completed;
} catch (Horde_Exception $e) {
continue;
}
}

return false;
}

return Nag::getTask($tasklist, $uid)->completed;
}

/**
* Returns an array of UIDs for tasks that have had $action happen since
* $timestamp.
Expand Down
Loading