From 749136361e6eedbc868778db17bdc67aa0f3b677 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Wed, 3 Sep 2014 14:25:17 -0700 Subject: Change a category directly from the board --- app/Controller/Board.php | 94 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 68 insertions(+), 26 deletions(-) (limited to 'app/Controller/Board.php') diff --git a/app/Controller/Board.php b/app/Controller/Board.php index f43527ea..e2c10f58 100644 --- a/app/Controller/Board.php +++ b/app/Controller/Board.php @@ -51,39 +51,27 @@ class Board extends Base * * @access public */ - public function assign() + public function changeAssignee() { - $task = $this->task->getById($this->request->getIntegerParam('task_id')); + $task = $this->getTask(); $project = $this->project->getById($task['project_id']); - $projects = $this->project->getListByStatus(ProjectModel::ACTIVE); - - if ($this->acl->isRegularUser()) { - $projects = $this->project->filterListByAccess($projects, $this->acl->getUserId()); - } - - if (! $project) $this->notfound(); - $this->checkProjectPermissions($project['id']); + $projects = $this->project->getAvailableList($this->acl->getUserId()); + $params = array( + 'errors' => array(), + 'values' => $task, + 'users_list' => $this->project->getUsersList($project['id']), + 'projects' => $projects, + 'current_project_id' => $project['id'], + 'current_project_name' => $project['name'], + ); if ($this->request->isAjax()) { - $this->response->html($this->template->load('board_assign', array( - 'errors' => array(), - 'values' => $task, - 'users_list' => $this->project->getUsersList($project['id']), - 'projects' => $projects, - 'current_project_id' => $project['id'], - 'current_project_name' => $project['name'], - ))); + $this->response->html($this->template->load('board_assignee', $params)); } else { - $this->response->html($this->template->layout('board_assign', array( - 'errors' => array(), - 'values' => $task, - 'users_list' => $this->project->getUsersList($project['id']), - 'projects' => $projects, - 'current_project_id' => $project['id'], - 'current_project_name' => $project['name'], + $this->response->html($this->template->layout('board_assignee', $params + array( 'menu' => 'boards', 'title' => t('Change assignee').' - '.$task['title'], ))); @@ -95,7 +83,7 @@ class Board extends Base * * @access public */ - public function assignTask() + public function updateAssignee() { $values = $this->request->getValues(); $this->checkProjectPermissions($values['project_id']); @@ -112,6 +100,60 @@ class Board extends Base $this->response->redirect('?controller=board&action=show&project_id='.$values['project_id']); } + /** + * Change a task category directly from the board + * + * @access public + */ + public function changeCategory() + { + $task = $this->getTask(); + $project = $this->project->getById($task['project_id']); + $projects = $this->project->getAvailableList($this->acl->getUserId()); + $params = array( + 'errors' => array(), + 'values' => $task, + 'categories_list' => $this->category->getList($project['id']), + 'projects' => $projects, + 'current_project_id' => $project['id'], + 'current_project_name' => $project['name'], + ); + + if ($this->request->isAjax()) { + + $this->response->html($this->template->load('board_category', $params)); + } + else { + + $this->response->html($this->template->layout('board_category', $params + array( + 'menu' => 'boards', + 'title' => t('Change category').' - '.$task['title'], + ))); + } + } + + /** + * Validate a category modification + * + * @access public + */ + public function updateCategory() + { + $values = $this->request->getValues(); + $this->checkProjectPermissions($values['project_id']); + + list($valid,) = $this->task->validateCategoryModification($values); + + if ($valid && $this->task->update($values)) { + $this->session->flash(t('Task updated successfully.')); + } + else { + $this->session->flashError(t('Unable to update your task.')); + } + + $this->response->redirect('?controller=board&action=show&project_id='.$values['project_id']); + } + /** * Display the public version of a board * Access checked by a simple token, no user login, read only, auto-refresh -- cgit v1.2.3