diff options
author | Max Kamashev <kamashev@gollard.ru> | 2015-09-30 09:19:33 +0300 |
---|---|---|
committer | Max Kamashev <kamashev@gollard.ru> | 2015-09-30 09:19:33 +0300 |
commit | cabcdc9d9e58d279ac6a5992ae5202568ed4d24e (patch) | |
tree | eebdc4ec16eb7dc2ed0edd953321fa3e02869f34 /app/Controller/Taskstatus.php | |
parent | 930406bf70e42413a83114b9530b3f63ccf9419f (diff) | |
parent | 421e8751ebca5b566ecbd8d08e9d56b93ce81ffa (diff) |
Merge branch 'master' of https://github.com/fguillot/kanboard into 1245_bug_with_subtask_timer
Diffstat (limited to 'app/Controller/Taskstatus.php')
-rw-r--r-- | app/Controller/Taskstatus.php | 62 |
1 files changed, 29 insertions, 33 deletions
diff --git a/app/Controller/Taskstatus.php b/app/Controller/Taskstatus.php index a47d9da3..9260b658 100644 --- a/app/Controller/Taskstatus.php +++ b/app/Controller/Taskstatus.php @@ -18,62 +18,58 @@ class Taskstatus extends Base public function close() { $task = $this->getTask(); + $this->changeStatus($task, 'close', t('Task closed successfully.'), t('Unable to close this task.')); + $this->renderTemplate($task, 'task_status/close'); + } + + /** + * Open a task + * + * @access public + */ + public function open() + { + $task = $this->getTask(); $redirect = $this->request->getStringParam('redirect'); + $this->changeStatus($task, 'open', t('Task opened successfully.'), t('Unable to open this task.')); + $this->renderTemplate($task, 'task_status/open'); + } + + private function changeStatus(array $task, $method, $success_message, $failure_message) + { if ($this->request->getStringParam('confirmation') === 'yes') { $this->checkCSRFParam(); - if ($this->taskStatus->close($task['id'])) { - $this->session->flash(t('Task closed successfully.')); + if ($this->taskStatus->$method($task['id'])) { + $this->session->flash($success_message); } else { - $this->session->flashError(t('Unable to close this task.')); + $this->session->flashError($failure_message); } - if ($redirect === 'board') { + if ($this->request->getStringParam('redirect') === 'board') { $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id']))); } $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']))); } + } + + private function renderTemplate(array $task, $template) + { + $redirect = $this->request->getStringParam('redirect'); if ($this->request->isAjax()) { - $this->response->html($this->template->render('task_status/close', array( + $this->response->html($this->template->render($template, array( 'task' => $task, 'redirect' => $redirect, ))); } - $this->response->html($this->taskLayout('task_status/close', array( + $this->response->html($this->taskLayout($template, array( 'task' => $task, 'redirect' => $redirect, ))); } - - /** - * Open a task - * - * @access public - */ - public function open() - { - $task = $this->getTask(); - - if ($this->request->getStringParam('confirmation') === 'yes') { - - $this->checkCSRFParam(); - - if ($this->taskStatus->open($task['id'])) { - $this->session->flash(t('Task opened successfully.')); - } else { - $this->session->flashError(t('Unable to open this task.')); - } - - $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id']))); - } - - $this->response->html($this->taskLayout('task_status/open', array( - 'task' => $task, - ))); - } } |