summaryrefslogtreecommitdiff
path: root/app/Controller/Comment.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-01-30 22:25:16 -0500
committerFrederic Guillot <fred@kanboard.net>2016-01-30 22:25:16 -0500
commitbb040cfb78d53696edd63bf256d0fd8ba3ccdbfa (patch)
tree811d150fddd6220faabb3c1ea1743ffd7f781e45 /app/Controller/Comment.php
parent4a52d327f7e555c336a428c457cf40c3d97bfab3 (diff)
Simplify code to handle ajax popover and redirects
Diffstat (limited to 'app/Controller/Comment.php')
-rw-r--r--app/Controller/Comment.php15
1 files changed, 4 insertions, 11 deletions
diff --git a/app/Controller/Comment.php b/app/Controller/Comment.php
index c77a4712..549c0c65 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;
@@ -66,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);
@@ -77,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);
@@ -126,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']), 'comment-'.$comment['id']));
}
$this->edit($values, $errors);