Skip to content

Commit

Permalink
UserController: Display a tab when showing a user
Browse files Browse the repository at this point in the history
refs #8826
  • Loading branch information
Johannes Meyer committed May 22, 2015
1 parent 705bb66 commit 5c6d5f5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
44 changes: 30 additions & 14 deletions application/controllers/UserController.php
Expand Up @@ -19,15 +19,6 @@

class UserController extends Controller
{
/**
* Initialize this controller
*/
public function init()
{
parent::init();
$this->createTabs();
}

/**
* Redirect to this controller's list action
*/
Expand Down Expand Up @@ -85,7 +76,7 @@ function ($b) { return $b->getName(); },
}

$this->view->backend = $backend;
$this->getTabs()->activate('user/list');
$this->createListTabs()->activate('user/list');

$this->setupLimitControl();
$this->setupSortControl(
Expand Down Expand Up @@ -139,6 +130,7 @@ public function showAction()
$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();
Expand Down Expand Up @@ -306,17 +298,17 @@ protected function getUserBackend($name = null, $interface = 'Icinga\Data\Select
}

/**
* Create the tabs
* Create the tabs to list users and groups
*/
protected function createTabs()
protected function createListTabs()
{
$tabs = $this->getTabs();
$tabs->add(
'user/list',
array(
'title' => $this->translate('List users of authentication backends'),
'label' => $this->translate('Users'),
'icon' => 'users',
'icon' => 'user',
'url' => 'user/list'
)
);
Expand All @@ -325,9 +317,33 @@ protected function createTabs()
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;
}
}
2 changes: 1 addition & 1 deletion application/views/scripts/user/show.phtml
Expand Up @@ -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; ?>
Expand Down

0 comments on commit 5c6d5f5

Please sign in to comment.