2013-07-12 15:00:59 +02:00
|
|
|
<?php
|
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
|
|
|
|
2013-08-20 15:32:25 +02:00
|
|
|
namespace Icinga\Module\Monitoring\Form\Command;
|
2013-07-12 15:00:59 +02:00
|
|
|
|
2013-09-05 14:00:38 +02:00
|
|
|
use Icinga\Module\Monitoring\Command\DelayNotificationCommand;
|
|
|
|
|
2013-07-17 14:08:07 +02:00
|
|
|
/**
|
2013-08-12 13:04:30 +02:00
|
|
|
* Form for the delay notification command
|
2013-07-17 14:08:07 +02:00
|
|
|
*/
|
2013-08-06 11:01:43 +02:00
|
|
|
class DelayNotificationForm extends CommandForm
|
2013-07-12 15:00:59 +02:00
|
|
|
{
|
2013-07-18 13:46:12 +02:00
|
|
|
/**
|
2013-08-12 13:04:30 +02:00
|
|
|
* Maximum delay amount in minutes
|
2013-07-18 13:46:12 +02:00
|
|
|
*/
|
2013-08-12 13:04:30 +02:00
|
|
|
const MAX_DELAY = 1440; // 1 day
|
|
|
|
|
2013-07-17 14:08:07 +02:00
|
|
|
/**
|
2013-08-12 13:04:30 +02:00
|
|
|
* Create the form's elements
|
2013-07-17 14:08:07 +02:00
|
|
|
*/
|
|
|
|
protected function create()
|
|
|
|
{
|
2013-08-26 15:06:07 +02:00
|
|
|
$this->addNote(t('This command is used to delay the next problem notification that is sent out.'));
|
|
|
|
|
2013-07-17 14:08:07 +02:00
|
|
|
$this->addElement(
|
|
|
|
'text',
|
|
|
|
'minutes',
|
|
|
|
array(
|
2013-08-22 17:27:11 +02:00
|
|
|
'label' => t('Notification Delay (Minutes From Now)'),
|
2013-08-12 13:04:30 +02:00
|
|
|
'style' => 'width: 80px;',
|
|
|
|
'value' => 0,
|
|
|
|
'required' => true,
|
|
|
|
'validators' => array(
|
2013-07-18 13:46:12 +02:00
|
|
|
array(
|
|
|
|
'between',
|
|
|
|
true,
|
|
|
|
array(
|
|
|
|
'min' => 1,
|
2013-08-12 13:04:30 +02:00
|
|
|
'max' => self::MAX_DELAY
|
2013-07-18 13:46:12 +02:00
|
|
|
)
|
|
|
|
)
|
2013-08-26 15:06:07 +02:00
|
|
|
),
|
|
|
|
'helptext' => t(
|
|
|
|
'The notification delay will be disregarded if the host/service changes state before the next '
|
|
|
|
. 'notification is scheduled to be sent out.'
|
2013-07-18 13:46:12 +02:00
|
|
|
)
|
2013-07-17 14:08:07 +02:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2013-08-12 13:04:30 +02:00
|
|
|
$this->setSubmitLabel(t('Delay Notification'));
|
2013-07-17 14:08:07 +02:00
|
|
|
|
|
|
|
parent::create();
|
|
|
|
}
|
2013-08-01 15:15:38 +02:00
|
|
|
|
2013-08-16 17:38:00 +02:00
|
|
|
/**
|
2013-09-05 14:00:38 +02:00
|
|
|
* Create the command object to delay notifications
|
2013-08-16 17:38:00 +02:00
|
|
|
*
|
2013-09-05 14:00:38 +02:00
|
|
|
* @return DelayNotificationCommand
|
2013-08-16 17:38:00 +02:00
|
|
|
*/
|
2013-09-05 14:00:38 +02:00
|
|
|
public function createCommand()
|
2013-08-01 15:15:38 +02:00
|
|
|
{
|
2013-09-05 14:00:38 +02:00
|
|
|
return new DelayNotificationCommand($this->getValue('minutes') * 60);
|
2013-08-01 15:15:38 +02:00
|
|
|
}
|
2013-07-12 15:00:59 +02:00
|
|
|
}
|