diff options
Diffstat (limited to 'app/Controller')
-rw-r--r-- | app/Controller/CommentController.php | 14 | ||||
-rw-r--r-- | app/Controller/TaskAjaxController.php | 25 | ||||
-rw-r--r-- | app/Controller/UserAjaxController.php | 10 | ||||
-rw-r--r-- | app/Controller/UserApiAccessController.php | 50 |
4 files changed, 94 insertions, 5 deletions
diff --git a/app/Controller/CommentController.php b/app/Controller/CommentController.php index c61a0602..526bd2bf 100644 --- a/app/Controller/CommentController.php +++ b/app/Controller/CommentController.php @@ -48,6 +48,7 @@ class CommentController extends BaseController */ public function create(array $values = array(), array $errors = array()) { + $project = $this->getProject(); $task = $this->getTask(); if (empty($values)) { @@ -57,10 +58,13 @@ class CommentController extends BaseController ); } - $this->response->html($this->template->render('comment/create', array( + $values['project_id'] = $task['project_id']; + + $this->response->html($this->helper->layout->task('comment/create', array( 'values' => $values, 'errors' => $errors, 'task' => $task, + 'project' => $project, ))); } @@ -103,8 +107,14 @@ class CommentController extends BaseController $task = $this->getTask(); $comment = $this->getComment(); + if (empty($values)) { + $values = $comment; + } + + $values['project_id'] = $task['project_id']; + $this->response->html($this->template->render('comment/edit', array( - 'values' => empty($values) ? $comment : $values, + 'values' => $values, 'errors' => $errors, 'comment' => $comment, 'task' => $task, diff --git a/app/Controller/TaskAjaxController.php b/app/Controller/TaskAjaxController.php index f9feff15..609dd23c 100644 --- a/app/Controller/TaskAjaxController.php +++ b/app/Controller/TaskAjaxController.php @@ -5,8 +5,12 @@ namespace Kanboard\Controller; use Kanboard\Filter\TaskIdExclusionFilter; use Kanboard\Filter\TaskIdFilter; use Kanboard\Filter\TaskProjectsFilter; +use Kanboard\Filter\TaskStartsWithIdFilter; +use Kanboard\Filter\TaskStatusFilter; use Kanboard\Filter\TaskTitleFilter; use Kanboard\Formatter\TaskAutoCompleteFormatter; +use Kanboard\Formatter\TaskSuggestMenuFormatter; +use Kanboard\Model\TaskModel; /** * Task Ajax Controller @@ -19,7 +23,6 @@ class TaskAjaxController extends BaseController /** * Task auto-completion (Ajax) * - * @access public */ public function autocomplete() { @@ -46,4 +49,24 @@ class TaskAjaxController extends BaseController $this->response->json($filter->format(new TaskAutoCompleteFormatter($this->container))); } } + + /** + * Task ID suggest menu + */ + public function suggest() + { + $taskId = $this->request->getIntegerParam('search'); + $projectIds = $this->projectPermissionModel->getActiveProjectIds($this->userSession->getId()); + + if (empty($projectIds)) { + $this->response->json(array()); + } else { + $filter = $this->taskQuery + ->withFilter(new TaskProjectsFilter($projectIds)) + ->withFilter(new TaskStatusFilter(TaskModel::STATUS_OPEN)) + ->withFilter(new TaskStartsWithIdFilter($taskId)); + + $this->response->json($filter->format(new TaskSuggestMenuFormatter($this->container))); + } + } } diff --git a/app/Controller/UserAjaxController.php b/app/Controller/UserAjaxController.php index ed180471..d93bfe9a 100644 --- a/app/Controller/UserAjaxController.php +++ b/app/Controller/UserAjaxController.php @@ -4,6 +4,7 @@ namespace Kanboard\Controller; use Kanboard\Filter\UserNameFilter; use Kanboard\Formatter\UserAutoCompleteFormatter; +use Kanboard\Formatter\UserMentionFormatter; use Kanboard\Model\UserModel; /** @@ -35,9 +36,14 @@ class UserAjaxController extends BaseController public function mention() { $project_id = $this->request->getStringParam('project_id'); - $query = $this->request->getStringParam('q'); + $query = $this->request->getStringParam('search'); $users = $this->projectPermissionModel->findUsernames($project_id, $query); - $this->response->json($users); + + $this->response->json( + UserMentionFormatter::getInstance($this->container) + ->withUsers($users) + ->format() + ); } /** diff --git a/app/Controller/UserApiAccessController.php b/app/Controller/UserApiAccessController.php new file mode 100644 index 00000000..e03514d5 --- /dev/null +++ b/app/Controller/UserApiAccessController.php @@ -0,0 +1,50 @@ +<?php + +namespace Kanboard\Controller; + +use Kanboard\Core\Security\Token; + +/** + * Class UserApiAccessController + * + * @package Kanboard\Controller + * @author Frederic Guillot + */ +class UserApiAccessController extends BaseController +{ + public function show() + { + $user = $this->getUser(); + + return $this->response->html($this->helper->layout->user('user_api_access/show', array( + 'user' => $user, + 'title' => t('API User Access'), + ))); + } + + public function generate() + { + $user = $this->getUser(); + $this->checkCSRFParam(); + + $this->userModel->update(array( + 'id' => $user['id'], + 'api_access_token' => Token::getToken(), + )); + + $this->response->redirect($this->helper->url->to('UserApiAccessController', 'show', array('user_id' => $user['id']))); + } + + public function remove() + { + $user = $this->getUser(); + $this->checkCSRFParam(); + + $this->userModel->update(array( + 'id' => $user['id'], + 'api_access_token' => null, + )); + + $this->response->redirect($this->helper->url->to('UserApiAccessController', 'show', array('user_id' => $user['id']))); + } +}
\ No newline at end of file |