public function removeAction() { if (!$this->getRequest()->isPost()) { return $this->fail('downtime/remove requires a POST request'); } $hostname = $this->params->get('host'); $comment = $this->params->get('comment'); if (!$hostname) { return $this->fail('Parameter "host" is required'); } if (!$comment) { return $this->fail('Parameter "comment" is required'); } $columns = array('host' => 'host_name', 'service' => 'service_description', 'objecttype' => 'downtime_objecttype', 'internal_id' => 'downtime_internal_id'); $downtimes = $this->backend()->select()->from('downtime', $columns)->where('host_name', $hostname)->where('downtime_comment', $comment)->getQuery()->fetchAll(); foreach ($downtimes as $downtime) { if ($downtime->objecttype === 'service') { $object = $this->getServiceObject($downtime->host, $downtime->service); } else { $object = $this->getHostObject($downtime->host); } $cmd = new DeleteDowntimeCommand(); $cmd->setObject($object)->setDowntimeId($downtime->internal_id); $this->getTransport()->send($cmd); } $this->view->cnt_removed = count($downtimes); $this->view->removed_downtimes = $downtimes; if ($this->isJson) { $this->render('remove-json'); } }
/** * {@inheritdoc} */ public function onSuccess() { $cmd = new DeleteDowntimeCommand(); $cmd->setDowntimeId($this->getElement('downtime_id')->getValue())->setDowntimeName($this->getElement('downtime_name')->getValue())->setIsService($this->getElement('downtime_is_service')->getValue()); $this->getTransport($this->request)->send($cmd); $redirect = $this->getElement('redirect')->getValue(); if (!empty($redirect)) { $this->setRedirectUrl($redirect); } Notification::success($this->translate('Deleting downtime.')); return true; }
/** * {@inheritdoc} */ public function onSuccess() { foreach ($this->downtimes as $downtime) { $delDowntime = new DeleteDowntimeCommand(); $delDowntime->setDowntimeId($downtime->id)->setIsService(isset($downtime->service_description)); $this->getTransport($this->request)->send($delDowntime); } $redirect = $this->getElement('redirect')->getValue(); if (!empty($redirect)) { $this->setRedirectUrl($redirect); } Notification::success($this->translatePlural('Deleting downtime..', 'Deleting downtimes..', count($this->downtimes))); return true; }
public function renderDeleteDowntime(DeleteDowntimeCommand $command) { return sprintf('%s;%u', $command->getIsService() ? 'DEL_SVC_DOWNTIME' : 'DEL_HOST_DOWNTIME', $command->getDowntimeId()); }
public function renderDeleteDowntime(DeleteDowntimeCommand $command) { $endpoint = 'actions/remove-downtime'; $data = array('downtime' => $command->getDowntimeName()); return IcingaApiCommand::create($endpoint, $data); }