diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/Api/Procedure/TaskMetadataProcedure.php | 38 | ||||
-rw-r--r-- | app/Api/Procedure/TaskProcedure.php | 27 | ||||
-rw-r--r-- | app/ServiceProvider/ApiProvider.php | 2 |
3 files changed, 41 insertions, 26 deletions
diff --git a/app/Api/Procedure/TaskMetadataProcedure.php b/app/Api/Procedure/TaskMetadataProcedure.php new file mode 100644 index 00000000..169482f5 --- /dev/null +++ b/app/Api/Procedure/TaskMetadataProcedure.php @@ -0,0 +1,38 @@ +<?php + +namespace Kanboard\Api\Procedure; + +use Kanboard\Api\Authorization\TaskAuthorization; + +/** + * Class TaskMetadataProcedure + * + * @package Kanboard\Api\Procedure + * @author Frederic Guillot + */ +class TaskMetadataProcedure extends BaseProcedure +{ + public function getTaskMetadata($task_id) + { + TaskAuthorization::getInstance($this->container)->check($this->getClassName(), 'getTask', $task_id); + return $this->taskMetadataModel->getAll($task_id); + } + + public function getTaskMetadataByName($task_id, $name) + { + TaskAuthorization::getInstance($this->container)->check($this->getClassName(), 'getTask', $task_id); + return $this->taskMetadataModel->get($task_id, $name); + } + + public function saveTaskMetadata($task_id, array $values) + { + TaskAuthorization::getInstance($this->container)->check($this->getClassName(), 'updateTask', $task_id); + return $this->taskMetadataModel->save($task_id, $values); + } + + public function removeTaskMetadata($task_id, $name) + { + TaskAuthorization::getInstance($this->container)->check($this->getClassName(), 'updateTask', $task_id); + return $this->taskMetadataModel->remove($task_id, $name); + } +} diff --git a/app/Api/Procedure/TaskProcedure.php b/app/Api/Procedure/TaskProcedure.php index 59075b13..ee9242d1 100644 --- a/app/Api/Procedure/TaskProcedure.php +++ b/app/Api/Procedure/TaskProcedure.php @@ -6,7 +6,6 @@ use Kanboard\Api\Authorization\ProjectAuthorization; use Kanboard\Api\Authorization\TaskAuthorization; use Kanboard\Filter\TaskProjectFilter; use Kanboard\Model\TaskModel; -use Kanboard\Model\TaskMetadataModel; /** * Task API controller @@ -16,30 +15,6 @@ use Kanboard\Model\TaskMetadataModel; */ class TaskProcedure extends BaseProcedure { - public function getTaskMetadata($task_id) - { - TaskAuthorization::getInstance($this->container)->check($this->getClassName(), 'getTask', $task_id); - return $this->taskMetadataModel->getAll($task_id); - } - - public function getTaskMetadataByName($task_id, $name) - { - TaskAuthorization::getInstance($this->container)->check($this->getClassName(), 'getTask', $task_id); - return $this->taskMetadataModel->get($task_id, $name); - } - - public function saveTaskMetadata($task_id, array $values) - { - TaskAuthorization::getInstance($this->container)->check($this->getClassName(), 'updateTask', $task_id); - return $this->taskMetadataModel->save($task_id, $values); - } - - public function removeTaskMetadata($task_id, $name) - { - TaskAuthorization::getInstance($this->container)->check($this->getClassName(), 'updateTask', $task_id); - return $this->taskMetadataModel->remove($task_id, $name); - } - public function searchTasks($project_id, $query) { ProjectAuthorization::getInstance($this->container)->check($this->getClassName(), 'searchTasks', $project_id); @@ -117,7 +92,7 @@ class TaskProcedure extends BaseProcedure $recurrence_basedate = 0, $reference = '') { ProjectAuthorization::getInstance($this->container)->check($this->getClassName(), 'createTask', $project_id); - + if ($owner_id !== 0 && ! $this->projectPermissionModel->isAssignable($project_id, $owner_id)) { return false; } diff --git a/app/ServiceProvider/ApiProvider.php b/app/ServiceProvider/ApiProvider.php index 5cf6231c..d5d1f260 100644 --- a/app/ServiceProvider/ApiProvider.php +++ b/app/ServiceProvider/ApiProvider.php @@ -22,6 +22,7 @@ use Kanboard\Api\Procedure\ProjectPermissionProcedure; use Kanboard\Api\Procedure\SubtaskProcedure; use Kanboard\Api\Procedure\SubtaskTimeTrackingProcedure; use Kanboard\Api\Procedure\SwimlaneProcedure; +use Kanboard\Api\Procedure\TaskMetadataProcedure; use Kanboard\Api\Procedure\TaskProcedure; use Kanboard\Api\Procedure\TaskLinkProcedure; use Kanboard\Api\Procedure\UserProcedure; @@ -69,6 +70,7 @@ class ApiProvider implements ServiceProviderInterface ->withObject(new TaskProcedure($container)) ->withObject(new TaskLinkProcedure($container)) ->withObject(new TaskExternalLinkProcedure($container)) + ->withObject(new TaskMetadataProcedure($container)) ->withObject(new UserProcedure($container)) ->withObject(new GroupProcedure($container)) ->withObject(new GroupMemberProcedure($container)) |