monitoring/security: Expect restriction name in ListController::applyRestriction()

Before, the restriction was hard coded to 'monitoring/filter'.
This restriction will be removed because we can not use the very same filter for all views.
This commit is contained in:
Eric Lippmann 2015-01-27 13:33:52 +01:00
parent 45408e45af
commit 08795e7cf4
1 changed files with 12 additions and 7 deletions

View File

@ -2,6 +2,7 @@
use Icinga\Module\Monitoring\Controller;
use Icinga\Module\Monitoring\Backend;
use Icinga\Module\Monitoring\DataView\DataView;
use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;
use Icinga\Module\Monitoring\Forms\Command\Object\DeleteDowntimeCommandForm;
use Icinga\Web\Url;
@ -216,8 +217,8 @@ class Monitoring_ListController extends Controller
'max_check_attempts' => 'service_max_check_attempts'
), $this->extraColumns());
$query = $this->backend->select()->from('serviceStatus', $columns);
$this->filterQuery($query);
$this->setupSortControl(array(
'service_severity' => $this->translate('Service Severity'),
'service_state' => $this->translate('Current Service State'),
@ -661,20 +662,24 @@ class Monitoring_ListController extends Controller
if ($sort = $this->params->get('sort')) {
$query->order($sort, $this->params->get('dir'));
}
$this->applyRestrictions($query);
$this->handleFormatRequest($query);
return $query;
}
/**
* Apply current user's `monitoring/filter' restrictions on the given data view
* Apply a restriction on the given data view
*
* @param string $restriction The name of restriction
* @param DataView $view The view to restrict
*
* @return DataView $view
*/
protected function applyRestrictions($query)
protected function applyRestriction($restriction, DataView $view)
{
foreach ($this->getRestrictions('monitoring/filter') as $restriction) {
// TODO: $query->applyFilter(Filter::fromQueryString());
foreach ($this->getRestrictions($restriction) as $filter) {
$view->applyFilter(Filter::fromQueryString($filter));
}
return $query;
return $view;
}
protected function extraColumns()