Added new API calls for project attachements
This commit is contained in:
68
app/Api/Procedure/ProjectFileProcedure.php
Normal file
68
app/Api/Procedure/ProjectFileProcedure.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace Kanboard\Api\Procedure;
|
||||
|
||||
use Kanboard\Api\Authorization\ProjectAuthorization;
|
||||
use Kanboard\Core\ObjectStorage\ObjectStorageException;
|
||||
|
||||
/**
|
||||
* Project File API controller
|
||||
*
|
||||
* @package Kanboard\Api\Procedure
|
||||
* @author Frederic Guillot
|
||||
*/
|
||||
class ProjectFileProcedure extends BaseProcedure
|
||||
{
|
||||
public function getProjectFile($project_id, $file_id)
|
||||
{
|
||||
ProjectAuthorization::getInstance($this->container)->check($this->getClassName(), 'getProjectFile', $project_id);
|
||||
return $this->projectFileModel->getById($file_id);
|
||||
}
|
||||
|
||||
public function getAllProjectFiles($project_id)
|
||||
{
|
||||
ProjectAuthorization::getInstance($this->container)->check($this->getClassName(), 'getAllProjectFiles', $project_id);
|
||||
return $this->projectFileModel->getAll($project_id);
|
||||
}
|
||||
|
||||
public function downloadProjectFile($project_id, $file_id)
|
||||
{
|
||||
ProjectAuthorization::getInstance($this->container)->check($this->getClassName(), 'downloadProjectFile', $project_id);
|
||||
|
||||
try {
|
||||
$file = $this->projectFileModel->getById($file_id);
|
||||
|
||||
if (! empty($file)) {
|
||||
return base64_encode($this->objectStorage->get($file['path']));
|
||||
}
|
||||
} catch (ObjectStorageException $e) {
|
||||
$this->logger->error($e->getMessage());
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
public function createProjectFile($project_id, $filename, $blob)
|
||||
{
|
||||
ProjectAuthorization::getInstance($this->container)->check($this->getClassName(), 'createProjectFile', $project_id);
|
||||
|
||||
try {
|
||||
return $this->projectFileModel->uploadContent($project_id, $filename, $blob);
|
||||
} catch (ObjectStorageException $e) {
|
||||
$this->logger->error(__METHOD__.': '.$e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function removeProjectFile($project_id, $file_id)
|
||||
{
|
||||
ProjectAuthorization::getInstance($this->container)->check($this->getClassName(), 'removeProjectFile', $project_id);
|
||||
return $this->projectFileModel->remove($file_id);
|
||||
}
|
||||
|
||||
public function removeAllProjectFiles($project_id)
|
||||
{
|
||||
ProjectAuthorization::getInstance($this->container)->check($this->getClassName(), 'removeAllProjectFiles', $project_id);
|
||||
return $this->projectFileModel->removeAll($project_id);
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ namespace Kanboard\Api\Procedure;
|
||||
use Kanboard\Api\Authorization\SubtaskAuthorization;
|
||||
|
||||
/**
|
||||
* Subtask Time Tracking API controller
|
||||
* Subtask Time Tracking API controller
|
||||
*
|
||||
* @package Kanboard\Api\Procedure
|
||||
* @author Frederic Guillot
|
||||
@@ -25,13 +25,13 @@ class SubtaskTimeTrackingProcedure extends BaseProcedure
|
||||
return $this->subtaskTimeTrackingModel->logStartTime($subtask_id, $user_id);
|
||||
}
|
||||
|
||||
public function logSubtaskEndTime($subtask_id,$user_id)
|
||||
public function logSubtaskEndTime($subtask_id, $user_id)
|
||||
{
|
||||
SubtaskAuthorization::getInstance($this->container)->check($this->getClassName(), 'logSubtaskEndTime', $subtask_id);
|
||||
return $this->subtaskTimeTrackingModel->logEndTime($subtask_id, $user_id);
|
||||
}
|
||||
|
||||
public function getSubtaskTimeSpent($subtask_id,$user_id)
|
||||
public function getSubtaskTimeSpent($subtask_id, $user_id)
|
||||
{
|
||||
SubtaskAuthorization::getInstance($this->container)->check($this->getClassName(), 'getSubtaskTimeSpent', $subtask_id);
|
||||
return $this->subtaskTimeTrackingModel->getTimeSpent($subtask_id, $user_id);
|
||||
|
||||
@@ -30,7 +30,7 @@ class TaskFileProcedure extends BaseProcedure
|
||||
public function downloadTaskFile($file_id)
|
||||
{
|
||||
TaskFileAuthorization::getInstance($this->container)->check($this->getClassName(), 'downloadTaskFile', $file_id);
|
||||
|
||||
|
||||
try {
|
||||
$file = $this->taskFileModel->getById($file_id);
|
||||
|
||||
@@ -51,7 +51,7 @@ class TaskFileProcedure extends BaseProcedure
|
||||
try {
|
||||
return $this->taskFileModel->uploadContent($task_id, $filename, $blob);
|
||||
} catch (ObjectStorageException $e) {
|
||||
$this->logger->error($e->getMessage());
|
||||
$this->logger->error(__METHOD__.': '.$e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ use Kanboard\Api\Procedure\BoardProcedure;
|
||||
use Kanboard\Api\Procedure\CategoryProcedure;
|
||||
use Kanboard\Api\Procedure\ColumnProcedure;
|
||||
use Kanboard\Api\Procedure\CommentProcedure;
|
||||
use Kanboard\Api\Procedure\ProjectFileProcedure;
|
||||
use Kanboard\Api\Procedure\TaskExternalLinkProcedure;
|
||||
use Kanboard\Api\Procedure\TaskFileProcedure;
|
||||
use Kanboard\Api\Procedure\GroupProcedure;
|
||||
@@ -58,6 +59,7 @@ class ApiProvider implements ServiceProviderInterface
|
||||
->withObject(new CategoryProcedure($container))
|
||||
->withObject(new CommentProcedure($container))
|
||||
->withObject(new TaskFileProcedure($container))
|
||||
->withObject(new ProjectFileProcedure($container))
|
||||
->withObject(new LinkProcedure($container))
|
||||
->withObject(new ProjectProcedure($container))
|
||||
->withObject(new ProjectPermissionProcedure($container))
|
||||
|
||||
@@ -202,6 +202,7 @@ class AuthenticationProvider implements ServiceProviderInterface
|
||||
$acl->add('SubtaskProcedure', '*', Role::PROJECT_MEMBER);
|
||||
$acl->add('SubtaskTimeTrackingProcedure', '*', Role::PROJECT_MEMBER);
|
||||
$acl->add('SwimlaneProcedure', '*', Role::PROJECT_MANAGER);
|
||||
$acl->add('ProjectFileProcedure', '*', Role::PROJECT_MEMBER);
|
||||
$acl->add('TaskFileProcedure', '*', Role::PROJECT_MEMBER);
|
||||
$acl->add('TaskLinkProcedure', '*', Role::PROJECT_MEMBER);
|
||||
$acl->add('TaskExternalLinkProcedure', array('createExternalTaskLink', 'updateExternalTaskLink', 'removeExternalTaskLink'), Role::PROJECT_MEMBER);
|
||||
|
||||
Reference in New Issue
Block a user