UserController: Display a tab when showing a user

refs #8826
This commit is contained in:
Johannes Meyer 2015-05-22 16:13:20 +02:00
parent 705bb665a5
commit 5c6d5f51c4
2 changed files with 31 additions and 15 deletions

View File

@ -19,15 +19,6 @@ use Icinga\Web\Widget;
class UserController extends Controller
{
/**
* Initialize this controller
*/
public function init()
{
parent::init();
$this->createTabs();
}
/**
* Redirect to this controller's list action
*/
@ -85,7 +76,7 @@ class UserController extends Controller
}
$this->view->backend = $backend;
$this->getTabs()->activate('user/list');
$this->createListTabs()->activate('user/list');
$this->setupLimitControl();
$this->setupSortControl(
@ -139,6 +130,7 @@ class UserController extends Controller
$this->view->user = $user;
$this->view->backend = $backend;
$this->view->memberships = $memberships;
$this->createShowTabs($backend->getName(), $userName)->activate('user/show');
$removeForm = new Form();
$removeForm->setUidDisabled();
@ -306,9 +298,9 @@ class UserController extends Controller
}
/**
* Create the tabs
* Create the tabs to list users and groups
*/
protected function createTabs()
protected function createListTabs()
{
$tabs = $this->getTabs();
$tabs->add(
@ -316,7 +308,7 @@ class UserController extends Controller
array(
'title' => $this->translate('List users of authentication backends'),
'label' => $this->translate('Users'),
'icon' => 'users',
'icon' => 'user',
'url' => 'user/list'
)
);
@ -325,9 +317,33 @@ class UserController extends Controller
array(
'title' => $this->translate('List groups of user group backends'),
'label' => $this->translate('Groups'),
'icon' => 'cubes',
'icon' => 'users',
'url' => 'group/list'
)
);
return $tabs;
}
/**
* Create the tabs to display when showing a user
*
* @param string $backendName
* @param string $userName
*/
protected function createShowTabs($backendName, $userName)
{
$tabs = $this->getTabs();
$tabs->add(
'user/show',
array(
'title' => sprintf($this->translate('Show user %s'), $userName),
'label' => $this->translate('User'),
'icon' => 'user',
'url' => Url::fromPath('user/show', array('backend' => $backendName, 'user' => $userName))
)
);
return $tabs;
}
}

View File

@ -23,7 +23,7 @@ if ($backend instanceof Updatable) {
?>
<div class="controls">
<?php if (! $this->compact): ?>
<?= $tabs->showOnlyCloseButton(); ?>
<?= $tabs; ?>
<?php endif ?>
<div class="user-header">
<p class="user-name"><strong><?= $this->escape($user->user_name); ?></strong></p> <?= $editLink; ?>