summaryrefslogtreecommitdiff
path: root/app/Controller/TaskStatusController.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-05-26 21:38:43 -0400
committerFrederic Guillot <fred@kanboard.net>2016-05-26 21:38:43 -0400
commit9ebbe3da56914c408327997cea4eb00db2f88e0c (patch)
tree92a40db64f958abff457add4aa643fc6154a05d3 /app/Controller/TaskStatusController.php
parent33dea152fc6b0c061b1f61060cc75710dd0ec236 (diff)
Rename task controllers
Diffstat (limited to 'app/Controller/TaskStatusController.php')
-rw-r--r--app/Controller/TaskStatusController.php62
1 files changed, 62 insertions, 0 deletions
diff --git a/app/Controller/TaskStatusController.php b/app/Controller/TaskStatusController.php
new file mode 100644
index 00000000..fca168ec
--- /dev/null
+++ b/app/Controller/TaskStatusController.php
@@ -0,0 +1,62 @@
+<?php
+
+namespace Kanboard\Controller;
+
+/**
+ * Task Status controller
+ *
+ * @package Kanboard\Controller
+ * @author Frederic Guillot
+ */
+class TaskStatusController extends BaseController
+{
+ /**
+ * Close a task
+ *
+ * @access public
+ */
+ public function close()
+ {
+ $this->changeStatus('close', 'task_status/close', t('Task closed successfully.'), t('Unable to close this task.'));
+ }
+
+ /**
+ * Open a task
+ *
+ * @access public
+ */
+ public function open()
+ {
+ $this->changeStatus('open', 'task_status/open', t('Task opened successfully.'), t('Unable to open this task.'));
+ }
+
+ /**
+ * Common method to change status
+ *
+ * @access private
+ * @param string $method
+ * @param string $template
+ * @param string $success_message
+ * @param string $failure_message
+ */
+ private function changeStatus($method, $template, $success_message, $failure_message)
+ {
+ $task = $this->getTask();
+
+ if ($this->request->getStringParam('confirmation') === 'yes') {
+ $this->checkCSRFParam();
+
+ if ($this->taskStatus->$method($task['id'])) {
+ $this->flash->success($success_message);
+ } else {
+ $this->flash->failure($failure_message);
+ }
+
+ return $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), true);
+ }
+
+ return $this->response->html($this->template->render($template, array(
+ 'task' => $task,
+ )));
+ }
+}