diff options
Diffstat (limited to 'app/Controller/Comment.php')
-rw-r--r-- | app/Controller/Comment.php | 33 |
1 files changed, 8 insertions, 25 deletions
diff --git a/app/Controller/Comment.php b/app/Controller/Comment.php index a608dd1c..da3213e0 100644 --- a/app/Controller/Comment.php +++ b/app/Controller/Comment.php @@ -21,13 +21,11 @@ class Comment extends Base $comment = $this->comment->getById($this->request->getIntegerParam('comment_id')); if (empty($comment)) { - $this->notfound(); + return $this->notfound(); } if (! $this->userSession->isAdmin() && $comment['user_id'] != $this->userSession->getId()) { - $this->response->html($this->template->layout('comment/forbidden', array( - 'title' => t('Access Forbidden') - ))); + return $this->forbidden(); } return $comment; @@ -41,7 +39,6 @@ class Comment extends Base public function create(array $values = array(), array $errors = array()) { $task = $this->getTask(); - $ajax = $this->request->isAjax() || $this->request->getIntegerParam('ajax'); if (empty($values)) { $values = array( @@ -50,16 +47,7 @@ class Comment extends Base ); } - if ($ajax) { - $this->response->html($this->template->render('comment/create', array( - 'values' => $values, - 'errors' => $errors, - 'task' => $task, - 'ajax' => $ajax, - ))); - } - - $this->response->html($this->taskLayout('comment/create', array( + $this->response->html($this->helper->layout->task('comment/create', array( 'values' => $values, 'errors' => $errors, 'task' => $task, @@ -76,7 +64,6 @@ class Comment extends Base { $task = $this->getTask(); $values = $this->request->getValues(); - $ajax = $this->request->isAjax() || $this->request->getIntegerParam('ajax'); list($valid, $errors) = $this->commentValidator->validateCreation($values); @@ -87,11 +74,7 @@ class Comment extends Base $this->flash->failure(t('Unable to create your comment.')); } - if ($ajax) { - $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']), 'comments')); + return $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), 'comments'), true); } $this->create($values, $errors); @@ -107,7 +90,7 @@ class Comment extends Base $task = $this->getTask(); $comment = $this->getComment(); - $this->response->html($this->taskLayout('comment/edit', array( + $this->response->html($this->helper->layout->task('comment/edit', array( 'values' => empty($values) ? $comment : $values, 'errors' => $errors, 'comment' => $comment, @@ -124,7 +107,7 @@ class Comment extends Base public function update() { $task = $this->getTask(); - $comment = $this->getComment(); + $this->getComment(); $values = $this->request->getValues(); list($valid, $errors) = $this->commentValidator->validateModification($values); @@ -136,7 +119,7 @@ class Comment extends Base $this->flash->failure(t('Unable to update your comment.')); } - $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), 'comment-'.$comment['id'])); + return $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), false); } $this->edit($values, $errors); @@ -152,7 +135,7 @@ class Comment extends Base $task = $this->getTask(); $comment = $this->getComment(); - $this->response->html($this->taskLayout('comment/remove', array( + $this->response->html($this->helper->layout->task('comment/remove', array( 'comment' => $comment, 'task' => $task, 'title' => t('Remove a comment') |