mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-31 01:34:09 +02:00
role/audit: Group suggestions by backend name
This commit is contained in:
parent
b48f7f3489
commit
54acd6b4c8
@ -18,6 +18,7 @@ use Icinga\Web\Controller\AuthBackendController;
|
|||||||
use Icinga\Web\View\PrivilegeAudit;
|
use Icinga\Web\View\PrivilegeAudit;
|
||||||
use Icinga\Web\Widget\SingleValueSearchControl;
|
use Icinga\Web\Widget\SingleValueSearchControl;
|
||||||
use ipl\Html\Html;
|
use ipl\Html\Html;
|
||||||
|
use ipl\Html\HtmlString;
|
||||||
use ipl\Web\Url;
|
use ipl\Web\Url;
|
||||||
use ipl\Web\Widget\Link;
|
use ipl\Web\Widget\Link;
|
||||||
|
|
||||||
@ -258,7 +259,7 @@ class RoleController extends AuthBackendController
|
|||||||
$searchTerm = $requestData['term']['label'];
|
$searchTerm = $requestData['term']['label'];
|
||||||
$userBackends = $this->loadUserBackends(Selectable::class);
|
$userBackends = $this->loadUserBackends(Selectable::class);
|
||||||
|
|
||||||
$users = [];
|
$suggestions = [];
|
||||||
while ($limit > 0 && ! empty($userBackends)) {
|
while ($limit > 0 && ! empty($userBackends)) {
|
||||||
/** @var Repository $backend */
|
/** @var Repository $backend */
|
||||||
$backend = array_shift($userBackends);
|
$backend = array_shift($userBackends);
|
||||||
@ -273,10 +274,22 @@ class RoleController extends AuthBackendController
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$users = [];
|
||||||
foreach ($names as $name) {
|
foreach ($names as $name) {
|
||||||
$users[$name] = [
|
$users[] = [$name, [
|
||||||
'type' => 'user',
|
'type' => 'user',
|
||||||
'backend' => $backend->getName()
|
'backend' => $backend->getName()
|
||||||
|
]];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($users)) {
|
||||||
|
$suggestions[] = [
|
||||||
|
[
|
||||||
|
t('Users'),
|
||||||
|
HtmlString::create(' '),
|
||||||
|
Html::tag('span', ['class' => 'badge'], $backend->getName())
|
||||||
|
],
|
||||||
|
$users
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,7 +298,6 @@ class RoleController extends AuthBackendController
|
|||||||
|
|
||||||
$groupBackends = $this->loadUserGroupBackends(Selectable::class);
|
$groupBackends = $this->loadUserGroupBackends(Selectable::class);
|
||||||
|
|
||||||
$groups = [];
|
|
||||||
while ($limit > 0 && ! empty($groupBackends)) {
|
while ($limit > 0 && ! empty($groupBackends)) {
|
||||||
/** @var Repository $backend */
|
/** @var Repository $backend */
|
||||||
$backend = array_shift($groupBackends);
|
$backend = array_shift($groupBackends);
|
||||||
@ -300,22 +312,25 @@ class RoleController extends AuthBackendController
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$groups = [];
|
||||||
foreach ($names as $name) {
|
foreach ($names as $name) {
|
||||||
$groups[$name] = ['type' => 'group'];
|
$groups[] = [$name, ['type' => 'group']];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($groups)) {
|
||||||
|
$suggestions[] = [
|
||||||
|
[
|
||||||
|
t('Groups'),
|
||||||
|
HtmlString::create(' '),
|
||||||
|
Html::tag('span', ['class' => 'badge'], $backend->getName())
|
||||||
|
],
|
||||||
|
$groups
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$limit -= count($names);
|
$limit -= count($names);
|
||||||
}
|
}
|
||||||
|
|
||||||
$suggestions = [];
|
|
||||||
if (! empty($users)) {
|
|
||||||
$suggestions[t('Users')] = $users;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (! empty($groups)) {
|
|
||||||
$suggestions[t('Groups')] = $groups;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->document->add(SingleValueSearchControl::createSuggestions($suggestions));
|
$this->document->add(SingleValueSearchControl::createSuggestions($suggestions));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user