diff --git a/modules/monitoring/application/forms/Command/Instance/DisableNotificationsCommandForm.php b/modules/monitoring/application/forms/Command/Instance/DisableNotificationsCommandForm.php new file mode 100644 index 000000000..8bf918631 --- /dev/null +++ b/modules/monitoring/application/forms/Command/Instance/DisableNotificationsCommandForm.php @@ -0,0 +1,76 @@ +setSubmitLabel(mt('monitoring', 'Disable Notifications')); + } + + /** + * (non-PHPDoc) + * @see \Icinga\Web\Form::createElements() For the method documentation. + */ + public function createElements(array $formData = array()) + { + $expire = new DateTime(); + $expire->add(new DateInterval('PT1H')); + $this->addElement( + new DateTimePicker( + 'expire', + array( + 'required' => true, + 'label' => t('Expire Time'), + 'description' => mt('monitoring', 'Set the start date and time for the service downtime.'), + 'value' => $expire + ) + ) + ); + return $this; + } + + /** + * Get the command which is to be sent to an Icinga instance + * + * @return ToggleNotifications + */ + public function getCommand() + { + return new ToggleNotifications(); + } + + /** + * (non-PHPDoc) + * @see \Icinga\Web\Form::onSuccess() For the method documentation. + */ + public function onSuccess(Request $request) + { + $toggleNotifications = $this->getCommand(); + $toggleNotifications + ->disable() + ->setExpire($this->getElement('expire')->getValue()); + $this->getTransport($request)->send($toggleNotifications); + Notification::success(mt('monitoring', 'Command sent')); + return true; + } + +}