monitoring/commands: Rename DisableNotificationsCommandForm' to DisableNotificationsExpireCommandForm'

The associated command also has 'Expired' in its name.

refs #6593
This commit is contained in:
Eric Lippmann 2014-09-11 17:13:57 +02:00
parent c40ac6f9dc
commit 22771e6f6f

View File

@ -6,7 +6,7 @@ namespace Icinga\Module\Monitoring\Form\Command\Instance;
use DateTime; use DateTime;
use DateInterval; use DateInterval;
use Icinga\Module\Monitoring\Command\Instance\ToggleNotifications; use Icinga\Module\Monitoring\Command\Instance\DisableNotificationsExpireCommand;
use Icinga\Module\Monitoring\Form\Command\CommandForm; use Icinga\Module\Monitoring\Form\Command\CommandForm;
use Icinga\Web\Form\Element\DateTimePicker; use Icinga\Web\Form\Element\DateTimePicker;
use Icinga\Web\Notification; use Icinga\Web\Notification;
@ -15,7 +15,7 @@ use Icinga\Web\Request;
/** /**
* Form for disabling host and service notifications w/ an optional expire date and time on an Icinga instance * Form for disabling host and service notifications w/ an optional expire date and time on an Icinga instance
*/ */
class DisableNotificationsCommandForm extends CommandForm class DisableNotificationsExpireCommandForm extends CommandForm
{ {
/** /**
* (non-PHPDoc) * (non-PHPDoc)
@ -42,43 +42,32 @@ class DisableNotificationsCommandForm extends CommandForm
) )
) )
); );
$expire = new DateTime(); $expireTime = new DateTime();
$expire->add(new DateInterval('PT1H')); $expireTime->add(new DateInterval('PT1H'));
$this->addElement( $this->addElement(
new DateTimePicker( new DateTimePicker(
'expire', 'expire_time',
array( array(
'required' => true, 'required' => true,
'label' => t('Expire Time'), 'label' => mt('monitoring', 'Expire Time'),
'description' => mt('monitoring', 'Set the start date and time for the service downtime.'), 'description' => mt('monitoring', 'Set the expire time.'),
'value' => $expire 'value' => $expireTime
) )
) )
); );
return $this; return $this;
} }
/**
* Get the command which is to be sent to an Icinga instance
*
* @return ToggleNotifications
*/
public function getCommand()
{
return new ToggleNotifications();
}
/** /**
* (non-PHPDoc) * (non-PHPDoc)
* @see \Icinga\Web\Form::onSuccess() For the method documentation. * @see \Icinga\Web\Form::onSuccess() For the method documentation.
*/ */
public function onSuccess(Request $request) public function onSuccess(Request $request)
{ {
$toggleNotifications = $this->getCommand(); $disableNotifications = new DisableNotificationsExpireCommand();
$toggleNotifications $disableNotifications
->disable() ->setExpireTime($this->getElement('expire_time')->getValue());
->setExpire($this->getElement('expire')->getValue()); $this->getTransport($request)->send($disableNotifications);
$this->getTransport($request)->send($toggleNotifications);
Notification::success(mt('monitoring', 'Disabling host and service notifications..')); Notification::success(mt('monitoring', 'Disabling host and service notifications..'));
return true; return true;
} }