/**
  * (non-PHPDoc)
  * @see \Icinga\Web\Form::onSuccess() For the method documentation.
  */
 public function onSuccess()
 {
     foreach ($this->objects as $object) {
         /** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
         $ack = new AcknowledgeProblemCommand();
         $ack->setObject($object)->setComment($this->getElement('comment')->getValue())->setAuthor($this->request->getUser()->getUsername())->setPersistent($this->getElement('persistent')->isChecked())->setSticky($this->getElement('sticky')->isChecked())->setNotify($this->getElement('notify')->isChecked());
         if ($this->getElement('expire')->isChecked()) {
             $ack->setExpireTime($this->getElement('expire_time')->getValue()->getTimestamp());
         }
         $this->getTransport($this->request)->send($ack);
     }
     Notification::success($this->translatePlural('Acknowledging problem..', 'Acknowledging problems..', count($this->objects)));
     return true;
 }
 public function renderAcknowledgeProblem(AcknowledgeProblemCommand $command)
 {
     $object = $command->getObject();
     if ($command->getObject()->getType() === $command::TYPE_HOST) {
         /** @var \Icinga\Module\Monitoring\Object\Host $object */
         $commandString = sprintf('%s;%s', $command->getExpireTime() !== null ? 'ACKNOWLEDGE_HOST_PROBLEM_EXPIRE' : 'ACKNOWLEDGE_HOST_PROBLEM', $object->getName());
     } else {
         /** @var \Icinga\Module\Monitoring\Object\Service $object */
         $commandString = sprintf('%s;%s;%s', $command->getExpireTime() !== null ? 'ACKNOWLEDGE_SVC_PROBLEM_EXPIRE' : 'ACKNOWLEDGE_SVC_PROBLEM', $object->getHost()->getName(), $object->getName());
     }
     $commandString = sprintf('%s;%u;%u;%u', $commandString, $command->getSticky() ? 2 : 0, $command->getNotify(), $command->getPersistent());
     if ($command->getExpireTime() !== null) {
         $commandString = sprintf('%s;%u', $commandString, $command->getExpireTime());
     }
     return sprintf('%s;%s;%s', $commandString, $command->getAuthor(), $command->getComment());
 }
 public function renderAcknowledgeProblem(AcknowledgeProblemCommand $command)
 {
     $endpoint = 'actions/acknowledge-problem';
     $data = array('author' => $command->getAuthor(), 'comment' => $command->getComment(), 'expiry' => $command->getExpireTime(), 'sticky' => $command->getSticky(), 'notify' => $command->getNotify());
     $this->applyFilter($data, $command->getObject());
     return IcingaApiCommand::create($endpoint, $data);
 }