summaryrefslogtreecommitdiff
path: root/app/Api/Task.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-05-16 21:07:29 -0400
committerFrederic Guillot <fred@kanboard.net>2016-05-16 21:07:29 -0400
commitb1e2ca00ce7375ffcbe5e927135c8892036e6bd6 (patch)
tree07ce453261f6493de7c901cfd8b4f0d9af85556d /app/Api/Task.php
parent4514bc1d4b4abff23902e46da76e70f13a3647eb (diff)
Rename Api classes
Diffstat (limited to 'app/Api/Task.php')
-rw-r--r--app/Api/Task.php169
1 files changed, 0 insertions, 169 deletions
diff --git a/app/Api/Task.php b/app/Api/Task.php
deleted file mode 100644
index 1d1211f2..00000000
--- a/app/Api/Task.php
+++ /dev/null
@@ -1,169 +0,0 @@
-<?php
-
-namespace Kanboard\Api;
-
-use Kanboard\Filter\TaskProjectFilter;
-use Kanboard\Model\Task as TaskModel;
-
-/**
- * Task API controller
- *
- * @package api
- * @author Frederic Guillot
- */
-class Task extends Base
-{
- public function searchTasks($project_id, $query)
- {
- $this->checkProjectPermission($project_id);
- return $this->taskLexer->build($query)->withFilter(new TaskProjectFilter($project_id))->toArray();
- }
-
- public function getTask($task_id)
- {
- $this->checkTaskPermission($task_id);
- return $this->formatTask($this->taskFinder->getById($task_id));
- }
-
- public function getTaskByReference($project_id, $reference)
- {
- $this->checkProjectPermission($project_id);
- return $this->formatTask($this->taskFinder->getByReference($project_id, $reference));
- }
-
- public function getAllTasks($project_id, $status_id = TaskModel::STATUS_OPEN)
- {
- $this->checkProjectPermission($project_id);
- return $this->formatTasks($this->taskFinder->getAll($project_id, $status_id));
- }
-
- public function getOverdueTasks()
- {
- return $this->taskFinder->getOverdueTasks();
- }
-
- public function getOverdueTasksByProject($project_id)
- {
- $this->checkProjectPermission($project_id);
- return $this->taskFinder->getOverdueTasksByProject($project_id);
- }
-
- public function openTask($task_id)
- {
- $this->checkTaskPermission($task_id);
- return $this->taskStatus->open($task_id);
- }
-
- public function closeTask($task_id)
- {
- $this->checkTaskPermission($task_id);
- return $this->taskStatus->close($task_id);
- }
-
- public function removeTask($task_id)
- {
- return $this->task->remove($task_id);
- }
-
- public function moveTaskPosition($project_id, $task_id, $column_id, $position, $swimlane_id = 0)
- {
- $this->checkProjectPermission($project_id);
- return $this->taskPosition->movePosition($project_id, $task_id, $column_id, $position, $swimlane_id);
- }
-
- public function moveTaskToProject($task_id, $project_id, $swimlane_id = null, $column_id = null, $category_id = null, $owner_id = null)
- {
- return $this->taskDuplication->moveToProject($task_id, $project_id, $swimlane_id, $column_id, $category_id, $owner_id);
- }
-
- public function duplicateTaskToProject($task_id, $project_id, $swimlane_id = null, $column_id = null, $category_id = null, $owner_id = null)
- {
- return $this->taskDuplication->duplicateToProject($task_id, $project_id, $swimlane_id, $column_id, $category_id, $owner_id);
- }
-
- public function createTask($title, $project_id, $color_id = '', $column_id = 0, $owner_id = 0, $creator_id = 0,
- $date_due = '', $description = '', $category_id = 0, $score = 0, $swimlane_id = 0, $priority = 0,
- $recurrence_status = 0, $recurrence_trigger = 0, $recurrence_factor = 0, $recurrence_timeframe = 0,
- $recurrence_basedate = 0, $reference = '')
- {
- $this->checkProjectPermission($project_id);
-
- if ($owner_id !== 0 && ! $this->projectPermission->isAssignable($project_id, $owner_id)) {
- return false;
- }
-
- if ($this->userSession->isLogged()) {
- $creator_id = $this->userSession->getId();
- }
-
- $values = array(
- 'title' => $title,
- 'project_id' => $project_id,
- 'color_id' => $color_id,
- 'column_id' => $column_id,
- 'owner_id' => $owner_id,
- 'creator_id' => $creator_id,
- 'date_due' => $date_due,
- 'description' => $description,
- 'category_id' => $category_id,
- 'score' => $score,
- 'swimlane_id' => $swimlane_id,
- 'recurrence_status' => $recurrence_status,
- 'recurrence_trigger' => $recurrence_trigger,
- 'recurrence_factor' => $recurrence_factor,
- 'recurrence_timeframe' => $recurrence_timeframe,
- 'recurrence_basedate' => $recurrence_basedate,
- 'reference' => $reference,
- 'priority' => $priority,
- );
-
- list($valid, ) = $this->taskValidator->validateCreation($values);
-
- return $valid ? $this->taskCreation->create($values) : false;
- }
-
- public function updateTask($id, $title = null, $color_id = null, $owner_id = null,
- $date_due = null, $description = null, $category_id = null, $score = null, $priority = null,
- $recurrence_status = null, $recurrence_trigger = null, $recurrence_factor = null,
- $recurrence_timeframe = null, $recurrence_basedate = null, $reference = null)
- {
- $this->checkTaskPermission($id);
-
- $project_id = $this->taskFinder->getProjectId($id);
-
- if ($project_id === 0) {
- return false;
- }
-
- if ($owner_id !== null && $owner_id != 0 && ! $this->projectPermission->isAssignable($project_id, $owner_id)) {
- return false;
- }
-
- $values = array(
- 'id' => $id,
- 'title' => $title,
- 'color_id' => $color_id,
- 'owner_id' => $owner_id,
- 'date_due' => $date_due,
- 'description' => $description,
- 'category_id' => $category_id,
- 'score' => $score,
- 'recurrence_status' => $recurrence_status,
- 'recurrence_trigger' => $recurrence_trigger,
- 'recurrence_factor' => $recurrence_factor,
- 'recurrence_timeframe' => $recurrence_timeframe,
- 'recurrence_basedate' => $recurrence_basedate,
- 'reference' => $reference,
- 'priority' => $priority,
- );
-
- foreach ($values as $key => $value) {
- if (is_null($value)) {
- unset($values[$key]);
- }
- }
-
- list($valid) = $this->taskValidator->validateApiModification($values);
- return $valid && $this->taskModification->update($values);
- }
-}