summaryrefslogtreecommitdiff
path: root/app/Controller/Board.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-05-15 18:31:47 -0400
committerFrederic Guillot <fred@kanboard.net>2016-05-15 18:31:47 -0400
commit67b836164997527b91452b19adbcb8aa3c5decf1 (patch)
treeb5876d311912e97b0592c7e208639f7b52813a75 /app/Controller/Board.php
parent108e867605dbc7ece4cbcbecc89a674e9c154a9b (diff)
Refactoring: added controlled middleware and changed response class
Diffstat (limited to 'app/Controller/Board.php')
-rw-r--r--app/Controller/Board.php28
1 files changed, 14 insertions, 14 deletions
diff --git a/app/Controller/Board.php b/app/Controller/Board.php
index 67e99b81..0f6b3b14 100644
--- a/app/Controller/Board.php
+++ b/app/Controller/Board.php
@@ -2,6 +2,7 @@
namespace Kanboard\Controller;
+use Kanboard\Core\Controller\AccessForbiddenException;
use Kanboard\Formatter\BoardFormatter;
/**
@@ -10,7 +11,7 @@ use Kanboard\Formatter\BoardFormatter;
* @package controller
* @author Frederic Guillot
*/
-class Board extends Base
+class Board extends BaseController
{
/**
* Display the public version of a board
@@ -25,7 +26,7 @@ class Board extends Base
// Token verification
if (empty($project)) {
- $this->forbidden(true);
+ throw AccessForbiddenException::getInstance()->withoutLayout();
}
// Display the board with a specific layout
@@ -74,7 +75,7 @@ class Board extends Base
$project_id = $this->request->getIntegerParam('project_id');
if (! $project_id || ! $this->request->isAjax()) {
- return $this->response->status(403);
+ throw new AccessForbiddenException();
}
$values = $this->request->getJson();
@@ -88,10 +89,10 @@ class Board extends Base
);
if (! $result) {
- return $this->response->status(400);
+ $this->response->status(400);
+ } else {
+ $this->response->html($this->renderBoard($project_id), 201);
}
-
- $this->response->html($this->renderBoard($project_id), 201);
}
/**
@@ -105,14 +106,12 @@ class Board extends Base
$timestamp = $this->request->getIntegerParam('timestamp');
if (! $project_id || ! $this->request->isAjax()) {
- return $this->response->status(403);
- }
-
- if (! $this->project->isModifiedSince($project_id, $timestamp)) {
- return $this->response->status(304);
+ $this->response->status(403);
+ } elseif (! $this->project->isModifiedSince($project_id, $timestamp)) {
+ $this->response->status(304);
+ } else {
+ $this->response->html($this->renderBoard($project_id));
}
-
- return $this->response->html($this->renderBoard($project_id));
}
/**
@@ -125,7 +124,7 @@ class Board extends Base
$project_id = $this->request->getIntegerParam('project_id');
if (! $project_id || ! $this->request->isAjax()) {
- return $this->response->status(403);
+ throw new AccessForbiddenException();
}
$values = $this->request->getJson();
@@ -177,6 +176,7 @@ class Board extends Base
*
* @access private
* @param integer $project_id
+ * @return string
*/
private function renderBoard($project_id)
{