summaryrefslogtreecommitdiff
path: root/controllers
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-05-17 18:26:17 -0400
committerFrédéric Guillot <fred@kanboard.net>2014-05-17 18:26:17 -0400
commitf9c24f3c2c46eccd18e70704c0e8767fa6023206 (patch)
tree0e26337e3910ef10a88a8093967748ce54bcc701 /controllers
parent4d677b720e818f9d14585479699335ec41ed3541 (diff)
Add the possibility to remove a task
Diffstat (limited to 'controllers')
-rw-r--r--controllers/base.php17
-rw-r--r--controllers/task.php52
2 files changed, 62 insertions, 7 deletions
diff --git a/controllers/base.php b/controllers/base.php
index 37353ff0..07c5db63 100644
--- a/controllers/base.php
+++ b/controllers/base.php
@@ -289,7 +289,7 @@ abstract class Base
$hide_comment_form = true;
}
- $this->response->html($this->template->layout('task_show', array(
+ $this->response->html($this->taskLayout('task_show', array(
'hide_comment_form' => isset($hide_comment_form),
'comment_edit_form' => $comment_edit_form,
'comment_form' => $comment_form,
@@ -302,4 +302,19 @@ abstract class Base
'title' => $task['title'],
)));
}
+
+ /**
+ * Common layout for task views
+ *
+ * @access protected
+ * @param string $template Template name
+ * @param array $params Template parameters
+ */
+ protected function taskLayout($template, array $params)
+ {
+ $content = $this->template->load($template, $params);
+ $params['task_content_for_layout'] = $content;
+
+ return $this->template->layout('task_layout', $params);
+ }
}
diff --git a/controllers/task.php b/controllers/task.php
index 9065c576..f5738a55 100644
--- a/controllers/task.php
+++ b/controllers/task.php
@@ -253,7 +253,7 @@ class Task extends Base
$this->session->flashError(t('Unable to close this task.'));
}
- $this->response->redirect('?controller=board&action=show&project_id='.$task['project_id']);
+ $this->response->redirect('?controller=task&action=show&task_id='.$task['id']);
}
/**
@@ -263,12 +263,12 @@ class Task extends Base
*/
public function confirmClose()
{
- $task = $this->task->getById($this->request->getIntegerParam('task_id'));
+ $task = $this->task->getById($this->request->getIntegerParam('task_id'), true);
if (! $task) $this->notfound();
$this->checkProjectPermissions($task['project_id']);
- $this->response->html($this->template->layout('task_close', array(
+ $this->response->html($this->taskLayout('task_close', array(
'task' => $task,
'menu' => 'tasks',
'title' => t('Close a task')
@@ -293,7 +293,7 @@ class Task extends Base
$this->session->flashError(t('Unable to open this task.'));
}
- $this->response->redirect('?controller=board&action=show&project_id='.$task['project_id']);
+ $this->response->redirect('?controller=task&action=show&task_id='.$task['id']);
}
/**
@@ -303,12 +303,12 @@ class Task extends Base
*/
public function confirmOpen()
{
- $task = $this->task->getById($this->request->getIntegerParam('task_id'));
+ $task = $this->task->getById($this->request->getIntegerParam('task_id'), true);
if (! $task) $this->notfound();
$this->checkProjectPermissions($task['project_id']);
- $this->response->html($this->template->layout('task_open', array(
+ $this->response->html($this->taskLayout('task_open', array(
'task' => $task,
'menu' => 'tasks',
'title' => t('Open a task')
@@ -316,6 +316,46 @@ class Task extends Base
}
/**
+ * Remove a task
+ *
+ * @access public
+ */
+ public function remove()
+ {
+ $task = $this->task->getById($this->request->getIntegerParam('task_id'));
+
+ if (! $task) $this->notfound();
+ $this->checkProjectPermissions($task['project_id']);
+
+ if ($this->task->remove($task['id'])) {
+ $this->session->flash(t('Task removed successfully.'));
+ } else {
+ $this->session->flashError(t('Unable to remove this task.'));
+ }
+
+ $this->response->redirect('?controller=board&action=show&project_id='.$task['project_id']);
+ }
+
+ /**
+ * Confirmation dialog before removing a task
+ *
+ * @access public
+ */
+ public function confirmRemove()
+ {
+ $task = $this->task->getById($this->request->getIntegerParam('task_id'), true);
+
+ if (! $task) $this->notfound();
+ $this->checkProjectPermissions($task['project_id']);
+
+ $this->response->html($this->taskLayout('task_remove', array(
+ 'task' => $task,
+ 'menu' => 'tasks',
+ 'title' => t('Remove a task')
+ )));
+ }
+
+ /**
* Duplicate a task (fill the form for a new task)
*
* @access public