Skip to content

Commit

Permalink
monitoring: Fix that searching for specific columns is no longer poss…
Browse files Browse the repository at this point in the history
…ible if default search columns are set
  • Loading branch information
lippserd committed May 28, 2015
1 parent 124173f commit 31400ea
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions library/Icinga/Web/Widget/FilterEditor.php
Expand Up @@ -216,25 +216,22 @@ public function handleRequest($request)
$filter = $this->getFilter();

if ($search !== null) {
if (empty($this->searchColumns)) {
if (strpos($search, '=') === false) {
Notification::error(mt('monitoring', 'Cannot search here'));
return $this;
} else {
list($k, $v) = preg_split('/=/', $search);
$filter = $this->mergeRootExpression($filter, trim($k), '=', ltrim($v));
}
} else {
if (false === $this->resetSearchColumns($filter)) {
if (strpos($search, '=') !== false) {
list($k, $v) = preg_split('/=/', $search);
$filter = $this->mergeRootExpression($filter, trim($k), '=', ltrim($v));
} elseif (! empty($this->searchColumns)) {
if (! $this->resetSearchColumns($filter)) {
$filter = Filter::matchAll();
}

$filters = array();
$search = ltrim($search);
foreach ($this->searchColumns as $searchColumn) {
$filters[] = Filter::expression($searchColumn, '=', "*$search*");
}
$filter->andFilter(new FilterOr($filters));
} else {
Notification::error(mt('monitoring', 'Cannot search here'));
return $this;
}

$url = $this->url()->setQueryString(
Expand Down

0 comments on commit 31400ea

Please sign in to comment.