Add task links (Merge pull-request #610)

This commit is contained in:
Frederic Guillot
2015-02-13 17:50:20 -05:00
parent 124f7cad28
commit 364382b1b5
38 changed files with 1769 additions and 41 deletions

View File

@@ -3,6 +3,7 @@
namespace Model;
use PDO;
use Model\TaskLink;
/**
* Task Finder model
@@ -84,6 +85,7 @@ class TaskFinder extends Base
'(SELECT count(*) FROM task_has_files WHERE task_id=tasks.id) AS nb_files',
'(SELECT count(*) FROM task_has_subtasks WHERE task_id=tasks.id) AS nb_subtasks',
'(SELECT count(*) FROM task_has_subtasks WHERE task_id=tasks.id AND status=2) AS nb_completed_subtasks',
'(SELECT count(*) FROM ' . TaskLink::TABLE . ' WHERE ' . TaskLink::TABLE . '.task_id = tasks.id) AS nb_links',
'tasks.id',
'tasks.reference',
'tasks.title',
@@ -128,6 +130,29 @@ class TaskFinder extends Base
->asc('tasks.position')
->findAll();
}
/**
* Get ids and names of all (limited by $limit) tasks for a given project and status
*
* @access public
* @param integer $project_id Project id
* @param integer $status_id Status id
* @param integer $exclude_id Exclude this task id in the result
* @param integer $limit Number of tasks to list
* @return array
*/
public function getList($project_id, $status_id = Task::STATUS_OPEN, $exclude_id=null, $limit=50)
{
$sql = $this->db
->hashtable(Task::TABLE)
->eq('project_id', $project_id)
->eq('is_active', $status_id)
->limit($limit);
if (null != $exclude_id) {
$sql->neq('id', $exclude_id);
}
return $sql->getAll('id', 'title');
}
/**
* Get all tasks for a given project and status