diff options
author | Timo Litzbarski <tili2@gmx.de> | 2015-09-17 16:27:59 +0000 |
---|---|---|
committer | Timo Litzbarski <tili2@gmx.de> | 2015-09-17 16:27:59 +0000 |
commit | 55ca46ad754b87991e5cc4c4bc26657b19d37830 (patch) | |
tree | 411ed1936d1ae8aa4e96a0b79534eef71bf3a977 | |
parent | 08e09c1cac39eb0836ccf11e1ad411832d424022 (diff) |
#1232 Api changes: new getMyOverdueTasks, new getOverdueTasksByProject, allow getProjectActivity for user-api
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | app/Api/Base.php | 3 | ||||
-rw-r--r-- | app/Api/Me.php | 5 | ||||
-rw-r--r-- | app/Api/Project.php | 1 | ||||
-rw-r--r-- | app/Api/Task.php | 6 | ||||
-rw-r--r-- | app/Model/TaskFinder.php | 64 | ||||
-rw-r--r-- | doc/api-json-rpc.markdown | 96 |
7 files changed, 176 insertions, 0 deletions
@@ -7,6 +7,7 @@ New features: * Add swimlane description * New plugin system (alpha) * Added Bahasa Indonesia translation +* Api changes: new getMyOverdueTasks, new getOverdueTasksByProject, allow getProjectActivity for user-api Breaking changes: diff --git a/app/Api/Base.php b/app/Api/Base.php index 17c7f79f..fe78d99d 100644 --- a/app/Api/Base.php +++ b/app/Api/Base.php @@ -19,6 +19,7 @@ abstract class Base extends \Core\Base 'getMyActivityStream', 'createMyPrivateProject', 'getMyProjectsList', + 'getMyOverdueTasks', ); private $both_allowed_procedures = array( @@ -37,6 +38,8 @@ abstract class Base extends \Core\Base 'createTask', 'updateTask', 'getBoard', + 'getProjectActivity', + 'getOverdueTasksByProject', ); public function checkProcedurePermission($is_user, $procedure) diff --git a/app/Api/Me.php b/app/Api/Me.php index 29a8052a..bc721c09 100644 --- a/app/Api/Me.php +++ b/app/Api/Me.php @@ -52,4 +52,9 @@ class Me extends Base { return $this->projectPermission->getMemberProjects($this->userSession->getId()); } + + public function getMyOverdueTasks() + { + return $this->taskFinder->getOverdueTasksByUser($this->userSession->getId()); + } } diff --git a/app/Api/Project.php b/app/Api/Project.php index c3ae503c..8ed382cb 100644 --- a/app/Api/Project.php +++ b/app/Api/Project.php @@ -58,6 +58,7 @@ class Project extends Base public function getProjectActivity($project_id) { + $this->checkProjectPermission($project_id); return $this->projectActivity->getProject($project_id); } diff --git a/app/Api/Task.php b/app/Api/Task.php index 946a9e88..23a8c5bf 100644 --- a/app/Api/Task.php +++ b/app/Api/Task.php @@ -34,6 +34,12 @@ class Task extends Base { return $this->taskFinder->getOverdueTasks(); } + + public function getOverdueTasksByProject($project_id) + { + $this->checkProjectPermission($project_id); + return $this->taskFinder->getOverdueTasksByProject($project_id); + } public function openTask($task_id) { diff --git a/app/Model/TaskFinder.php b/app/Model/TaskFinder.php index 3e76041c..6cdf9146 100644 --- a/app/Model/TaskFinder.php +++ b/app/Model/TaskFinder.php @@ -206,6 +206,70 @@ class TaskFinder extends Base return $tasks; } + + /** + * Get a list of overdue tasks by project + * + * @access public + * @return array + */ + public function getOverdueTasksByProject($project_id) + { + $tasks = $this->db->table(Task::TABLE) + ->columns( + Task::TABLE.'.id', + Task::TABLE.'.title', + Task::TABLE.'.date_due', + Task::TABLE.'.project_id', + Task::TABLE.'.creator_id', + Task::TABLE.'.owner_id', + Project::TABLE.'.name AS project_name', + User::TABLE.'.username AS assignee_username', + User::TABLE.'.name AS assignee_name' + ) + ->join(Project::TABLE, 'id', 'project_id') + ->join(User::TABLE, 'id', 'owner_id') + ->eq(Project::TABLE.'.is_active', 1) + ->eq(Task::TABLE.'.project_id', $project_id) + ->eq(Task::TABLE.'.is_active', 1) + ->neq(Task::TABLE.'.date_due', 0) + ->lte(Task::TABLE.'.date_due', mktime(23, 59, 59)) + ->findAll(); + + return $tasks; + } + + /** + * Get a list of overdue tasks by user + * + * @access public + * @return array + */ + public function getOverdueTasksByUser($user_id) + { + $tasks = $this->db->table(Task::TABLE) + ->columns( + Task::TABLE.'.id', + Task::TABLE.'.title', + Task::TABLE.'.date_due', + Task::TABLE.'.project_id', + Task::TABLE.'.creator_id', + Task::TABLE.'.owner_id', + Project::TABLE.'.name AS project_name', + User::TABLE.'.username AS assignee_username', + User::TABLE.'.name AS assignee_name' + ) + ->join(Project::TABLE, 'id', 'project_id') + ->join(User::TABLE, 'id', 'owner_id') + ->eq(Project::TABLE.'.is_active', 1) + ->eq(Task::TABLE.'.owner_id', $user_id) + ->eq(Task::TABLE.'.is_active', 1) + ->neq(Task::TABLE.'.date_due', 0) + ->lte(Task::TABLE.'.date_due', mktime(23, 59, 59)) + ->findAll(); + + return $tasks; + } /** * Get project id for a given task diff --git a/doc/api-json-rpc.markdown b/doc/api-json-rpc.markdown index b11f256b..23371669 100644 --- a/doc/api-json-rpc.markdown +++ b/doc/api-json-rpc.markdown @@ -84,6 +84,8 @@ If there is an authentication error, you will receive the HTTP status code `401 - createTask - updateTask - getBoard +- getProjectActivity +- getMyOverdueTasks ### Custom HTTP header @@ -2448,6 +2450,55 @@ Response example: } ``` +### getOverdueTasksByProject + +- Purpose: **Get all overdue tasks for a special project** +- Result on success: **List of tasks** +- Result on failure: **false** + +Request example to fetch all tasks on the board: + +```json +{ + "jsonrpc": "2.0", + "method": "getOverdueTasksByProject", + "id": 133280317, + "params": { + "project_id": 1 + } +} +``` + +Response example: + +```json +{ + "jsonrpc": "2.0", + "id": 133280317, + "result": [ + { + "id": "1", + "title": "Task #1", + "date_due": "1409961789", + "project_id": "1", + "project_name": "Test", + "assignee_username":"admin", + "assignee_name": null + }, + { + "id": "2", + "title": "Test", + "date_due": "1409962115", + "project_id": "1", + "project_name": "Test", + "assignee_username":"admin", + "assignee_name": null + }, + ... + ] +} +``` + ### updateTask - Purpose: **Update a task** @@ -4366,3 +4417,48 @@ Response example: } } ``` +### getMyOverdueTasks + +- Purpose: **Get my overdue tasks** +- Result on success: **List of tasks** +- Result on failure: **false** + +Request example to fetch all tasks on the board: + +```json +{ + "jsonrpc": "2.0", + "method": "getMyOverdueTasks", + "id": 133280317 +} +``` + +Response example: + +```json +{ + "jsonrpc": "2.0", + "id": 133280317, + "result": [ + { + "id": "1", + "title": "Task #1", + "date_due": "1409961789", + "project_id": "1", + "project_name": "Test", + "assignee_username":"admin", + "assignee_name": null + }, + { + "id": "2", + "title": "Test", + "date_due": "1409962115", + "project_id": "1", + "project_name": "Test", + "assignee_username":"admin", + "assignee_name": null + }, + ... + ] +} +``` |