summaryrefslogtreecommitdiff
path: root/app/Api
diff options
context:
space:
mode:
Diffstat (limited to 'app/Api')
-rw-r--r--app/Api/ActionApi.php6
-rw-r--r--app/Api/AppApi.php8
-rw-r--r--app/Api/AuthApi.php82
-rw-r--r--app/Api/BaseApi.php59
-rw-r--r--app/Api/BoardApi.php2
-rw-r--r--app/Api/CategoryApi.php10
-rw-r--r--app/Api/ColumnApi.php12
-rw-r--r--app/Api/CommentApi.php10
-rw-r--r--app/Api/FileApi.php12
-rw-r--r--app/Api/GroupApi.php10
-rw-r--r--app/Api/GroupMemberApi.php10
-rw-r--r--app/Api/LinkApi.php14
-rw-r--r--app/Api/MeApi.php22
-rw-r--r--app/Api/Middleware/AuthenticationApiMiddleware.php130
-rw-r--r--app/Api/ProjectApi.php20
-rw-r--r--app/Api/ProjectPermissionApi.php16
-rw-r--r--app/Api/SubtaskApi.php10
-rw-r--r--app/Api/SwimlaneApi.php24
-rw-r--r--app/Api/TaskApi.php34
-rw-r--r--app/Api/TaskLinkApi.php10
-rw-r--r--app/Api/UserApi.php20
21 files changed, 262 insertions, 259 deletions
diff --git a/app/Api/ActionApi.php b/app/Api/ActionApi.php
index 0647f9e8..116742d8 100644
--- a/app/Api/ActionApi.php
+++ b/app/Api/ActionApi.php
@@ -29,12 +29,12 @@ class ActionApi extends Base
public function removeAction($action_id)
{
- return $this->action->remove($action_id);
+ return $this->actionModel->remove($action_id);
}
public function getActions($project_id)
{
- return $this->action->getAllByProject($project_id);
+ return $this->actionModel->getAllByProject($project_id);
}
public function createAction($project_id, $event_name, $action_name, array $params)
@@ -82,6 +82,6 @@ class ActionApi extends Base
}
}
- return $this->action->create($values);
+ return $this->actionModel->create($values);
}
}
diff --git a/app/Api/AppApi.php b/app/Api/AppApi.php
index 865ba21a..637de5c5 100644
--- a/app/Api/AppApi.php
+++ b/app/Api/AppApi.php
@@ -14,7 +14,7 @@ class AppApi extends Base
{
public function getTimezone()
{
- return $this->timezone->getCurrentTimezone();
+ return $this->timezoneModel->getCurrentTimezone();
}
public function getVersion()
@@ -24,17 +24,17 @@ class AppApi extends Base
public function getDefaultTaskColor()
{
- return $this->color->getDefaultColor();
+ return $this->colorModel->getDefaultColor();
}
public function getDefaultTaskColors()
{
- return $this->color->getDefaultColors();
+ return $this->colorModel->getDefaultColors();
}
public function getColorList()
{
- return $this->color->getList();
+ return $this->colorModel->getList();
}
public function getApplicationRoles()
diff --git a/app/Api/AuthApi.php b/app/Api/AuthApi.php
deleted file mode 100644
index a9ad5baf..00000000
--- a/app/Api/AuthApi.php
+++ /dev/null
@@ -1,82 +0,0 @@
-<?php
-
-namespace Kanboard\Api;
-
-use JsonRPC\Exception\AuthenticationFailureException;
-
-/**
- * Base class
- *
- * @package Kanboard\Api
- * @author Frederic Guillot
- */
-class AuthApi extends BaseApi
-{
- /**
- * Check api credentials
- *
- * @access public
- * @param string $username
- * @param string $password
- * @param string $class
- * @param string $method
- * @throws AuthenticationFailureException
- */
- public function checkCredentials($username, $password, $class, $method)
- {
- $this->dispatcher->dispatch('app.bootstrap');
-
- if ($this->isUserAuthenticated($username, $password)) {
- $this->checkProcedurePermission(true, $method);
- $this->userSession->initialize($this->user->getByUsername($username));
- } elseif ($this->isAppAuthenticated($username, $password)) {
- $this->checkProcedurePermission(false, $method);
- } else {
- $this->logger->error('API authentication failure for '.$username);
- throw new AuthenticationFailureException('Wrong credentials');
- }
- }
-
- /**
- * Check user credentials
- *
- * @access public
- * @param string $username
- * @param string $password
- * @return boolean
- */
- private function isUserAuthenticated($username, $password)
- {
- return $username !== 'jsonrpc' &&
- ! $this->userLocking->isLocked($username) &&
- $this->authenticationManager->passwordAuthentication($username, $password);
- }
-
- /**
- * Check administrative credentials
- *
- * @access public
- * @param string $username
- * @param string $password
- * @return boolean
- */
- private function isAppAuthenticated($username, $password)
- {
- return $username === 'jsonrpc' && $password === $this->getApiToken();
- }
-
- /**
- * Get API Token
- *
- * @access private
- * @return string
- */
- private function getApiToken()
- {
- if (defined('API_AUTHENTICATION_TOKEN')) {
- return API_AUTHENTICATION_TOKEN;
- }
-
- return $this->config->get('api_token');
- }
-}
diff --git a/app/Api/BaseApi.php b/app/Api/BaseApi.php
index 37e11030..9f69aa65 100644
--- a/app/Api/BaseApi.php
+++ b/app/Api/BaseApi.php
@@ -13,54 +13,9 @@ use Kanboard\Core\Base;
*/
abstract class BaseApi extends Base
{
- private $user_allowed_procedures = array(
- 'getMe',
- 'getMyDashboard',
- 'getMyActivityStream',
- 'createMyPrivateProject',
- 'getMyProjectsList',
- 'getMyProjects',
- 'getMyOverdueTasks',
- );
-
- private $both_allowed_procedures = array(
- 'getTimezone',
- 'getVersion',
- 'getDefaultTaskColor',
- 'getDefaultTaskColors',
- 'getColorList',
- 'getProjectById',
- 'getTask',
- 'getTaskByReference',
- 'getAllTasks',
- 'openTask',
- 'closeTask',
- 'moveTaskPosition',
- 'createTask',
- 'updateTask',
- 'getBoard',
- 'getProjectActivity',
- 'getOverdueTasksByProject',
- 'searchTasks',
- );
-
- public function checkProcedurePermission($is_user, $procedure)
- {
- $is_both_procedure = in_array($procedure, $this->both_allowed_procedures);
- $is_user_procedure = in_array($procedure, $this->user_allowed_procedures);
-
- if ($is_user && ! $is_both_procedure && ! $is_user_procedure) {
- throw new AccessDeniedException('Permission denied');
- } elseif (! $is_user && ! $is_both_procedure && $is_user_procedure) {
- throw new AccessDeniedException('Permission denied');
- }
-
- $this->logger->debug('API call: '.$procedure);
- }
-
public function checkProjectPermission($project_id)
{
- if ($this->userSession->isLogged() && ! $this->projectPermission->isUserAllowed($project_id, $this->userSession->getId())) {
+ if ($this->userSession->isLogged() && ! $this->projectPermissionModel->isUserAllowed($project_id, $this->userSession->getId())) {
throw new AccessDeniedException('Permission denied');
}
}
@@ -68,15 +23,15 @@ abstract class BaseApi extends Base
public function checkTaskPermission($task_id)
{
if ($this->userSession->isLogged()) {
- $this->checkProjectPermission($this->taskFinder->getProjectId($task_id));
+ $this->checkProjectPermission($this->taskFinderModel->getProjectId($task_id));
}
}
protected function formatTask($task)
{
if (! empty($task)) {
- $task['url'] = $this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), '', true);
- $task['color'] = $this->color->getColorProperties($task['color_id']);
+ $task['url'] = $this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), '', true);
+ $task['color'] = $this->colorModel->getColorProperties($task['color_id']);
}
return $task;
@@ -97,9 +52,9 @@ abstract class BaseApi extends Base
{
if (! empty($project)) {
$project['url'] = array(
- 'board' => $this->helper->url->to('board', 'show', array('project_id' => $project['id']), '', true),
- 'calendar' => $this->helper->url->to('calendar', 'show', array('project_id' => $project['id']), '', true),
- 'list' => $this->helper->url->to('listing', 'show', array('project_id' => $project['id']), '', true),
+ 'board' => $this->helper->url->to('BoardViewController', 'show', array('project_id' => $project['id']), '', true),
+ 'calendar' => $this->helper->url->to('CalendarController', 'show', array('project_id' => $project['id']), '', true),
+ 'list' => $this->helper->url->to('TaskListController', 'show', array('project_id' => $project['id']), '', true),
);
}
diff --git a/app/Api/BoardApi.php b/app/Api/BoardApi.php
index c7d93aa0..aa5942af 100644
--- a/app/Api/BoardApi.php
+++ b/app/Api/BoardApi.php
@@ -13,6 +13,6 @@ class BoardApi extends BaseApi
public function getBoard($project_id)
{
$this->checkProjectPermission($project_id);
- return $this->board->getBoard($project_id);
+ return $this->boardModel->getBoard($project_id);
}
}
diff --git a/app/Api/CategoryApi.php b/app/Api/CategoryApi.php
index 7c5d3bfb..c56cfb35 100644
--- a/app/Api/CategoryApi.php
+++ b/app/Api/CategoryApi.php
@@ -14,17 +14,17 @@ class CategoryApi extends Base
{
public function getCategory($category_id)
{
- return $this->category->getById($category_id);
+ return $this->categoryModel->getById($category_id);
}
public function getAllCategories($project_id)
{
- return $this->category->getAll($project_id);
+ return $this->categoryModel->getAll($project_id);
}
public function removeCategory($category_id)
{
- return $this->category->remove($category_id);
+ return $this->categoryModel->remove($category_id);
}
public function createCategory($project_id, $name)
@@ -35,7 +35,7 @@ class CategoryApi extends Base
);
list($valid, ) = $this->categoryValidator->validateCreation($values);
- return $valid ? $this->category->create($values) : false;
+ return $valid ? $this->categoryModel->create($values) : false;
}
public function updateCategory($id, $name)
@@ -46,6 +46,6 @@ class CategoryApi extends Base
);
list($valid, ) = $this->categoryValidator->validateModification($values);
- return $valid && $this->category->update($values);
+ return $valid && $this->categoryModel->update($values);
}
}
diff --git a/app/Api/ColumnApi.php b/app/Api/ColumnApi.php
index 45ce521d..aa4026f6 100644
--- a/app/Api/ColumnApi.php
+++ b/app/Api/ColumnApi.php
@@ -12,31 +12,31 @@ class ColumnApi extends BaseApi
{
public function getColumns($project_id)
{
- return $this->column->getAll($project_id);
+ return $this->columnModel->getAll($project_id);
}
public function getColumn($column_id)
{
- return $this->column->getById($column_id);
+ return $this->columnModel->getById($column_id);
}
public function updateColumn($column_id, $title, $task_limit = 0, $description = '')
{
- return $this->column->update($column_id, $title, $task_limit, $description);
+ return $this->columnModel->update($column_id, $title, $task_limit, $description);
}
public function addColumn($project_id, $title, $task_limit = 0, $description = '')
{
- return $this->column->create($project_id, $title, $task_limit, $description);
+ return $this->columnModel->create($project_id, $title, $task_limit, $description);
}
public function removeColumn($column_id)
{
- return $this->column->remove($column_id);
+ return $this->columnModel->remove($column_id);
}
public function changeColumnPosition($project_id, $column_id, $position)
{
- return $this->column->changePosition($project_id, $column_id, $position);
+ return $this->columnModel->changePosition($project_id, $column_id, $position);
}
}
diff --git a/app/Api/CommentApi.php b/app/Api/CommentApi.php
index f16b0f7f..8358efee 100644
--- a/app/Api/CommentApi.php
+++ b/app/Api/CommentApi.php
@@ -14,17 +14,17 @@ class CommentApi extends Base
{
public function getComment($comment_id)
{
- return $this->comment->getById($comment_id);
+ return $this->commentModel->getById($comment_id);
}
public function getAllComments($task_id)
{
- return $this->comment->getAll($task_id);
+ return $this->commentModel->getAll($task_id);
}
public function removeComment($comment_id)
{
- return $this->comment->remove($comment_id);
+ return $this->commentModel->remove($comment_id);
}
public function createComment($task_id, $user_id, $content, $reference = '')
@@ -38,7 +38,7 @@ class CommentApi extends Base
list($valid, ) = $this->commentValidator->validateCreation($values);
- return $valid ? $this->comment->create($values) : false;
+ return $valid ? $this->commentModel->create($values) : false;
}
public function updateComment($id, $content)
@@ -49,6 +49,6 @@ class CommentApi extends Base
);
list($valid, ) = $this->commentValidator->validateModification($values);
- return $valid && $this->comment->update($values);
+ return $valid && $this->commentModel->update($values);
}
}
diff --git a/app/Api/FileApi.php b/app/Api/FileApi.php
index cc2e3986..1ed3aeb9 100644
--- a/app/Api/FileApi.php
+++ b/app/Api/FileApi.php
@@ -14,18 +14,18 @@ class FileApi extends BaseApi
{
public function getTaskFile($file_id)
{
- return $this->taskFile->getById($file_id);
+ return $this->taskFileModel->getById($file_id);
}
public function getAllTaskFiles($task_id)
{
- return $this->taskFile->getAll($task_id);
+ return $this->taskFileModel->getAll($task_id);
}
public function downloadTaskFile($file_id)
{
try {
- $file = $this->taskFile->getById($file_id);
+ $file = $this->taskFileModel->getById($file_id);
if (! empty($file)) {
return base64_encode($this->objectStorage->get($file['path']));
@@ -40,7 +40,7 @@ class FileApi extends BaseApi
public function createTaskFile($project_id, $task_id, $filename, $blob)
{
try {
- return $this->taskFile->uploadContent($task_id, $filename, $blob);
+ return $this->taskFileModel->uploadContent($task_id, $filename, $blob);
} catch (ObjectStorageException $e) {
$this->logger->error($e->getMessage());
return false;
@@ -49,12 +49,12 @@ class FileApi extends BaseApi
public function removeTaskFile($file_id)
{
- return $this->taskFile->remove($file_id);
+ return $this->taskFileModel->remove($file_id);
}
public function removeAllTaskFiles($task_id)
{
- return $this->taskFile->removeAll($task_id);
+ return $this->taskFileModel->removeAll($task_id);
}
// Deprecated procedures
diff --git a/app/Api/GroupApi.php b/app/Api/GroupApi.php
index f1841fa3..1701edc3 100644
--- a/app/Api/GroupApi.php
+++ b/app/Api/GroupApi.php
@@ -14,7 +14,7 @@ class GroupApi extends Base
{
public function createGroup($name, $external_id = '')
{
- return $this->group->create($name, $external_id);
+ return $this->groupModel->create($name, $external_id);
}
public function updateGroup($group_id, $name = null, $external_id = null)
@@ -31,21 +31,21 @@ class GroupApi extends Base
}
}
- return $this->group->update($values);
+ return $this->groupModel->update($values);
}
public function removeGroup($group_id)
{
- return $this->group->remove($group_id);
+ return $this->groupModel->remove($group_id);
}
public function getGroup($group_id)
{
- return $this->group->getById($group_id);
+ return $this->groupModel->getById($group_id);
}
public function getAllGroups()
{
- return $this->group->getAll();
+ return $this->groupModel->getAll();
}
}
diff --git a/app/Api/GroupMemberApi.php b/app/Api/GroupMemberApi.php
index f5171e23..e09f6975 100644
--- a/app/Api/GroupMemberApi.php
+++ b/app/Api/GroupMemberApi.php
@@ -14,26 +14,26 @@ class GroupMemberApi extends Base
{
public function getMemberGroups($user_id)
{
- return $this->groupMember->getGroups($user_id);
+ return $this->groupMemberModel->getGroups($user_id);
}
public function getGroupMembers($group_id)
{
- return $this->groupMember->getMembers($group_id);
+ return $this->groupMemberModel->getMembers($group_id);
}
public function addGroupMember($group_id, $user_id)
{
- return $this->groupMember->addUser($group_id, $user_id);
+ return $this->groupMemberModel->addUser($group_id, $user_id);
}
public function removeGroupMember($group_id, $user_id)
{
- return $this->groupMember->removeUser($group_id, $user_id);
+ return $this->groupMemberModel->removeUser($group_id, $user_id);
}
public function isGroupMember($group_id, $user_id)
{
- return $this->groupMember->isMember($group_id, $user_id);
+ return $this->groupMemberModel->isMember($group_id, $user_id);
}
}
diff --git a/app/Api/LinkApi.php b/app/Api/LinkApi.php
index a76cb802..d8e525e4 100644
--- a/app/Api/LinkApi.php
+++ b/app/Api/LinkApi.php
@@ -21,7 +21,7 @@ class LinkApi extends Base
*/
public function getLinkById($link_id)
{
- return $this->link->getById($link_id);
+ return $this->linkModel->getById($link_id);
}
/**
@@ -33,7 +33,7 @@ class LinkApi extends Base
*/
public function getLinkByLabel($label)
{
- return $this->link->getByLabel($label);
+ return $this->linkModel->getByLabel($label);
}
/**
@@ -45,7 +45,7 @@ class LinkApi extends Base
*/
public function getOppositeLinkId($link_id)
{
- return $this->link->getOppositeLinkId($link_id);
+ return $this->linkModel->getOppositeLinkId($link_id);
}
/**
@@ -56,7 +56,7 @@ class LinkApi extends Base
*/
public function getAllLinks()
{
- return $this->link->getAll();
+ return $this->linkModel->getAll();
}
/**
@@ -75,7 +75,7 @@ class LinkApi extends Base
);
list($valid, ) = $this->linkValidator->validateCreation($values);
- return $valid ? $this->link->create($label, $opposite_label) : false;
+ return $valid ? $this->linkModel->create($label, $opposite_label) : false;
}
/**
@@ -96,7 +96,7 @@ class LinkApi extends Base
);
list($valid, ) = $this->linkValidator->validateModification($values);
- return $valid && $this->link->update($values);
+ return $valid && $this->linkModel->update($values);
}
/**
@@ -108,6 +108,6 @@ class LinkApi extends Base
*/
public function removeLink($link_id)
{
- return $this->link->remove($link_id);
+ return $this->linkModel->remove($link_id);
}
}
diff --git a/app/Api/MeApi.php b/app/Api/MeApi.php
index 7d46a962..497749b6 100644
--- a/app/Api/MeApi.php
+++ b/app/Api/MeApi.php
@@ -2,7 +2,7 @@
namespace Kanboard\Api;
-use Kanboard\Model\Subtask as SubtaskModel;
+use Kanboard\Model\SubtaskModel;
/**
* Me API controller
@@ -20,25 +20,25 @@ class MeApi extends BaseApi
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();
+ $projects = $this->projectModel->getQueryColumnStats($this->projectPermissionModel->getActiveProjectIds($user_id))->findAll();
+ $tasks = $this->taskFinderModel->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(),
+ 'subtasks' => $this->subtaskModel->getUserQuery($user_id, array(SubtaskModel::STATUS_TODO, SubtaskModel::STATUS_INPROGRESS))->findAll(),
);
}
public function getMyActivityStream()
{
- $project_ids = $this->projectPermission->getActiveProjectIds($this->userSession->getId());
+ $project_ids = $this->projectPermissionModel->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) {
+ if ($this->configModel->get('disable_private_project', 0) == 1) {
return false;
}
@@ -49,23 +49,23 @@ class MeApi extends BaseApi
);
list($valid, ) = $this->projectValidator->validateCreation($values);
- return $valid ? $this->project->create($values, $this->userSession->getId(), true) : false;
+ return $valid ? $this->projectModel->create($values, $this->userSession->getId(), true) : false;
}
public function getMyProjectsList()
{
- return $this->projectUserRole->getProjectsByUser($this->userSession->getId());
+ return $this->projectUserRoleModel->getProjectsByUser($this->userSession->getId());
}
public function getMyOverdueTasks()
{
- return $this->taskFinder->getOverdueTasksByUser($this->userSession->getId());
+ return $this->taskFinderModel->getOverdueTasksByUser($this->userSession->getId());
}
public function getMyProjects()
{
- $project_ids = $this->projectPermission->getActiveProjectIds($this->userSession->getId());
- $projects = $this->project->getAllByIds($project_ids);
+ $project_ids = $this->projectPermissionModel->getActiveProjectIds($this->userSession->getId());
+ $projects = $this->projectModel->getAllByIds($project_ids);
return $this->formatProjects($projects);
}
diff --git a/app/Api/Middleware/AuthenticationApiMiddleware.php b/app/Api/Middleware/AuthenticationApiMiddleware.php
new file mode 100644
index 00000000..5f63e1a1
--- /dev/null
+++ b/app/Api/Middleware/AuthenticationApiMiddleware.php
@@ -0,0 +1,130 @@
+<?php
+
+namespace Kanboard\Api\Middleware;
+
+use JsonRPC\Exception\AccessDeniedException;
+use JsonRPC\Exception\AuthenticationFailureException;
+use JsonRPC\MiddlewareInterface;
+use Kanboard\Core\Base;
+
+/**
+ * Class AuthenticationApiMiddleware
+ *
+ * @package Kanboard\Api\Middleware
+ * @author Frederic Guillot
+ */
+class AuthenticationApiMiddleware extends Base implements MiddlewareInterface
+{
+ private $user_allowed_procedures = array(
+ 'getMe',
+ 'getMyDashboard',
+ 'getMyActivityStream',
+ 'createMyPrivateProject',
+ 'getMyProjectsList',
+ 'getMyProjects',
+ 'getMyOverdueTasks',
+ );
+
+ private $both_allowed_procedures = array(
+ 'getTimezone',
+ 'getVersion',
+ 'getDefaultTaskColor',
+ 'getDefaultTaskColors',
+ 'getColorList',
+ 'getProjectById',
+ 'getTask',
+ 'getTaskByReference',
+ 'getAllTasks',
+ 'openTask',
+ 'closeTask',
+ 'moveTaskPosition',
+ 'createTask',
+ 'updateTask',
+ 'getBoard',
+ 'getProjectActivity',
+ 'getOverdueTasksByProject',
+ 'searchTasks',
+ );
+
+ /**
+ * Execute Middleware
+ *
+ * @access public
+ * @param string $username
+ * @param string $password
+ * @param string $procedureName
+ * @throws AccessDeniedException
+ * @throws AuthenticationFailureException
+ */
+ public function execute($username, $password, $procedureName)
+ {
+ $this->dispatcher->dispatch('app.bootstrap');
+
+ if ($this->isUserAuthenticated($username, $password)) {
+ $this->checkProcedurePermission(true, $procedureName);
+ $this->userSession->initialize($this->userModel->getByUsername($username));
+ } elseif ($this->isAppAuthenticated($username, $password)) {
+ $this->checkProcedurePermission(false, $procedureName);
+ } else {
+ $this->logger->error('API authentication failure for '.$username);
+ throw new AuthenticationFailureException('Wrong credentials');
+ }
+ }
+
+ /**
+ * Check user credentials
+ *
+ * @access public
+ * @param string $username
+ * @param string $password
+ * @return boolean
+ */
+ private function isUserAuthenticated($username, $password)
+ {
+ return $username !== 'jsonrpc' &&
+ ! $this->userLockingModel->isLocked($username) &&
+ $this->authenticationManager->passwordAuthentication($username, $password);
+ }
+
+ /**
+ * Check administrative credentials
+ *
+ * @access public
+ * @param string $username
+ * @param string $password
+ * @return boolean
+ */
+ private function isAppAuthenticated($username, $password)
+ {
+ return $username === 'jsonrpc' && $password === $this->getApiToken();
+ }
+
+ /**
+ * Get API Token
+ *
+ * @access private
+ * @return string
+ */
+ private function getApiToken()
+ {
+ if (defined('API_AUTHENTICATION_TOKEN')) {
+ return API_AUTHENTICATION_TOKEN;
+ }
+
+ return $this->configModel->get('api_token');
+ }
+
+ public function checkProcedurePermission($is_user, $procedure)
+ {
+ $is_both_procedure = in_array($procedure, $this->both_allowed_procedures);
+ $is_user_procedure = in_array($procedure, $this->user_allowed_procedures);
+
+ if ($is_user && ! $is_both_procedure && ! $is_user_procedure) {
+ throw new AccessDeniedException('Permission denied');
+ } elseif (! $is_user && ! $is_both_procedure && $is_user_procedure) {
+ throw new AccessDeniedException('Permission denied');
+ }
+
+ $this->logger->debug('API call: '.$procedure);
+ }
+}
diff --git a/app/Api/ProjectApi.php b/app/Api/ProjectApi.php
index 70cd8d16..29a9cd79 100644
--- a/app/Api/ProjectApi.php
+++ b/app/Api/ProjectApi.php
@@ -13,42 +13,42 @@ class ProjectApi extends BaseApi
public function getProjectById($project_id)
{
$this->checkProjectPermission($project_id);
- return $this->formatProject($this->project->getById($project_id));
+ return $this->formatProject($this->projectModel->getById($project_id));
}
public function getProjectByName($name)
{
- return $this->formatProject($this->project->getByName($name));
+ return $this->formatProject($this->projectModel->getByName($name));
}
public function getAllProjects()
{
- return $this->formatProjects($this->project->getAll());
+ return $this->formatProjects($this->projectModel->getAll());
}
public function removeProject($project_id)
{
- return $this->project->remove($project_id);
+ return $this->projectModel->remove($project_id);
}
public function enableProject($project_id)
{
- return $this->project->enable($project_id);
+ return $this->projectModel->enable($project_id);
}
public function disableProject($project_id)
{
- return $this->project->disable($project_id);
+ return $this->projectModel->disable($project_id);
}
public function enableProjectPublicAccess($project_id)
{
- return $this->project->enablePublicAccess($project_id);
+ return $this->projectModel->enablePublicAccess($project_id);
}
public function disableProjectPublicAccess($project_id)
{
- return $this->project->disablePublicAccess($project_id);
+ return $this->projectModel->disablePublicAccess($project_id);
}
public function getProjectActivities(array $project_ids)
@@ -70,7 +70,7 @@ class ProjectApi extends BaseApi
);
list($valid, ) = $this->projectValidator->validateCreation($values);
- return $valid ? $this->project->create($values) : false;
+ return $valid ? $this->projectModel->create($values) : false;
}
public function updateProject($id, $name, $description = null)
@@ -82,6 +82,6 @@ class ProjectApi extends BaseApi
);
list($valid, ) = $this->projectValidator->validateModification($values);
- return $valid && $this->project->update($values);
+ return $valid && $this->projectModel->update($values);
}
}
diff --git a/app/Api/ProjectPermissionApi.php b/app/Api/ProjectPermissionApi.php
index 10ee3852..703cd0f3 100644
--- a/app/Api/ProjectPermissionApi.php
+++ b/app/Api/ProjectPermissionApi.php
@@ -15,42 +15,42 @@ class ProjectPermissionApi extends Base
{
public function getProjectUsers($project_id)
{
- return $this->projectUserRole->getAllUsers($project_id);
+ return $this->projectUserRoleModel->getAllUsers($project_id);
}
public function getAssignableUsers($project_id, $prepend_unassigned = false)
{
- return $this->projectUserRole->getAssignableUsersList($project_id, $prepend_unassigned);
+ return $this->projectUserRoleModel->getAssignableUsersList($project_id, $prepend_unassigned);
}
public function addProjectUser($project_id, $user_id, $role = Role::PROJECT_MEMBER)
{
- return $this->projectUserRole->addUser($project_id, $user_id, $role);
+ return $this->projectUserRoleModel->addUser($project_id, $user_id, $role);
}
public function addProjectGroup($project_id, $group_id, $role = Role::PROJECT_MEMBER)
{
- return $this->projectGroupRole->addGroup($project_id, $group_id, $role);
+ return $this->projectGroupRoleModel->addGroup($project_id, $group_id, $role);
}
public function removeProjectUser($project_id, $user_id)
{
- return $this->projectUserRole->removeUser($project_id, $user_id);
+ return $this->projectUserRoleModel->removeUser($project_id, $user_id);
}
public function removeProjectGroup($project_id, $group_id)
{
- return $this->projectGroupRole->removeGroup($project_id, $group_id);
+ return $this->projectGroupRoleModel->removeGroup($project_id, $group_id);
}
public function changeProjectUserRole($project_id, $user_id, $role)
{
- return $this->projectUserRole->changeUserRole($project_id, $user_id, $role);
+ return $this->projectUserRoleModel->changeUserRole($project_id, $user_id, $role);
}
public function changeProjectGroupRole($project_id, $group_id, $role)
{
- return $this->projectGroupRole->changeGroupRole($project_id, $group_id, $role);
+ return $this->projectGroupRoleModel->changeGroupRole($project_id, $group_id, $role);
}
// Deprecated
diff --git a/app/Api/SubtaskApi.php b/app/Api/SubtaskApi.php
index 305f9ae7..5764ff7d 100644
--- a/app/Api/SubtaskApi.php
+++ b/app/Api/SubtaskApi.php
@@ -14,17 +14,17 @@ class SubtaskApi extends Base
{
public function getSubtask($subtask_id)
{
- return $this->subtask->getById($subtask_id);
+ return $this->subtaskModel->getById($subtask_id);
}
public function getAllSubtasks($task_id)
{
- return $this->subtask->getAll($task_id);
+ return $this->subtaskModel->getAll($task_id);
}
public function removeSubtask($subtask_id)
{
- return $this->subtask->remove($subtask_id);
+ return $this->subtaskModel->remove($subtask_id);
}
public function createSubtask($task_id, $title, $user_id = 0, $time_estimated = 0, $time_spent = 0, $status = 0)
@@ -39,7 +39,7 @@ class SubtaskApi extends Base
);
list($valid, ) = $this->subtaskValidator->validateCreation($values);
- return $valid ? $this->subtask->create($values) : false;
+ return $valid ? $this->subtaskModel->create($values) : false;
}
public function updateSubtask($id, $task_id, $title = null, $user_id = null, $time_estimated = null, $time_spent = null, $status = null)
@@ -61,6 +61,6 @@ class SubtaskApi extends Base
}
list($valid, ) = $this->subtaskValidator->validateApiModification($values);
- return $valid && $this->subtask->update($values);
+ return $valid && $this->subtaskModel->update($values);
}
}
diff --git a/app/Api/SwimlaneApi.php b/app/Api/SwimlaneApi.php
index f179e11b..c3c56a71 100644
--- a/app/Api/SwimlaneApi.php
+++ b/app/Api/SwimlaneApi.php
@@ -14,37 +14,37 @@ class SwimlaneApi extends Base
{
public function getActiveSwimlanes($project_id)
{
- return $this->swimlane->getSwimlanes($project_id);
+ return $this->swimlaneModel->getSwimlanes($project_id);
}
public function getAllSwimlanes($project_id)
{
- return $this->swimlane->getAll($project_id);
+ return $this->swimlaneModel->getAll($project_id);
}
public function getSwimlaneById($swimlane_id)
{
- return $this->swimlane->getById($swimlane_id);
+ return $this->swimlaneModel->getById($swimlane_id);
}
public function getSwimlaneByName($project_id, $name)
{
- return $this->swimlane->getByName($project_id, $name);
+ return $this->swimlaneModel->getByName($project_id, $name);
}
public function getSwimlane($swimlane_id)
{
- return $this->swimlane->getById($swimlane_id);
+ return $this->swimlaneModel->getById($swimlane_id);
}
public function getDefaultSwimlane($project_id)
{
- return $this->swimlane->getDefault($project_id);
+ return $this->swimlaneModel->getDefault($project_id);
}
public function addSwimlane($project_id, $name, $description = '')
{
- return $this->swimlane->create(array('project_id' => $project_id, 'name' => $name, 'description' => $description));
+ return $this->swimlaneModel->create(array('project_id' => $project_id, 'name' => $name, 'description' => $description));
}
public function updateSwimlane($swimlane_id, $name, $description = null)
@@ -55,26 +55,26 @@ class SwimlaneApi extends Base
$values['description'] = $description;
}
- return $this->swimlane->update($values);
+ return $this->swimlaneModel->update($values);
}
public function removeSwimlane($project_id, $swimlane_id)
{
- return $this->swimlane->remove($project_id, $swimlane_id);
+ return $this->swimlaneModel->remove($project_id, $swimlane_id);
}
public function disableSwimlane($project_id, $swimlane_id)
{
- return $this->swimlane->disable($project_id, $swimlane_id);
+ return $this->swimlaneModel->disable($project_id, $swimlane_id);
}
public function enableSwimlane($project_id, $swimlane_id)
{
- return $this->swimlane->enable($project_id, $swimlane_id);
+ return $this->swimlaneModel->enable($project_id, $swimlane_id);
}
public function changeSwimlanePosition($project_id, $swimlane_id, $position)
{
- return $this->swimlane->changePosition($project_id, $swimlane_id, $position);
+ return $this->swimlaneModel->changePosition($project_id, $swimlane_id, $position);
}
}
diff --git a/app/Api/TaskApi.php b/app/Api/TaskApi.php
index 4d745fa6..ddb3ac54 100644
--- a/app/Api/TaskApi.php
+++ b/app/Api/TaskApi.php
@@ -3,7 +3,7 @@
namespace Kanboard\Api;
use Kanboard\Filter\TaskProjectFilter;
-use Kanboard\Model\Task as TaskModel;
+use Kanboard\Model\TaskModel;
/**
* Task API controller
@@ -22,63 +22,63 @@ class TaskApi extends BaseApi
public function getTask($task_id)
{
$this->checkTaskPermission($task_id);
- return $this->formatTask($this->taskFinder->getById($task_id));
+ return $this->formatTask($this->taskFinderModel->getById($task_id));
}
public function getTaskByReference($project_id, $reference)
{
$this->checkProjectPermission($project_id);
- return $this->formatTask($this->taskFinder->getByReference($project_id, $reference));
+ return $this->formatTask($this->taskFinderModel->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));
+ return $this->formatTasks($this->taskFinderModel->getAll($project_id, $status_id));
}
public function getOverdueTasks()
{
- return $this->taskFinder->getOverdueTasks();
+ return $this->taskFinderModel->getOverdueTasks();
}
public function getOverdueTasksByProject($project_id)
{
$this->checkProjectPermission($project_id);
- return $this->taskFinder->getOverdueTasksByProject($project_id);
+ return $this->taskFinderModel->getOverdueTasksByProject($project_id);
}
public function openTask($task_id)
{
$this->checkTaskPermission($task_id);
- return $this->taskStatus->open($task_id);
+ return $this->taskStatusModel->open($task_id);
}
public function closeTask($task_id)
{
$this->checkTaskPermission($task_id);
- return $this->taskStatus->close($task_id);
+ return $this->taskStatusModel->close($task_id);
}
public function removeTask($task_id)
{
- return $this->task->remove($task_id);
+ return $this->taskModel->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);
+ return $this->taskPositionModel->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);
+ return $this->taskDuplicationModel->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);
+ return $this->taskDuplicationModel->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,
@@ -88,7 +88,7 @@ class TaskApi extends BaseApi
{
$this->checkProjectPermission($project_id);
- if ($owner_id !== 0 && ! $this->projectPermission->isAssignable($project_id, $owner_id)) {
+ if ($owner_id !== 0 && ! $this->projectPermissionModel->isAssignable($project_id, $owner_id)) {
return false;
}
@@ -119,7 +119,7 @@ class TaskApi extends BaseApi
list($valid, ) = $this->taskValidator->validateCreation($values);
- return $valid ? $this->taskCreation->create($values) : false;
+ return $valid ? $this->taskCreationModel->create($values) : false;
}
public function updateTask($id, $title = null, $color_id = null, $owner_id = null,
@@ -129,13 +129,13 @@ class TaskApi extends BaseApi
{
$this->checkTaskPermission($id);
- $project_id = $this->taskFinder->getProjectId($id);
+ $project_id = $this->taskFinderModel->getProjectId($id);
if ($project_id === 0) {
return false;
}
- if ($owner_id !== null && $owner_id != 0 && ! $this->projectPermission->isAssignable($project_id, $owner_id)) {
+ if ($owner_id !== null && $owner_id != 0 && ! $this->projectPermissionModel->isAssignable($project_id, $owner_id)) {
return false;
}
@@ -164,6 +164,6 @@ class TaskApi extends BaseApi
}
list($valid) = $this->taskValidator->validateApiModification($values);
- return $valid && $this->taskModification->update($values);
+ return $valid && $this->taskModificationModel->update($values);
}
}
diff --git a/app/Api/TaskLinkApi.php b/app/Api/TaskLinkApi.php
index 8c02c524..bb809133 100644
--- a/app/Api/TaskLinkApi.php
+++ b/app/Api/TaskLinkApi.php
@@ -21,7 +21,7 @@ class TaskLinkApi extends Base
*/
public function getTaskLinkById($task_link_id)
{
- return $this->taskLink->getById($task_link_id);
+ return $this->taskLinkModel->getById($task_link_id);
}
/**
@@ -33,7 +33,7 @@ class TaskLinkApi extends Base
*/
public function getAllTaskLinks($task_id)
{
- return $this->taskLink->getAll($task_id);
+ return $this->taskLinkModel->getAll($task_id);
}
/**
@@ -47,7 +47,7 @@ class TaskLinkApi extends Base
*/
public function createTaskLink($task_id, $opposite_task_id, $link_id)
{
- return $this->taskLink->create($task_id, $opposite_task_id, $link_id);
+ return $this->taskLinkModel->create($task_id, $opposite_task_id, $link_id);
}
/**
@@ -62,7 +62,7 @@ class TaskLinkApi extends Base
*/
public function updateTaskLink($task_link_id, $task_id, $opposite_task_id, $link_id)
{
- return $this->taskLink->update($task_link_id, $task_id, $opposite_task_id, $link_id);
+ return $this->taskLinkModel->update($task_link_id, $task_id, $opposite_task_id, $link_id);
}
/**
@@ -74,6 +74,6 @@ class TaskLinkApi extends Base
*/
public function removeTaskLink($task_link_id)
{
- return $this->taskLink->remove($task_link_id);
+ return $this->taskLinkModel->remove($task_link_id);
}
}
diff --git a/app/Api/UserApi.php b/app/Api/UserApi.php
index 9786e6cf..88d75527 100644
--- a/app/Api/UserApi.php
+++ b/app/Api/UserApi.php
@@ -19,37 +19,37 @@ class UserApi extends Base
{
public function getUser($user_id)
{
- return $this->user->getById($user_id);
+ return $this->userModel->getById($user_id);
}
public function getUserByName($username)
{
- return $this->user->getByUsername($username);
+ return $this->userModel->getByUsername($username);
}
public function getAllUsers()
{
- return $this->user->getAll();
+ return $this->userModel->getAll();
}
public function removeUser($user_id)
{
- return $this->user->remove($user_id);
+ return $this->userModel->remove($user_id);
}
public function disableUser($user_id)
{
- return $this->user->disable($user_id);
+ return $this->userModel->disable($user_id);
}
public function enableUser($user_id)
{
- return $this->user->enable($user_id);
+ return $this->userModel->enable($user_id);
}
public function isActiveUser($user_id)
{
- return $this->user->isActive($user_id);
+ return $this->userModel->isActive($user_id);
}
public function createUser($username, $password, $name = '', $email = '', $role = Role::APP_USER)
@@ -64,7 +64,7 @@ class UserApi extends Base
);
list($valid, ) = $this->userValidator->validateCreation($values);
- return $valid ? $this->user->create($values) : false;
+ return $valid ? $this->userModel->create($values) : false;
}
/**
@@ -108,7 +108,7 @@ class UserApi extends Base
'is_ldap_user' => 1,
);
- return $this->user->create($values);
+ return $this->userModel->create($values);
} catch (LdapException $e) {
$this->logger->error($e->getMessage());
@@ -133,6 +133,6 @@ class UserApi extends Base
}
list($valid, ) = $this->userValidator->validateApiModification($values);
- return $valid && $this->user->update($values);
+ return $valid && $this->userModel->update($values);
}
}