diff --git a/agents/bottomlevel/UserrolesAgent.inc b/agents/bottomlevel/UserrolesAgent.inc new file mode 100644 index 00000000..b6d6e65b --- /dev/null +++ b/agents/bottomlevel/UserrolesAgent.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 and manage userroles. + * + * @author Oliver Hanraths + */ + class UserrolesAgent extends \nre\agents\BottomlevelAgent + { + + + + + /** + * Action: user. + */ + public function user(\nre\core\Request $request, \nre\core\Response $response) + { + } + + } + +?> diff --git a/agents/intermediate/UsersAgent.inc b/agents/intermediate/UsersAgent.inc index 7b929586..a9094490 100644 --- a/agents/intermediate/UsersAgent.inc +++ b/agents/intermediate/UsersAgent.inc @@ -30,6 +30,15 @@ { } + + /** + * Action: user. + */ + public function user(\nre\core\Request $request, \nre\core\Response $response) + { + $this->addSubAgent('Userroles', 'user'); + } + } ?> diff --git a/controllers/UserrolesController.inc b/controllers/UserrolesController.inc new file mode 100644 index 00000000..80c00347 --- /dev/null +++ b/controllers/UserrolesController.inc @@ -0,0 +1,47 @@ + + * @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 and manage userroles. + * + * @author Oliver Hanraths + */ + class UserrolesController extends \hhu\z\Controller + { + + + + + /** + * Action: user. + * + * Show a user and its details. + * + * @throws IdNotFoundException + * @param string $userUrl URL-Username of an user + */ + public function user($userUrl) + { + // Get userroles + $roles = $this->Userroles->getUserrolesForUserByUrl($userUrl); + + + // Pass data to view + $this->set('roles', $roles); + } + + + } + +?> diff --git a/controllers/UsersController.inc b/controllers/UsersController.inc index fb6c8d16..a9eb9f91 100644 --- a/controllers/UsersController.inc +++ b/controllers/UsersController.inc @@ -31,6 +31,12 @@ 'edit' => array('admin', 'moderator'), 'delete' => array('admin') ); + /** + * Required models + * + * @var array + */ + public $models = array('users', 'characters'); @@ -62,9 +68,13 @@ // Get user $user = $this->Users->getUserByUrl($userUrl); + // Get Characters + $characters = $this->Characters->getCharactersForUser($user['id']); + // Pass data to view $this->set('user', $user); + $this->set('characters', $characters); } diff --git a/views/html/userroles/user.tpl b/views/html/userroles/user.tpl new file mode 100644 index 00000000..df8b7a66 --- /dev/null +++ b/views/html/userroles/user.tpl @@ -0,0 +1,5 @@ + diff --git a/views/html/users/user.tpl b/views/html/users/user.tpl index 2b2ea884..2c081f2d 100644 --- a/views/html/users/user.tpl +++ b/views/html/users/user.tpl @@ -7,3 +7,13 @@

format(new \DateTime($user['created'])))?>

+ +

+ + +

+