update menu (split system and Seminary related elements)
This commit is contained in:
parent
879364d8e2
commit
55ae9cf198
8 changed files with 114 additions and 24 deletions
35
agents/bottomlevel/SeminarymenuAgent.inc
Normal file
35
agents/bottomlevel/SeminarymenuAgent.inc
Normal 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)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
@ -37,8 +37,9 @@
|
||||||
*/
|
*/
|
||||||
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
public function index(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
{
|
{
|
||||||
// Add menu
|
// Add menus
|
||||||
$this->addSubAgent('Menu');
|
$this->addSubAgent('Menu');
|
||||||
|
$this->addSubAgent('Seminarymenu');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,13 @@
|
||||||
try {
|
try {
|
||||||
static::$user = $this->Users->getUserById($this->Auth->getUserId());
|
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
|
// Character
|
||||||
$controller = $this->agent->getIntermediateAgent()->controller;
|
$controller = $this->agent->getIntermediateAgent()->controller;
|
||||||
if(is_subclass_of($controller, '\hhu\z\controllers\SeminaryRoleController'))
|
if(is_subclass_of($controller, '\hhu\z\controllers\SeminaryRoleController'))
|
||||||
|
|
@ -122,7 +129,10 @@
|
||||||
private function checkPermission(\nre\core\Request $request, \nre\core\Response $response)
|
private function checkPermission(\nre\core\Request $request, \nre\core\Response $response)
|
||||||
{
|
{
|
||||||
// Determine user
|
// Determine user
|
||||||
$userId = $this->Auth->getUserId();
|
$userRoles = array('guest');
|
||||||
|
if(!is_null(static::$user)) {
|
||||||
|
$userRoles = static::$user['roles'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Do not check error pages
|
// Do not check error pages
|
||||||
|
|
@ -133,20 +143,6 @@
|
||||||
return;
|
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
|
// Determine permissions of Intermediate Controller for current action
|
||||||
$controller = $this->agent->getIntermediateAgent()->controller;
|
$controller = $this->agent->getIntermediateAgent()->controller;
|
||||||
$action = $this->request->getParam(2, 'action');
|
$action = $this->request->getParam(2, 'action');
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@
|
||||||
array('seminaries/seminary/(.*)', 'seminaries/$1', false),
|
array('seminaries/seminary/(.*)', 'seminaries/$1', false),
|
||||||
//array('seminaries/seminary/(.*)', '$1', false)
|
//array('seminaries/seminary/(.*)', '$1', false)
|
||||||
array('characters/index/(.*)', 'characters/$1', true),
|
array('characters/index/(.*)', 'characters/$1', true),
|
||||||
array('charactergroup/index/(.*)', 'charactergroup/$1', true),
|
array('charactergroups/index/(.*)', 'charactergroups/$1', true),
|
||||||
array('charactergroupsquests/quest/(.*)', 'charactergroupsquests/$1', true)
|
array('charactergroupsquests/quest/(.*)', 'charactergroupsquests/$1', true)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
52
controllers/SeminarymenuController.inc
Normal file
52
controllers/SeminarymenuController.inc
Normal 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()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
@ -38,6 +38,9 @@
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
<?=$menu?>
|
<?=$menu?>
|
||||||
|
<?php if(!is_null($loggedSeminary)) : ?>
|
||||||
|
<?=$seminarymenu?>
|
||||||
|
<?php endif ?>
|
||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
<article class="wrap">
|
<article class="wrap">
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,8 @@
|
||||||
<menu>
|
<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)?>">The Legend of Z</a></li>
|
||||||
<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) && !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('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="<?=$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)) : ?>
|
<?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>
|
<li><a href="<?=$linker->link(array('users','login'))?>"><i class="fa fa-sign-in fa-fw"></i><?=_('Login')?></a></li>
|
||||||
<?php else : ?>
|
<?php else : ?>
|
||||||
|
|
|
||||||
7
views/html/seminarymenu/index.tpl
Normal file
7
views/html/seminarymenu/index.tpl
Normal 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>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue