summaryrefslogtreecommitdiff
path: root/app/Api/Me.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/Api/Me.php')
-rw-r--r--app/Api/Me.php55
1 files changed, 55 insertions, 0 deletions
diff --git a/app/Api/Me.php b/app/Api/Me.php
new file mode 100644
index 00000000..29a8052a
--- /dev/null
+++ b/app/Api/Me.php
@@ -0,0 +1,55 @@
+<?php
+
+namespace Api;
+
+use Model\Subtask as SubtaskModel;
+use Model\Task as TaskModel;
+
+/**
+ * Me API controller
+ *
+ * @package api
+ * @author Frederic Guillot
+ */
+class Me extends Base
+{
+ public function getMe()
+ {
+ return $this->session['user'];
+ }
+
+ public function getMyDashboard()
+ {
+ $user_id = $this->userSession->getId();
+ $projects = $this->project->getQueryColumnStats($this->projectPermission->getActiveMemberProjectIds($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()
+ {
+ return $this->projectActivity->getProjects($this->projectPermission->getActiveMemberProjectIds($this->userSession->getId()), 100);
+ }
+
+ public function createMyPrivateProject($name, $description = null)
+ {
+ $values = array(
+ 'name' => $name,
+ 'description' => $description,
+ 'is_private' => 1,
+ );
+
+ list($valid,) = $this->project->validateCreation($values);
+ return $valid ? $this->project->create($values, $this->userSession->getId(), true) : false;
+ }
+
+ public function getMyProjectsList()
+ {
+ return $this->projectPermission->getMemberProjects($this->userSession->getId());
+ }
+}