diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-05-16 21:07:29 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-05-16 21:07:29 -0400 |
commit | b1e2ca00ce7375ffcbe5e927135c8892036e6bd6 (patch) | |
tree | 07ce453261f6493de7c901cfd8b4f0d9af85556d /app/Api/MeApi.php | |
parent | 4514bc1d4b4abff23902e46da76e70f13a3647eb (diff) |
Rename Api classes
Diffstat (limited to 'app/Api/MeApi.php')
-rw-r--r-- | app/Api/MeApi.php | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/app/Api/MeApi.php b/app/Api/MeApi.php new file mode 100644 index 00000000..7d46a962 --- /dev/null +++ b/app/Api/MeApi.php @@ -0,0 +1,72 @@ +<?php + +namespace Kanboard\Api; + +use Kanboard\Model\Subtask as SubtaskModel; + +/** + * Me API controller + * + * @package Kanboard\Api + * @author Frederic Guillot + */ +class MeApi extends BaseApi +{ + public function getMe() + { + return $this->sessionStorage->user; + } + + public function getMyDashboard() + { + $user_id = $this->userSession->getId(); + $projects = $this->project->getQueryColumnStats($this->projectPermission->getActiveProjectIds($user_id))->findAll(); + $tasks = $this->taskFinder->getUserQuery($user_id)->findAll(); + + return array( + 'projects' => $this->formatProjects($projects), + 'tasks' => $this->formatTasks($tasks), + 'subtasks' => $this->subtask->getUserQuery($user_id, array(SubTaskModel::STATUS_TODO, SubtaskModel::STATUS_INPROGRESS))->findAll(), + ); + } + + public function getMyActivityStream() + { + $project_ids = $this->projectPermission->getActiveProjectIds($this->userSession->getId()); + return $this->helper->projectActivity->getProjectsEvents($project_ids, 100); + } + + public function createMyPrivateProject($name, $description = null) + { + if ($this->config->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->project->create($values, $this->userSession->getId(), true) : false; + } + + public function getMyProjectsList() + { + return $this->projectUserRole->getProjectsByUser($this->userSession->getId()); + } + + public function getMyOverdueTasks() + { + return $this->taskFinder->getOverdueTasksByUser($this->userSession->getId()); + } + + public function getMyProjects() + { + $project_ids = $this->projectPermission->getActiveProjectIds($this->userSession->getId()); + $projects = $this->project->getAllByIds($project_ids); + + return $this->formatProjects($projects); + } +} |