few fixed for Character permissions

This commit is contained in:
coderkun 2014-04-17 00:27:59 +02:00
commit 67bff1f5a6
7 changed files with 17 additions and 9 deletions

View file

@ -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();
}
}

View file

@ -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']);

View file

@ -35,6 +35,7 @@
// Set userdata
$this->set('loggedUser', IntermediateController::$user);
$this->set('loggedCharacter', SeminaryRoleController::$character);
$this->set('loggedSeminary', SeminaryRoleController::$seminary);
}

View file

@ -18,7 +18,7 @@
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
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);
}

View file

@ -47,11 +47,9 @@
<?=$intermediate?>
</article>
<aside>
<?php if(!is_null($loggedUser)) : ?>
<?php if(!is_null($loggedCharacter)) : ?>
<?php if(!is_null($loggedCharacter) && count($loggedUser['seminaryroles']) > 0) : ?>
<?=$seminarybar?>
<?php endif ?>
<?php endif ?>
</aside>
</body>

View file

@ -1,7 +1,7 @@
<li><a href="<?=$linker->link(array(), 0, true, array(), true)?>"><i class="fa fa-home fa-fw"></i>The Legend of Z</a></li>
<?php if(!is_null($loggedUser) && count(array_intersect(array('admin','moderator'),$loggedUser['roles'])) > 0) : ?><li><a href="<?=$linker->link('users')?>"><i class="fa fa-users fa-fw"></i><?=_('Users')?></a></li><?php endif ?>
<?php if(!is_null($loggedUser)) : ?><li><a href="<?=$linker->link('seminaries')?>"><i class="fa fa-pencil-square-o fa-fw"></i><?=_('Seminaries')?></a></li><?php endif ?>
<?php if(!is_null($loggedSeminary)) : ?><?=$seminarymenu?><?php endif ?>
<?php if(!is_null($loggedCharacter) && count($loggedUser['seminaryroles']) > 0) : ?><?=$seminarymenu?><?php endif ?>
<?php if(is_null($loggedUser)) : ?>
<li><a href="<?=$linker->link(array('users','login'))?>"><i class="fa fa-sign-in fa-fw"></i><?=_('Login')?></a></li>
<?php else : ?>

View file

@ -3,4 +3,3 @@
<li><a href="<?=$linker->link(array('charactergroups','index',$loggedSeminary['url']))?>" class="smnry"><i class="fa fa-users fa-fw"></i><?=_('Character Groups')?></a></li>
<li><a href="<?=$linker->link(array('achievements','index',$loggedSeminary['url']))?>" class="smnry"><i class="fa fa-trophy fa-fw"></i><?=_('Achievements')?></a></li>
<li><a href="<?=$linker->link(array('library','index',$loggedSeminary['url']))?>" class="smnry"><i class="fa fa-book fa-fw"></i><?=_('Library')?></a></li>