mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-30 09:14:08 +02:00
DataView: Apply object restrictions to dynamic filter columns
fixes #9993
This commit is contained in:
parent
1e09f68ad2
commit
9ec471d349
@ -5,6 +5,7 @@ namespace Icinga\Module\Monitoring\DataView;
|
|||||||
|
|
||||||
use IteratorAggregate;
|
use IteratorAggregate;
|
||||||
use Icinga\Application\Hook;
|
use Icinga\Application\Hook;
|
||||||
|
use Icinga\Authentication\Auth;
|
||||||
use Icinga\Data\ConnectionInterface;
|
use Icinga\Data\ConnectionInterface;
|
||||||
use Icinga\Data\Filter\Filter;
|
use Icinga\Data\Filter\Filter;
|
||||||
use Icinga\Data\Filter\FilterMatch;
|
use Icinga\Data\Filter\FilterMatch;
|
||||||
@ -264,12 +265,24 @@ abstract class DataView implements QueryInterface, SortRules, FilterColumns, Ite
|
|||||||
return $columns;
|
return $columns;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$restriction = Filter::matchAny();
|
||||||
|
$restrictions = Auth::getInstance()->getRestrictions('monitoring/filter/objects');
|
||||||
|
foreach ($restrictions as $filter) {
|
||||||
|
if ($filter === '*') {
|
||||||
|
$restriction = Filter::matchAny();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$restriction->addFilter(Filter::fromQueryString($filter));
|
||||||
|
}
|
||||||
|
|
||||||
$query = MonitoringBackend::instance()
|
$query = MonitoringBackend::instance()
|
||||||
->select()
|
->select()
|
||||||
->from('customvar', array('varname', 'object_type'))
|
->from('customvar', array('varname', 'object_type'))
|
||||||
->where('is_json', 0)
|
->where('is_json', 0)
|
||||||
->where('object_type_id', array(1, 2))
|
->where('object_type_id', array(1, 2))
|
||||||
|
->applyFilter($restriction)
|
||||||
->getQuery()->group(array('varname', 'object_type'));
|
->getQuery()->group(array('varname', 'object_type'));
|
||||||
|
|
||||||
foreach ($query as $row) {
|
foreach ($query as $row) {
|
||||||
if ($row->object_type === 'host') {
|
if ($row->object_type === 'host') {
|
||||||
$label = t('Host') . ' ' . ucwords(str_replace('_', ' ', $row->varname));
|
$label = t('Host') . ' ' . ucwords(str_replace('_', ' ', $row->varname));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user