diff options
author | i00171 <anton.delitsch@implema.se> | 2016-06-26 18:35:25 +0200 |
---|---|---|
committer | i00171 <anton.delitsch@implema.se> | 2016-06-26 18:35:25 +0200 |
commit | 47039d32c84ba699867920d2c3cb47a34b199b9d (patch) | |
tree | 4fbc2ec34889baeab00085e0509055dca7daee6a /app/Api/Procedure/MeProcedure.php | |
parent | 911be6ed00c1ece5d9ef2c16e80899bb7bffad67 (diff) | |
parent | c110dffefe259c13e60193fb81ebb9d4b79504de (diff) |
Merge branch 'master' of https://github.com/fguillot/kanboard
Diffstat (limited to 'app/Api/Procedure/MeProcedure.php')
-rw-r--r-- | app/Api/Procedure/MeProcedure.php | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/app/Api/Procedure/MeProcedure.php b/app/Api/Procedure/MeProcedure.php new file mode 100644 index 00000000..e59e6522 --- /dev/null +++ b/app/Api/Procedure/MeProcedure.php @@ -0,0 +1,72 @@ +<?php + +namespace Kanboard\Api\Procedure; + +use Kanboard\Model\SubtaskModel; + +/** + * Me API controller + * + * @package Kanboard\Api\Procedure + * @author Frederic Guillot + */ +class MeProcedure extends BaseProcedure +{ + public function getMe() + { + return $this->sessionStorage->user; + } + + public function getMyDashboard() + { + $user_id = $this->userSession->getId(); + $projects = $this->projectModel->getQueryColumnStats($this->projectPermissionModel->getActiveProjectIds($user_id))->findAll(); + $tasks = $this->taskFinderModel->getUserQuery($user_id)->findAll(); + + return array( + 'projects' => $this->formatProjects($projects), + 'tasks' => $this->formatTasks($tasks), + 'subtasks' => $this->subtaskModel->getUserQuery($user_id, array(SubtaskModel::STATUS_TODO, SubtaskModel::STATUS_INPROGRESS))->findAll(), + ); + } + + public function getMyActivityStream() + { + $project_ids = $this->projectPermissionModel->getActiveProjectIds($this->userSession->getId()); + return $this->helper->projectActivity->getProjectsEvents($project_ids, 100); + } + + public function createMyPrivateProject($name, $description = null) + { + if ($this->configModel->get('disable_private_project', 0) == 1) { + return false; + } + + $values = array( + 'name' => $name, + 'description' => $description, + 'is_private' => 1, + ); + + list($valid, ) = $this->projectValidator->validateCreation($values); + return $valid ? $this->projectModel->create($values, $this->userSession->getId(), true) : false; + } + + public function getMyProjectsList() + { + return $this->projectUserRoleModel->getProjectsByUser($this->userSession->getId()); + } + + public function getMyOverdueTasks() + { + return $this->taskFinderModel->getOverdueTasksByUser($this->userSession->getId()); + } + + public function getMyProjects() + { + $project_ids = $this->projectPermissionModel->getActiveProjectIds($this->userSession->getId()); + $projects = $this->projectModel->getAllByIds($project_ids); + + return $this->formatProjects($projects); + } +} |