From 2cec4a6d67de02aebb01c6c992fc3479d631bc29 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 20 May 2015 15:41:02 +0200 Subject: [PATCH] UserController: Add showAction refs #8826 --- application/controllers/UserController.php | 23 ++++++++++++++ application/views/scripts/user/list.phtml | 7 ++++- application/views/scripts/user/show.phtml | 35 ++++++++++++++++++++++ public/css/icinga/main-content.less | 15 ++++++++++ 4 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 application/views/scripts/user/show.phtml diff --git a/application/controllers/UserController.php b/application/controllers/UserController.php index c9e9dbb0d..217859574 100644 --- a/application/controllers/UserController.php +++ b/application/controllers/UserController.php @@ -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(); diff --git a/application/views/scripts/user/list.phtml b/application/views/scripts/user/list.phtml index b550d4533..093270d4b 100644 --- a/application/views/scripts/user/list.phtml +++ b/application/views/scripts/user/list.phtml @@ -44,7 +44,12 @@ if (count($users) > 0): ?> - escape($user->user_name); ?> + 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) + )); ?> qlink( diff --git a/application/views/scripts/user/show.phtml b/application/views/scripts/user/show.phtml new file mode 100644 index 000000000..00b242512 --- /dev/null +++ b/application/views/scripts/user/show.phtml @@ -0,0 +1,35 @@ +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' + ) + ); +} + +?> +
+ compact): ?> + showOnlyCloseButton(); ?> + +
+

escape($user->user_name); ?>

+

translate('State'); ?>: is_active ? $this->translate('Active') : $this->translate('Inactive'); ?>

+

translate('Created at'); ?>: created_at === null ? '-' : $this->formatDateTime($user->created_at); ?>

+

translate('Last modified'); ?>: last_modified === null ? '-' : $this->formatDateTime($user->last_modified); ?>

+
+
+
+
\ No newline at end of file diff --git a/public/css/icinga/main-content.less b/public/css/icinga/main-content.less index 6c829cacb..82c58674c 100644 --- a/public/css/icinga/main-content.less +++ b/public/css/icinga/main-content.less @@ -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 {