diff --git a/agents/bottomlevel/SeminarymenuAgent.inc b/agents/bottomlevel/SeminarymenuAgent.inc new file mode 100644 index 00000000..375eab1e --- /dev/null +++ b/agents/bottomlevel/SeminarymenuAgent.inc @@ -0,0 +1,35 @@ + + * @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 + */ + class SeminarymenuAgent extends \nre\agents\BottomlevelAgent + { + + + + + /** + * Action: index. + */ + public function index(\nre\core\Request $request, \nre\core\Response $response) + { + } + + } + +?> diff --git a/agents/toplevel/HtmlAgent.inc b/agents/toplevel/HtmlAgent.inc index 63ed4525..0648160e 100644 --- a/agents/toplevel/HtmlAgent.inc +++ b/agents/toplevel/HtmlAgent.inc @@ -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'); } diff --git a/app/controllers/ToplevelController.inc b/app/controllers/ToplevelController.inc index 30558c91..5e640dca 100644 --- a/app/controllers/ToplevelController.inc +++ b/app/controllers/ToplevelController.inc @@ -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'); diff --git a/configs/AppConfig.inc b/configs/AppConfig.inc index 9077da8f..817b0114 100644 --- a/configs/AppConfig.inc +++ b/configs/AppConfig.inc @@ -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) ); diff --git a/controllers/SeminarymenuController.inc b/controllers/SeminarymenuController.inc new file mode 100644 index 00000000..a2289777 --- /dev/null +++ b/controllers/SeminarymenuController.inc @@ -0,0 +1,52 @@ + + * @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 + */ + 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() + { + } + + } + +?> diff --git a/views/html/html.tpl b/views/html/html.tpl index cbaa5a65..e36da721 100644 --- a/views/html/html.tpl +++ b/views/html/html.tpl @@ -38,6 +38,9 @@ + + +
diff --git a/views/html/menu/index.tpl b/views/html/menu/index.tpl index 11806da4..393e4747 100644 --- a/views/html/menu/index.tpl +++ b/views/html/menu/index.tpl @@ -1,12 +1,8 @@ -
  • -
  • The Legend of Z
  • -
  • +
  • The Legend of Z
  • +
  • +
  • -
  • Gilden
  • -
  • Achievements
  • -
  • Karte
  • -
  • Bibliothek
  • diff --git a/views/html/seminarymenu/index.tpl b/views/html/seminarymenu/index.tpl new file mode 100644 index 00000000..fa6d4457 --- /dev/null +++ b/views/html/seminarymenu/index.tpl @@ -0,0 +1,7 @@ + +
  • +
  • +
  • +
  • +
  • +