show Characters and Roles of an user
This commit is contained in:
parent
6a52ded20e
commit
a0f85a976a
6 changed files with 116 additions and 0 deletions
35
agents/bottomlevel/UserrolesAgent.inc
Normal file
35
agents/bottomlevel/UserrolesAgent.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 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)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -30,6 +30,15 @@
|
|||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action: user.
|
||||
*/
|
||||
public function user(\nre\core\Request $request, \nre\core\Response $response)
|
||||
{
|
||||
$this->addSubAgent('Userroles', 'user');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
47
controllers/UserrolesController.inc
Normal file
47
controllers/UserrolesController.inc
Normal 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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
5
views/html/userroles/user.tpl
Normal file
5
views/html/userroles/user.tpl
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<ul>
|
||||
<?php foreach($roles as &$role) : ?>
|
||||
<li><?=$role['name']?></li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
|
|
@ -7,3 +7,13 @@
|
|||
<p>
|
||||
<?=sprintf(_('registered on %s'), $dateFormatter->format(new \DateTime($user['created'])))?>
|
||||
</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?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue