diff options
Diffstat (limited to '')
-rw-r--r-- | library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php | 8 | ||||
-rw-r--r-- | library/Icingadb/Web/Controller.php | 21 |
2 files changed, 21 insertions, 8 deletions
diff --git a/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php b/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php index b89e729..31b6483 100644 --- a/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php +++ b/library/Icingadb/Web/Control/SearchBar/ObjectSuggestions.php @@ -121,8 +121,12 @@ class ObjectSuggestions extends Suggestions $quickFilter = Filter::any(); foreach ($model->getSearchColumns() as $column) { - $where = Filter::like($resolver->qualifyColumn($column, $model->getTableName()), $searchTerm); - $where->metaData()->set('columnLabel', $resolver->getColumnDefinition($where->getColumn())->getLabel()); + if (strpos($column, '.') === false) { + $column = $resolver->qualifyColumn($column, $model->getTableName()); + } + + $where = Filter::like($column, $searchTerm); + $where->metaData()->set('columnLabel', $resolver->getColumnDefinition($column)->getLabel()); $quickFilter->add($where); } diff --git a/library/Icingadb/Web/Controller.php b/library/Icingadb/Web/Controller.php index ad9f07e..ffa711a 100644 --- a/library/Icingadb/Web/Controller.php +++ b/library/Icingadb/Web/Controller.php @@ -307,10 +307,11 @@ class Controller extends CompatController { $columns = array_merge($query->getModel()->getSearchColumns(), $additionalColumns); foreach ($columns as $column) { - $filter->add(Filter::like( - $query->getResolver()->qualifyColumn($column, $query->getModel()->getTableName()), - "*$search*" - )); + if (strpos($column, '.') === false) { + $column = $query->getResolver()->qualifyColumn($column, $query->getModel()->getTableName()); + } + + $filter->add(Filter::like($column, "*$search*")); } } @@ -367,7 +368,10 @@ class Controller extends CompatController // No matter the format, a limit should only apply if set if ($this->format !== null) { - $query->limit(Url::fromRequest()->getParam('limit')); + if (! Url::fromRequest()->hasParam('limit')) { + $query->limit(null) + ->offset(null); + } } if ($this->format === 'json' || $this->format === 'csv') { @@ -512,7 +516,12 @@ class Controller extends CompatController { parent::preDispatch(); - $this->format = $this->params->shift('format'); + $this->format = $this->params->shift( + 'format', + $this->getRequest()->isApiRequest() + ? 'json' + : null + ); } public function postDispatch() |