mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-31 01:34:09 +02:00
Fix code compliance in the SendCustomNotificationCommandForm
This commit is contained in:
parent
9d4460d02f
commit
a8ce3abca7
@ -17,29 +17,20 @@ class SendCustomNotificationCommandForm extends ObjectsCommandForm
|
|||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
$this->addDescription(
|
$this->addDescription(
|
||||||
$this->translate(
|
$this->translate('This command is used to send custom notifications about hosts or services.')
|
||||||
'This command is used to send custom notifications for hosts or'
|
|
||||||
. ' services.'
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (non-PHPDoc)
|
* {@inheritdoc}
|
||||||
* @see \Icinga\Web\Form::getSubmitLabel() For the method documentation.
|
|
||||||
*/
|
*/
|
||||||
public function getSubmitLabel()
|
public function getSubmitLabel()
|
||||||
{
|
{
|
||||||
return $this->translatePlural(
|
return $this->translatePlural('Send custom notification', 'Send custom notifications', count($this->objects));
|
||||||
'Send custom notification',
|
|
||||||
'Send custom notifications',
|
|
||||||
count($this->objects)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (non-PHPDoc)
|
* {@inheritdoc}
|
||||||
* @see \Icinga\Web\Form::createElements() For the method documentation.
|
|
||||||
*/
|
*/
|
||||||
public function createElements(array $formData = array())
|
public function createElements(array $formData = array())
|
||||||
{
|
{
|
||||||
@ -64,9 +55,8 @@ class SendCustomNotificationCommandForm extends ObjectsCommandForm
|
|||||||
'label' => $this->translate('Forced'),
|
'label' => $this->translate('Forced'),
|
||||||
'value' => false,
|
'value' => false,
|
||||||
'description' => $this->translate(
|
'description' => $this->translate(
|
||||||
'If you check this option, a notification is sent'
|
'If you check this option, the notification is sent out regardless of time restrictions and'
|
||||||
. 'regardless of the current time and whether'
|
. ' whether or not notifications are enabled.'
|
||||||
. ' notifications are enabled.'
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
@ -77,8 +67,7 @@ class SendCustomNotificationCommandForm extends ObjectsCommandForm
|
|||||||
'label' => $this->translate('Broadcast'),
|
'label' => $this->translate('Broadcast'),
|
||||||
'value' => false,
|
'value' => false,
|
||||||
'description' => $this->translate(
|
'description' => $this->translate(
|
||||||
'If you check this option, a notification is sent to'
|
'If you check this option, the notification is sent out to all normal and escalated contacts.'
|
||||||
. ' all normal and escalated contacts.'
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -87,24 +76,24 @@ class SendCustomNotificationCommandForm extends ObjectsCommandForm
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (non-PHPDoc)
|
* {@inheritdoc}
|
||||||
* @see \Icinga\Web\Form::onSuccess() For the method documentation.
|
|
||||||
*/
|
*/
|
||||||
public function onSuccess()
|
public function onSuccess()
|
||||||
{
|
{
|
||||||
foreach ($this->objects as $object) {
|
foreach ($this->objects as $object) {
|
||||||
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
|
/** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
|
||||||
$comment = new SendCustomNotificationCommand();
|
$notification = new SendCustomNotificationCommand();
|
||||||
$comment->setObject($object);
|
$notification
|
||||||
$comment->setComment($this->getElement('comment')->getValue());
|
->setObject($object)
|
||||||
$comment->setAuthor($this->request->getUser()->getUsername());
|
->setComment($this->getElement('comment')->getValue())
|
||||||
$comment->setForced($this->getElement('forced')->isChecked());
|
->setAuthor($this->request->getUser()->getUsername())
|
||||||
$comment->setBroadcast($this->getElement('broadcast')->isChecked());
|
->setForced($this->getElement('forced')->isChecked())
|
||||||
$this->getTransport($this->request)->send($comment);
|
->setBroadcast($this->getElement('broadcast')->isChecked());
|
||||||
|
$this->getTransport($this->request)->send($notification);
|
||||||
}
|
}
|
||||||
Notification::success($this->translatePlural(
|
Notification::success($this->translatePlural(
|
||||||
'Send custom notification..',
|
'Sending custom notification..',
|
||||||
'Send custom notifications..',
|
'Sending custom notifications..',
|
||||||
count($this->objects)
|
count($this->objects)
|
||||||
));
|
));
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user