GroupController: Add showAction

refs #8826
This commit is contained in:
Johannes Meyer 2015-05-20 16:17:37 +02:00
parent 94cd4b91e5
commit ed166d6eb7
4 changed files with 91 additions and 1 deletions

View File

@ -96,6 +96,28 @@ class GroupController extends Controller
);
}
/**
* Show a group
*/
public function showAction()
{
$groupName = $this->params->getRequired('group');
$backend = $this->getUserGroupBackend($this->params->getRequired('backend'));
$group = $backend->select(array(
'group_name',
'parent_name',
'created_at',
'last_modified'
))->where('group_name', $groupName)->fetchRow();
if ($group === false) {
$this->httpNotFound(sprintf($this->translate('Group "%s" not found'), $groupName));
}
$this->view->group = $group;
$this->view->backend = $backend;
}
/**
* Add a group
*/
@ -125,6 +147,9 @@ class GroupController extends Controller
}
$form = new UserGroupForm();
$form->setRedirectUrl(
Url::fromPath('group/show', array('backend' => $backend->getName(), 'group' => $groupName))
);
$form->setRepository($backend);
$form->edit($groupName, get_object_vars($row))->handleRequest();

View File

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

View File

@ -0,0 +1,45 @@
<?php
use Icinga\Data\Updatable;
$editLink = null;
if ($backend instanceof Updatable) {
$editLink = $this->qlink(
null,
'group/edit',
array(
'backend' => $backend->getName(),
'group' => $group->group_name
),
array(
'title' => sprintf($this->translate('Edit group %s'), $group->group_name),
'class' => 'group-edit',
'icon' => 'edit'
)
);
}
?>
<div class="controls">
<?php if (! $this->compact): ?>
<?= $tabs->showOnlyCloseButton(); ?>
<?php endif ?>
<div class="group-header">
<p class="group-name"><strong><?= $this->escape($group->group_name); ?></strong></p> <?= $editLink; ?>
<p class="group-parent"><strong><?= $this->translate('Parent'); ?>:</strong> <?= $group->parent_name === null ? '-' : $this->qlink(
$group->parent_name,
'group/show',
array(
'backend' => $backend->getName(),
'group' => $group->parent_name
),
array(
'title' => sprintf($this->translate('Show detailed information for group %s'), $group->parent_name)
)
); ?></p>
<p class="group-created"><strong><?= $this->translate('Created at'); ?>:</strong> <?= $group->created_at === null ? '-' : $this->formatDateTime($group->created_at); ?></p>
<p class="group-modified"><strong><?= $this->translate('Last modified'); ?>:</strong> <?= $group->last_modified === null ? '-' : $this->formatDateTime($group->last_modified); ?></p>
</div>
</div>
<div class="content" data-base-target="_next">
</div>

View File

@ -264,6 +264,21 @@ div.content.groups {
}
}
div.controls div.group-header {
border-bottom: 2px solid @colorPetrol;
.group-name {
display: inline-block;
margin: 0 0 0.3em;
font-size: 2em;
}
.group-parent, .group-created, .group-modified {
margin: 0 0 0.2em;
font-size: 0.8em;
}
}
form.backend-selection {
float: right;