show Characters and Roles of an user

This commit is contained in:
coderkun 2014-02-09 13:33:38 +01:00
commit a0f85a976a
6 changed files with 116 additions and 0 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 and manage userroles.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
class UserrolesAgent extends \nre\agents\BottomlevelAgent
{
/**
* Action: user.
*/
public function user(\nre\core\Request $request, \nre\core\Response $response)
{
}
}
?>

View file

@ -30,6 +30,15 @@
{ {
} }
/**
* Action: user.
*/
public function user(\nre\core\Request $request, \nre\core\Response $response)
{
$this->addSubAgent('Userroles', 'user');
}
} }
?> ?>

View file

@ -0,0 +1,47 @@
<?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 and manage userroles.
*
* @author Oliver Hanraths <oliver.hanraths@uni-duesseldorf.de>
*/
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);
}
}
?>

View file

@ -31,6 +31,12 @@
'edit' => array('admin', 'moderator'), 'edit' => array('admin', 'moderator'),
'delete' => array('admin') 'delete' => array('admin')
); );
/**
* Required models
*
* @var array
*/
public $models = array('users', 'characters');
@ -62,9 +68,13 @@
// Get user // Get user
$user = $this->Users->getUserByUrl($userUrl); $user = $this->Users->getUserByUrl($userUrl);
// Get Characters
$characters = $this->Characters->getCharactersForUser($user['id']);
// Pass data to view // Pass data to view
$this->set('user', $user); $this->set('user', $user);
$this->set('characters', $characters);
} }

View file

@ -0,0 +1,5 @@
<ul>
<?php foreach($roles as &$role) : ?>
<li><?=$role['name']?></li>
<?php endforeach ?>
</ul>

View file

@ -7,3 +7,13 @@
<p> <p>
<?=sprintf(_('registered on %s'), $dateFormatter->format(new \DateTime($user['created'])))?> <?=sprintf(_('registered on %s'), $dateFormatter->format(new \DateTime($user['created'])))?>
</p> </p>
<h3><?=_('Characters')?></h3>
<ul>
<?php foreach($characters as &$character) : ?>
<li><?=$character['name']?> (<a href="<?=$linker->link(array('seminaries',$character['seminary_url']))?>"><?=$character['seminary_title']?></a>)</li>
<?php endforeach ?>
</ul>
<h3><?=_('Roles')?></h3>
<?=$userroles?>