diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 11:46:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 11:46:43 +0000 |
commit | 3e02d5aff85babc3ffbfcf52313f2108e313aa23 (patch) | |
tree | b01f3923360c20a6a504aff42d45670c58af3ec5 /modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php | |
parent | Initial commit. (diff) | |
download | icingaweb2-3e02d5aff85babc3ffbfcf52313f2108e313aa23.tar.xz icingaweb2-3e02d5aff85babc3ffbfcf52313f2108e313aa23.zip |
Adding upstream version 2.12.1.upstream/2.12.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php')
-rw-r--r-- | modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php b/modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php new file mode 100644 index 0000000..ee49962 --- /dev/null +++ b/modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php @@ -0,0 +1,64 @@ +<?php +/* Icinga Web 2 | (c) 2014 Icinga Development Team | GPLv2+ */ + +namespace Icinga\Module\Monitoring\Forms\Command\Instance; + +use DateTime; +use DateInterval; +use Icinga\Module\Monitoring\Command\Instance\DisableNotificationsExpireCommand; +use Icinga\Module\Monitoring\Forms\Command\CommandForm; +use Icinga\Web\Notification; + +/** + * Form for disabling host and service notifications w/ an optional expire date and time on an Icinga instance + */ +class DisableNotificationsExpireCommandForm extends CommandForm +{ + /** + * (non-PHPDoc) + * @see \Zend_Form::init() For the method documentation. + */ + public function init() + { + $this->setRequiredCue(null); + $this->setSubmitLabel($this->translate('Disable Notifications')); + $this->addDescription($this->translate( + 'This command is used to disable host and service notifications for a specific time.' + )); + } + + /** + * (non-PHPDoc) + * @see \Icinga\Web\Form::createElements() For the method documentation. + */ + public function createElements(array $formData = array()) + { + $expireTime = new DateTime(); + $expireTime->add(new DateInterval('PT1H')); + $this->addElement( + 'dateTimePicker', + 'expire_time', + array( + 'required' => true, + 'label' => $this->translate('Expire Time'), + 'description' => $this->translate('Set the expire time.'), + 'value' => $expireTime + ) + ); + return $this; + } + + /** + * (non-PHPDoc) + * @see \Icinga\Web\Form::onSuccess() For the method documentation. + */ + public function onSuccess() + { + $disableNotifications = new DisableNotificationsExpireCommand(); + $disableNotifications + ->setExpireTime($this->getElement('expire_time')->getValue()->getTimestamp()); + $this->getTransport($this->request)->send($disableNotifications); + Notification::success($this->translate('Disabling host and service notifications..')); + return true; + } +} |