/**
  * {@inheritdoc}
  */
 public function onSuccess()
 {
     foreach ($this->objects as $object) {
         /** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
         $notification = new SendCustomNotificationCommand();
         $notification->setObject($object)->setComment($this->getElement('comment')->getValue())->setAuthor($this->request->getUser()->getUsername())->setForced($this->getElement('forced')->isChecked())->setBroadcast($this->getElement('broadcast')->isChecked());
         $this->getTransport($this->request)->send($notification);
     }
     Notification::success($this->translatePlural('Sending custom notification..', 'Sending custom notifications..', count($this->objects)));
     return true;
 }
 public function renderSendCustomNotification(SendCustomNotificationCommand $command)
 {
     $object = $command->getObject();
     if ($command->getObject()->getType() === $command::TYPE_HOST) {
         /** @var \Icinga\Module\Monitoring\Object\Host $object */
         $commandString = sprintf('SEND_CUSTOM_HOST_NOTIFICATION;%s', $object->getName());
     } else {
         /** @var \Icinga\Module\Monitoring\Object\Service $object */
         $commandString = sprintf('SEND_CUSTOM_SVC_NOTIFICATION;%s;%s', $object->getHost()->getName(), $object->getName());
     }
     $options = 0;
     // 0 for no options
     if ($command->getBroadcast() === true) {
         $options |= 1;
     }
     if ($command->getForced() === true) {
         $options |= 2;
     }
     return sprintf('%s;%u;%s;%s', $commandString, $options, $command->getAuthor(), $command->getComment());
 }
 public function renderSendCustomNotification(SendCustomNotificationCommand $command)
 {
     $endpoint = 'actions/send-custom-notification';
     $data = array('author' => $command->getAuthor(), 'comment' => $command->getComment(), 'force' => $command->getForced());
     $this->applyFilter($data, $command->getObject());
     return IcingaApiCommand::create($endpoint, $data);
 }