diff --git a/modules/monitoring/application/controllers/ActionsController.php b/modules/monitoring/application/controllers/ActionsController.php index d125e03de..fa2569e95 100644 --- a/modules/monitoring/application/controllers/ActionsController.php +++ b/modules/monitoring/application/controllers/ActionsController.php @@ -1,8 +1,11 @@ backend->list('host')->handleRequest()->fetchAll() + $hostList = new HostList($this->backend); + $this->applyRestriction('monitoring/filter/objects', $hostList); + $hostList->addFilter(Filter::fromQueryString((string) $this->params)); + if (! $hostList->count()) { + // @TODO(el): Use ApiResponse class for unified response handling. + $this->getRequest()->sendJson(array( + 'status' => 'fail', + 'message' => 'No hosts found matching the given filter' + )); + } + $form = new ScheduleHostDowntimeCommandForm(); + $form + ->setIsApiTarget(true) + ->setObjects($hostList->fetch()) + ->handleRequest($this->getRequest()); + } + /** * Remove host downtimes */ public function removeHostDowntimeAction() { - // @TODO(el): Require a filter? + // @TODO(el): Require a filter $downtimes = $this->backend ->select() ->from('downtime', array('host_name', 'id' => 'downtime_internal_id')) @@ -30,7 +57,7 @@ class Monitoring_ActionsController extends Controller if (empty($downtimes)) { // @TODO(el): Use ApiResponse class for unified response handling. $this->getRequest()->sendJson(array( - 'status' => 'error', + 'status' => 'fail', 'message' => 'No downtimes found matching the given filter' )); }