diff options
Diffstat (limited to 'app/Controller/Comment.php')
-rw-r--r-- | app/Controller/Comment.php | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/app/Controller/Comment.php b/app/Controller/Comment.php index a608dd1c..ff7ec305 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,20 +47,10 @@ 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->template->render('comment/create', array( 'values' => $values, 'errors' => $errors, 'task' => $task, - 'title' => t('Add a comment'), ))); } @@ -76,7 +63,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 +73,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 +89,7 @@ class Comment extends Base $task = $this->getTask(); $comment = $this->getComment(); - $this->response->html($this->taskLayout('comment/edit', array( + $this->response->html($this->template->render('comment/edit', array( 'values' => empty($values) ? $comment : $values, 'errors' => $errors, 'comment' => $comment, @@ -124,7 +106,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 +118,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 +134,7 @@ class Comment extends Base $task = $this->getTask(); $comment = $this->getComment(); - $this->response->html($this->taskLayout('comment/remove', array( + $this->response->html($this->template->render('comment/remove', array( 'comment' => $comment, 'task' => $task, 'title' => t('Remove a comment') |