diff options
Diffstat (limited to 'app')
-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 |
5 files changed, 79 insertions, 0 deletions
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 |