summaryrefslogtreecommitdiff
path: root/app/Controller/CommentController.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-08-21 20:36:16 -0400
committerFrederic Guillot <fred@kanboard.net>2016-08-21 20:36:16 -0400
commit1d16a53c480ea7eb93ba118f6ffd69131eb5f3c5 (patch)
tree822a3a22ce1411a1ad10665c6c7b8f3b6c2ed3b5 /app/Controller/CommentController.php
parent8e83e404fbb1d0dc770e5b41fa315a674541459a (diff)
Store comment sorting direction in user metadata
Diffstat (limited to 'app/Controller/CommentController.php')
-rw-r--r--app/Controller/CommentController.php20
1 files changed, 14 insertions, 6 deletions
diff --git a/app/Controller/CommentController.php b/app/Controller/CommentController.php
index 2a8c258a..c61a0602 100644
--- a/app/Controller/CommentController.php
+++ b/app/Controller/CommentController.php
@@ -4,6 +4,7 @@ namespace Kanboard\Controller;
use Kanboard\Core\Controller\AccessForbiddenException;
use Kanboard\Core\Controller\PageNotFoundException;
+use Kanboard\Model\UserMetadataModel;
/**
* Comment Controller
@@ -82,10 +83,10 @@ class CommentController extends BaseController
$this->flash->failure(t('Unable to create your comment.'));
}
- return $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), 'comments'), true);
+ $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), 'comments'), true);
+ } else {
+ $this->create($values, $errors);
}
-
- return $this->create($values, $errors);
}
/**
@@ -183,9 +184,16 @@ class CommentController extends BaseController
{
$task = $this->getTask();
- $order = $this->userSession->getCommentSorting() === 'ASC' ? 'DESC' : 'ASC';
- $this->userSession->setCommentSorting($order);
+ $oldDirection = $this->userMetadataCacheDecorator->get(UserMetadataModel::KEY_COMMENT_SORTING_DIRECTION, 'ASC');
+ $newDirection = $oldDirection === 'ASC' ? 'DESC' : 'ASC';
- $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), 'comments'));
+ $this->userMetadataCacheDecorator->set(UserMetadataModel::KEY_COMMENT_SORTING_DIRECTION, $newDirection);
+
+ $this->response->redirect($this->helper->url->to(
+ 'TaskViewController',
+ 'show',
+ array('task_id' => $task['id'], 'project_id' => $task['project_id']),
+ 'comments'
+ ));
}
}