UserController: Add showAction

refs #8826
This commit is contained in:
Johannes Meyer 2015-05-20 15:41:02 +02:00
parent 9891dc4491
commit 2cec4a6d67
4 changed files with 79 additions and 1 deletions

View File

@ -96,6 +96,28 @@ class UserController extends Controller
);
}
/**
* Show a user
*/
public function showAction()
{
$userName = $this->params->getRequired('user');
$backend = $this->getUserBackend($this->params->getRequired('backend'));
$user = $backend->select(array(
'user_name',
'is_active',
'created_at',
'last_modified'
))->where('user_name', $userName)->fetchRow();
if ($user === false) {
$this->httpNotFound(sprintf($this->translate('User "%s" not found'), $userName));
}
$this->view->user = $user;
$this->view->backend = $backend;
}
/**
* Add a user
*/
@ -125,6 +147,7 @@ class UserController extends Controller
}
$form = new UserForm();
$form->setRedirectUrl(Url::fromPath('user/show', array('backend' => $backend->getName(), 'user' => $userName)));
$form->setRepository($backend);
$form->edit($userName, get_object_vars($row))->handleRequest();

View File

@ -44,7 +44,12 @@ if (count($users) > 0): ?>
<tbody>
<?php foreach ($users as $user): ?>
<tr>
<td clas="user-name"><?= $this->escape($user->user_name); ?></td>
<td class="user-name"><?= $this->qlink($user->user_name, 'user/show', array(
'backend' => $backend->getName(),
'user' => $user->user_name
), array(
'title' => sprintf($this->translate('Show detailed information about %s'), $user->user_name)
)); ?></td>
<?php if ($reducible): ?>
<td class="user-remove">
<?= $this->qlink(

View File

@ -0,0 +1,35 @@
<?php
use Icinga\Data\Updatable;
$editLink = null;
if ($backend instanceof Updatable) {
$editLink = $this->qlink(
null,
'user/edit',
array(
'backend' => $backend->getName(),
'user' => $user->user_name
),
array(
'title' => sprintf($this->translate('Edit user %s'), $user->user_name),
'class' => 'user-edit',
'icon' => 'edit'
)
);
}
?>
<div class="controls">
<?php if (! $this->compact): ?>
<?= $tabs->showOnlyCloseButton(); ?>
<?php endif ?>
<div class="user-header">
<p class="user-name"><strong><?= $this->escape($user->user_name); ?></strong></p> <?= $editLink; ?>
<p class="user-state"><strong><?= $this->translate('State'); ?>:</strong> <?= $user->is_active ? $this->translate('Active') : $this->translate('Inactive'); ?></p>
<p class="user-created"><strong><?= $this->translate('Created at'); ?>:</strong> <?= $user->created_at === null ? '-' : $this->formatDateTime($user->created_at); ?></p>
<p class="user-modified"><strong><?= $this->translate('Last modified'); ?>:</strong> <?= $user->last_modified === null ? '-' : $this->formatDateTime($user->last_modified); ?></p>
</div>
</div>
<div class="content" data-base-target="_next">
</div>

View File

@ -226,6 +226,21 @@ div.content.users {
}
}
div.controls div.user-header {
border-bottom: 2px solid @colorPetrol;
.user-name {
display: inline-block;
margin: 0 0 0.3em;
font-size: 2em;
}
.user-state, .user-created, .user-modified {
margin: 0 0 0.2em;
font-size: 0.8em;
}
}
div.content.groups {
table.group-list {
th {