mirror of
https://github.com/Icinga/icingadb-web.git
synced 2026-05-28 04:36:06 -04:00
Fix too extensive host notification recipients
Previously, host notification recipients also included notification recipients from their services.
This commit is contained in:
parent
cf4b68d0f0
commit
b4b6726ccf
1 changed files with 22 additions and 4 deletions
|
|
@ -477,16 +477,30 @@ class ObjectDetail extends BaseHtmlElement
|
|||
{
|
||||
$users = [];
|
||||
$usergroups = [];
|
||||
$groupBy = false;
|
||||
|
||||
$objectFilter = Filter::equal(
|
||||
'notification.' . ($this->objectType === 'host' ? 'host_id' : 'service_id'),
|
||||
$this->object->id
|
||||
);
|
||||
if ($this->objectType === 'host') {
|
||||
$objectFilter = Filter::all(
|
||||
Filter::equal('notification.host_id', $this->object->id),
|
||||
Filter::unequal('notification.service_id', '*')
|
||||
);
|
||||
$objectFilter->metaData()->set('forceOptimization', false);
|
||||
$groupBy = true;
|
||||
} else {
|
||||
$objectFilter = Filter::equal(
|
||||
'notification.service_id',
|
||||
$this->object->id
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->isPermittedRoute('users')) {
|
||||
$userQuery = User::on($this->getDb());
|
||||
$userQuery->filter($objectFilter);
|
||||
$this->applyRestrictions($userQuery);
|
||||
if ($groupBy) {
|
||||
$userQuery->getSelectBase()->groupBy(['user.id']);
|
||||
}
|
||||
|
||||
foreach ($userQuery as $user) {
|
||||
$users[$user->name] = $user;
|
||||
}
|
||||
|
|
@ -496,6 +510,10 @@ class ObjectDetail extends BaseHtmlElement
|
|||
$usergroupQuery = Usergroup::on($this->getDb());
|
||||
$usergroupQuery->filter($objectFilter);
|
||||
$this->applyRestrictions($usergroupQuery);
|
||||
if ($groupBy) {
|
||||
$userQuery->getSelectBase()->groupBy(['usergroup.id']);
|
||||
}
|
||||
|
||||
foreach ($usergroupQuery as $usergroup) {
|
||||
$usergroups[$usergroup->name] = $usergroup;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue