update menu (split system and Seminary related elements)

This commit is contained in:
coderkun 2014-03-30 14:21:45 +02:00
commit 42437ddd46
8 changed files with 114 additions and 24 deletions

View file

@ -0,0 +1,35 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\agents\bottomlevel;
/**
* Agent to display a menu with Seminary related links.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class SeminarymenuAgent extends \nre\agents\BottomlevelAgent
{
/**
* Action: index.
*/
public function index(\nre\core\Request $request, \nre\core\Response $response)
{
}
}
?>

View file

@ -37,8 +37,9 @@
*/
public function index(\nre\core\Request $request, \nre\core\Response $response)
{
// Add menu
// Add menus
$this->addSubAgent('Menu');
$this->addSubAgent('Seminarymenu');
}

View file

@ -78,6 +78,13 @@
try {
static::$user = $this->Users->getUserById($this->Auth->getUserId());
// Determine user roles
static::$user['roles'] = array();
$roles = $this->Userroles->getUserrolesForUserById(static::$user['id']);
foreach($roles as &$role) {
static::$user['roles'][] = $role['name'];
}
// Character
$controller = $this->agent->getIntermediateAgent()->controller;
if(is_subclass_of($controller, '\hhu\z\controllers\SeminaryRoleController'))
@ -122,7 +129,10 @@
private function checkPermission(\nre\core\Request $request, \nre\core\Response $response)
{
// Determine user
$userId = $this->Auth->getUserId();
$userRoles = array('guest');
if(!is_null(static::$user)) {
$userRoles = static::$user['roles'];
}
// Do not check error pages
@ -133,20 +143,6 @@
return;
}
// Determine user roles
if($userId > 0)
{
$userRoles = array();
$roles = $this->Userroles->getUserrolesForUserById($userId);
foreach($roles as &$role) {
$userRoles[] = $role['name'];
}
}
else {
$userRoles = array('guest');
}
// Determine permissions of Intermediate Controller for current action
$controller = $this->agent->getIntermediateAgent()->controller;
$action = $this->request->getParam(2, 'action');

View file

@ -103,7 +103,7 @@
array('seminaries/seminary/(.*)', 'seminaries/$1', false),
//array('seminaries/seminary/(.*)', '$1', false)
array('characters/index/(.*)', 'characters/$1', true),
array('charactergroup/index/(.*)', 'charactergroup/$1', true),
array('charactergroups/index/(.*)', 'charactergroups/$1', true),
array('charactergroupsquests/quest/(.*)', 'charactergroupsquests/$1', true)
);

View file

@ -0,0 +1,52 @@
<?php
/**
* The Legend of Z
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
* @copyright 2014 Heinrich-Heine-Universität Düsseldorf
* @license http://www.gnu.org/licenses/gpl.html
* @link https://bitbucket.org/coderkun/the-legend-of-z
*/
namespace hhu\z\controllers;
/**
* Controller of the Agent to display a menu with Seminary related
* links.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class SeminarymenuController extends \hhu\z\Controller
{
/**
* Prefilter.
*
* @param Request $request Current request
* @param Response $response Current response
*/
public function preFilter(\nre\core\Request $request, \nre\core\Response $response)
{
parent::preFilter($request, $response);
// Set userdata
$this->set('loggedUser', HtmlController::$user);
$this->set('loggedSeminary', HtmlController::$seminary);
}
/**
* Action: index.
*/
public function index()
{
}
}
?>

View file

@ -38,6 +38,9 @@
<?php endif ?>
<?php endif ?>
<?=$menu?>
<?php if(!is_null($loggedSeminary)) : ?>
<?=$seminarymenu?>
<?php endif ?>
</nav>
</header>
<article class="wrap">

View file

@ -1,12 +1,8 @@
<menu>
<?php if(is_null($loggedUser)) : ?><li><a href="<?=$linker->link(null)?>"><i class="fa fa-users fa-fw"></i><?=_('Introduction')?></a></li><?php endif ?>
<li><a href="<?=$linker->link(array(), 0, true, array(), true)?>"><i class="fa fa-users fa-fw"></i>The Legend of Z</a></li>
<?php if(!is_null($loggedUser)) : ?><li><a href="<?=$linker->link('users')?>"><i class="fa fa-users fa-fw"></i><?=_('Users')?></a></li><?php endif ?>
<li><a href="<?=$linker->link(array(), 0, true, array(), true)?>">The Legend of Z</a></li>
<?php if(!is_null($loggedUser) && !empty(array_intersect(array('admin','moderator'),$loggedUser['roles']))) : ?><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('usersgroups')?>"><i class="fa fa-users fa-fw"></i><?=_('Usergroups')?></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($loggedUser)) : ?><li><a href="#"><i class="fa fa-users fa-fw"></i>Gilden</a></li><?php endif ?>
<?php if(!is_null($loggedUser)) : ?><li><a href="#"><i class="fa fa-trophy fa-fw"></i>Achievements</a></li><?php endif ?>
<?php if(!is_null($loggedUser)) : ?><li><a href="#"><i class="fa fa-picture-o fa-fw"></i>Karte</a></li><?php endif ?>
<?php if(!is_null($loggedUser)) : ?><li><a href="#"><i class="fa fa-book fa-fw"></i>Bibliothek</a></li><?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

@ -0,0 +1,7 @@
<menu>
<li><a href="<?=$linker->link(array('seminaries',$loggedSeminary['url']))?>"><?=$loggedSeminary['title']?></a></li>
<?php if(!empty(array_intersect(array('admin','moderator'),$loggedUser['roles']))) : ?><li><a href="<?=$linker->link(array('characters',$loggedSeminary['url']))?>"><i class="fa fa-users fa-fw"></i><?=_('Characters')?></a></li><?php endif ?>
<li><a href="<?=$linker->link(array('charactergroups','index',$loggedSeminary['url']))?>"><i class="fa fa-users fa-fw"></i><?=_('Character Groups')?></a></li>
<li><a href="<?=$linker->link(array('achievements','index',$loggedSeminary['url']))?>"><i class="fa fa-trophy fa-fw"></i><?=_('Achievements')?></a></li>
<li><a href="<?=$linker->link(array('library','index',$loggedSeminary['url']))?>"><i class="fa fa-book fa-fw"></i><?=_('Library')?></a></li>
</menu>