summaryrefslogtreecommitdiff
path: root/controllers
diff options
context:
space:
mode:
authorrzeka <piotr@rzeka.net>2014-03-04 20:17:26 +0100
committerrzeka <piotr@rzeka.net>2014-03-04 20:17:26 +0100
commitccc54c65cf2191e35bd0294c0ffbae761b29f151 (patch)
tree98040c247f1a3165c83266ceeccc7b618f6f2303 /controllers
parent86bee367846491be2a7f703affc1052318dac63d (diff)
Added basic comments on tasks
Diffstat (limited to 'controllers')
-rw-r--r--controllers/task.php30
1 files changed, 29 insertions, 1 deletions
diff --git a/controllers/task.php b/controllers/task.php
index 0057a531..75d08958 100644
--- a/controllers/task.php
+++ b/controllers/task.php
@@ -45,17 +45,45 @@ class Task extends Base
$task = $this->task->getById($this->request->getIntegerParam('task_id'), true);
if (! $task) $this->notfound();
+
$this->checkProjectPermissions($task['project_id']);
+ $values = $values = $this->request->getValues();
+ $errors = $this->comment($values, $task['id']);
+ $comments = $this->task->getCommentsByTask($task['id']);
+
$this->response->html($this->template->layout('task_show', array(
'task' => $task,
'columns_list' => $this->board->getColumnsList($task['project_id']),
'colors_list' => $this->task->getColors(),
'menu' => 'tasks',
- 'title' => $task['title']
+ 'title' => $task['title'],
+ 'comments' => $comments,
+ 'errors' => $errors,
+ 'values' => $values
)));
}
+ //add a comment
+ public function comment(array $values, $task_id)
+ {
+ $errors = array();
+
+ if ($_POST) {
+ list($valid, $errors) = $this->task->validateComment($values);
+
+ if ($valid) {
+ $this->task->addComment(array(
+ 'task_id' => $task_id,
+ 'comment' => $values['comment'],
+ 'user_id' => $this->acl->getUserId()
+ ));
+ }
+ }
+
+ return $errors;
+ }
+
// Display a form to create a new task
public function create()
{