From 67bff1f5a6691ccc7e705e141fa609106220121d Mon Sep 17 00:00:00 2001 From: coderkun Date: Thu, 17 Apr 2014 00:27:59 +0200 Subject: [PATCH] few fixed for Character permissions --- app/controllers/SeminaryRoleController.inc | 2 +- controllers/CharactersController.inc | 10 ++++++++++ controllers/MenuController.inc | 1 + controllers/SeminarymenuController.inc | 6 +++--- views/html/html.tpl | 4 +--- views/html/menu/index.tpl | 2 +- views/html/seminarymenu/index.tpl | 1 - 7 files changed, 17 insertions(+), 9 deletions(-) diff --git a/app/controllers/SeminaryRoleController.inc b/app/controllers/SeminaryRoleController.inc index cb7f6b86..f5bba984 100644 --- a/app/controllers/SeminaryRoleController.inc +++ b/app/controllers/SeminaryRoleController.inc @@ -137,7 +137,7 @@ // Check permissions - if(count(array_intersect(self::$user['seminaryroles'], $permissions)) == 0) { + if(!array_key_exists('seminaryroles', self::$user) || count(array_intersect(self::$user['seminaryroles'], $permissions)) == 0) { throw new \nre\exceptions\AccessDeniedException(); } } diff --git a/controllers/CharactersController.inc b/controllers/CharactersController.inc index 1adab0d3..7046e1a1 100644 --- a/controllers/CharactersController.inc +++ b/controllers/CharactersController.inc @@ -158,6 +158,16 @@ // Get seminary $seminary = $this->Seminaries->getSeminaryByUrl($seminaryUrl); + // Check for already existing Character + try { + $this->Characters->getCharacterForUserAndSeminary($this->Auth->getUserId(), $seminary['id']); + throw new \nre\exceptions\AccessDeniedException(); + } + catch(\nre\exceptions\IdNotFoundException $e) { + // The should be the case + } + + // Character types $types = $this->Charactertypes->getCharacterTypesForSeminary($seminary['id']); diff --git a/controllers/MenuController.inc b/controllers/MenuController.inc index c254a617..b7557c1f 100644 --- a/controllers/MenuController.inc +++ b/controllers/MenuController.inc @@ -35,6 +35,7 @@ // Set userdata $this->set('loggedUser', IntermediateController::$user); + $this->set('loggedCharacter', SeminaryRoleController::$character); $this->set('loggedSeminary', SeminaryRoleController::$seminary); } diff --git a/controllers/SeminarymenuController.inc b/controllers/SeminarymenuController.inc index 5b5d780f..8f2957d7 100644 --- a/controllers/SeminarymenuController.inc +++ b/controllers/SeminarymenuController.inc @@ -18,7 +18,7 @@ * * @author Oliver Hanraths */ - class SeminarymenuController extends \hhu\z\Controller + class SeminarymenuController extends \hhu\z\controllers\SeminaryRoleController { @@ -35,8 +35,8 @@ parent::preFilter($request, $response); // Set userdata - $this->set('loggedUser', IntermediateController::$user); - $this->set('loggedSeminary', SeminaryRoleController::$seminary); + $this->set('loggedUser', self::$user); + $this->set('loggedSeminary', self::$seminary); } diff --git a/views/html/html.tpl b/views/html/html.tpl index 9cfcf8f3..a62f4e11 100644 --- a/views/html/html.tpl +++ b/views/html/html.tpl @@ -47,11 +47,9 @@ diff --git a/views/html/menu/index.tpl b/views/html/menu/index.tpl index c2662789..dbab43c2 100644 --- a/views/html/menu/index.tpl +++ b/views/html/menu/index.tpl @@ -1,7 +1,7 @@
  • The Legend of Z
  • 0) : ?>
  • - + 0) : ?>
  • diff --git a/views/html/seminarymenu/index.tpl b/views/html/seminarymenu/index.tpl index 041c4f43..56b9307b 100644 --- a/views/html/seminarymenu/index.tpl +++ b/views/html/seminarymenu/index.tpl @@ -3,4 +3,3 @@
  • -