diff --git a/application/controllers/CommentController.php b/application/controllers/CommentController.php index 390481fc..1019ad73 100644 --- a/application/controllers/CommentController.php +++ b/application/controllers/CommentController.php @@ -11,6 +11,7 @@ use Icinga\Module\Icingadb\Model\Comment; use Icinga\Module\Icingadb\Web\Controller; use Icinga\Module\Icingadb\Widget\Detail\CommentDetail; use Icinga\Module\Icingadb\Widget\ItemList\CommentList; +use ipl\Stdlib\Filter; use ipl\Web\Url; class CommentController extends Controller @@ -34,9 +35,7 @@ class CommentController extends Controller 'service.host', 'service.host.state' ]); - - $query->getSelectBase() - ->where(['comment.name = ?' => $name]); + $query->filter(Filter::equal('comment.name', $name)); $this->applyRestrictions($query); diff --git a/application/controllers/DowntimeController.php b/application/controllers/DowntimeController.php index 7e0a8050..a0a7fa07 100644 --- a/application/controllers/DowntimeController.php +++ b/application/controllers/DowntimeController.php @@ -11,6 +11,7 @@ use Icinga\Module\Icingadb\Model\Downtime; use Icinga\Module\Icingadb\Web\Controller; use Icinga\Module\Icingadb\Widget\Detail\DowntimeDetail; use Icinga\Module\Icingadb\Widget\ItemList\DowntimeList; +use ipl\Stdlib\Filter; use ipl\Web\Url; class DowntimeController extends Controller @@ -44,8 +45,7 @@ class DowntimeController extends Controller 'triggered_by.service', 'triggered_by.service.state' ]); - $query->getSelectBase() - ->where(['downtime.name = ?' => $name]); + $query->filter(Filter::equal('downtime.name', $name)); $this->applyRestrictions($query); diff --git a/application/controllers/HostController.php b/application/controllers/HostController.php index 5e3d8e44..7f6e4bac 100644 --- a/application/controllers/HostController.php +++ b/application/controllers/HostController.php @@ -41,9 +41,9 @@ class HostController extends Controller $name = $this->params->getRequired('name'); $query = Host::on($this->getDb())->with(['state', 'icon_image']); - $query->setResultSetClass(VolatileStateResults::class); - $query->getSelectBase() - ->where(['host.name = ?' => $name]); + $query + ->setResultSetClass(VolatileStateResults::class) + ->filter(Filter::equal('host.name', $name)); $this->applyRestrictions($query); @@ -63,8 +63,7 @@ class HostController extends Controller public function indexAction() { $serviceSummary = ServicestateSummary::on($this->getDb())->with('state'); - $serviceSummary->getSelectBase() - ->where(['service.host_id = ?' => $this->host->id]); + $serviceSummary->filter(Filter::equal('service.host_id', $this->host->id)); $this->applyRestrictions($serviceSummary); @@ -193,11 +192,9 @@ class HostController extends Controller 'host', 'host.state' ]); - $services->setResultSetClass(VolatileStateResults::class); - $services - ->getSelectBase() - ->where(['service_host.id = ?' => $this->host->id]); + ->setResultSetClass(VolatileStateResults::class) + ->filter(Filter::equal('host.id', $this->host->id)); $this->applyRestrictions($services); diff --git a/application/controllers/HostgroupController.php b/application/controllers/HostgroupController.php index ad250339..b5085f7f 100644 --- a/application/controllers/HostgroupController.php +++ b/application/controllers/HostgroupController.php @@ -50,9 +50,9 @@ class HostgroupController extends Controller $db = $this->getDb(); $hosts = Host::on($db)->with(['state', 'state.last_comment', 'icon_image'])->utilize('hostgroup'); - $hosts->setResultSetClass(VolatileStateResults::class); - - $hosts->getSelectBase()->where(['host_hostgroup.id = ?' => $this->hostgroup->id]); + $hosts + ->setResultSetClass(VolatileStateResults::class) + ->filter(Filter::equal('hostgroup.id', $this->hostgroup->id)); $this->applyRestrictions($hosts); $limitControl = $this->createLimitControl(); diff --git a/application/controllers/ServiceController.php b/application/controllers/ServiceController.php index efe0cab2..2933d933 100644 --- a/application/controllers/ServiceController.php +++ b/application/controllers/ServiceController.php @@ -43,11 +43,12 @@ class ServiceController extends Controller 'host', 'host.state' ]); - $query->setResultSetClass(VolatileStateResults::class); - - $query->getSelectBase() - ->where(['service.name = ?' => $name]) - ->where(['service_host.name = ?' => $hostName]); + $query + ->setResultSetClass(VolatileStateResults::class) + ->filter(Filter::all( + Filter::equal('service.name', $name), + Filter::equal('host.name', $hostName) + )); $this->applyRestrictions($query); @@ -127,13 +128,10 @@ class ServiceController extends Controller 'acknowledgement', 'state' ]); - - $history - ->getSelectBase() - ->where([ - 'history.host_id = ?' => $this->service->host_id, - 'history.service_id = ?' => $this->service->id - ]); + $history->filter(Filter::all( + Filter::equal('history.host_id', $this->service->host_id), + Filter::equal('history.service_id', $this->service->id) + )); $before = $this->params->shift('before', time()); $url = Url::fromRequest()->setParams(clone $this->params); diff --git a/application/controllers/ServicegroupController.php b/application/controllers/ServicegroupController.php index 4e055c44..4b65aaa7 100644 --- a/application/controllers/ServicegroupController.php +++ b/application/controllers/ServicegroupController.php @@ -55,9 +55,10 @@ class ServicegroupController extends Controller 'host', 'host.state' ])->utilize('servicegroup'); - $services->setResultSetClass(VolatileStateResults::class); + $services + ->setResultSetClass(VolatileStateResults::class) + ->filter(Filter::equal('servicegroup.id', $this->servicegroup->id)); - $services->getSelectBase()->where(['service_servicegroup.id = ?' => $this->servicegroup->id]); $this->applyRestrictions($services); $limitControl = $this->createLimitControl(); diff --git a/application/controllers/UserController.php b/application/controllers/UserController.php index bbe30373..751bb385 100644 --- a/application/controllers/UserController.php +++ b/application/controllers/UserController.php @@ -9,6 +9,7 @@ use Icinga\Module\Icingadb\Model\User; use Icinga\Module\Icingadb\Web\Controller; use Icinga\Module\Icingadb\Widget\Detail\UserDetail; use Icinga\Module\Icingadb\Widget\ItemList\UserList; +use ipl\Stdlib\Filter; class UserController extends Controller { @@ -24,8 +25,7 @@ class UserController extends Controller $name = $this->params->getRequired('name'); $query = User::on($this->getDb()); - $query->getSelectBase() - ->where(['user.name = ?' => $name]); + $query->filter(Filter::equal('user.name', $name)); $this->applyRestrictions($query); diff --git a/application/controllers/UsergroupController.php b/application/controllers/UsergroupController.php index 209e5947..e1d4ae20 100644 --- a/application/controllers/UsergroupController.php +++ b/application/controllers/UsergroupController.php @@ -9,6 +9,7 @@ use Icinga\Module\Icingadb\Model\Usergroup; use Icinga\Module\Icingadb\Web\Controller; use Icinga\Module\Icingadb\Widget\Detail\UsergroupDetail; use Icinga\Module\Icingadb\Widget\ItemList\UsergroupList; +use ipl\Stdlib\Filter; class UsergroupController extends Controller { @@ -24,8 +25,7 @@ class UsergroupController extends Controller $name = $this->params->getRequired('name'); $query = Usergroup::on($this->getDb()); - $query->getSelectBase() - ->where(['usergroup.name = ?' => $name]); + $query->filter(Filter::equal('usergroup.name', $name)); $this->applyRestrictions($query);