From 7253fbcfa44d0d4f2d28d31a12b8a627bb092d02 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 7 Dec 2016 16:53:53 +0100 Subject: [PATCH] Command forms: make the defaults of some checkboxes configurable refs #11952 --- .../Command/Object/AcknowledgeProblemCommandForm.php | 9 +++++++-- .../forms/Command/Object/AddCommentCommandForm.php | 3 ++- .../Command/Object/ScheduleHostCheckCommandForm.php | 4 ++++ .../Command/Object/ScheduleHostDowntimeCommandForm.php | 3 +-- .../Command/Object/SendCustomNotificationCommandForm.php | 7 +++++-- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/modules/monitoring/application/forms/Command/Object/AcknowledgeProblemCommandForm.php b/modules/monitoring/application/forms/Command/Object/AcknowledgeProblemCommandForm.php index 32fb522e2..180719ca7 100644 --- a/modules/monitoring/application/forms/Command/Object/AcknowledgeProblemCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/AcknowledgeProblemCommandForm.php @@ -5,6 +5,7 @@ namespace Icinga\Module\Monitoring\Forms\Command\Object; use DateTime; use DateInterval; +use Icinga\Application\Config; use Icinga\Module\Monitoring\Command\Object\AcknowledgeProblemCommand; use Icinga\Web\Notification; @@ -40,6 +41,8 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm */ public function createElements(array $formData = array()) { + $config = Config::module('monitoring'); + $this->addElements(array( array( 'textarea', @@ -59,6 +62,7 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm 'persistent', array( 'label' => $this->translate('Persistent Comment'), + 'value' => (bool) $config->get('settings', 'acknowledge_persistent', false), 'description' => $this->translate( 'If you would like the comment to remain even when the acknowledgement is removed, check this' . ' option.' @@ -70,6 +74,7 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm 'expire', array( 'label' => $this->translate('Use Expire Time'), + 'value' => (bool) $config->get('settings', 'acknowledge_expire', false), 'description' => $this->translate( 'If the acknowledgement should expire, check this option.' ), @@ -109,7 +114,7 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm 'sticky', array( 'label' => $this->translate('Sticky Acknowledgement'), - 'value' => false, + 'value' => (bool) $config->get('settings', 'acknowledge_sticky', false), 'description' => $this->translate( 'If you want the acknowledgement to remain until the host or service recovers even if the host' . ' or service changes state, check this option.' @@ -121,7 +126,7 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm 'notify', array( 'label' => $this->translate('Send Notification'), - 'value' => true, + 'value' => (bool) $config->get('settings', 'acknowledge_notify', true), 'description' => $this->translate( 'If you do not want an acknowledgement notification to be sent out to the appropriate contacts,' . ' uncheck this option.' diff --git a/modules/monitoring/application/forms/Command/Object/AddCommentCommandForm.php b/modules/monitoring/application/forms/Command/Object/AddCommentCommandForm.php index 4d6124e0c..3cff2cf7c 100644 --- a/modules/monitoring/application/forms/Command/Object/AddCommentCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/AddCommentCommandForm.php @@ -3,6 +3,7 @@ namespace Icinga\Module\Monitoring\Forms\Command\Object; +use Icinga\Application\Config; use Icinga\Module\Monitoring\Command\Object\AddCommentCommand; use Icinga\Web\Notification; @@ -53,7 +54,7 @@ class AddCommentCommandForm extends ObjectsCommandForm 'persistent', array( 'label' => $this->translate('Persistent'), - 'value' => true, + 'value' => (bool) Config::module('monitoring')->get('settings', 'comment_persistent', true), 'description' => $this->translate( 'If you uncheck this option, the comment will automatically be deleted the next time Icinga is' . ' restarted.' diff --git a/modules/monitoring/application/forms/Command/Object/ScheduleHostCheckCommandForm.php b/modules/monitoring/application/forms/Command/Object/ScheduleHostCheckCommandForm.php index b11d2d2d2..6bbd1a7f4 100644 --- a/modules/monitoring/application/forms/Command/Object/ScheduleHostCheckCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ScheduleHostCheckCommandForm.php @@ -3,6 +3,7 @@ namespace Icinga\Module\Monitoring\Forms\Command\Object; +use Icinga\Application\Config; use Icinga\Module\Monitoring\Command\Object\ScheduleHostCheckCommand; use Icinga\Web\Notification; @@ -17,6 +18,8 @@ class ScheduleHostCheckCommandForm extends ScheduleServiceCheckCommandForm */ public function createElements(array $formData = array()) { + $config = Config::module('monitoring'); + parent::createElements($formData); $this->addElements(array( array( @@ -24,6 +27,7 @@ class ScheduleHostCheckCommandForm extends ScheduleServiceCheckCommandForm 'all_services', array( 'label' => $this->translate('All Services'), + 'value' => (bool) $config->get('settings', 'hostcheck_all_services', false), 'description' => $this->translate( 'Schedule check for all services on the hosts and the hosts themselves.' ) diff --git a/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php b/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php index d1f43972a..53c951644 100644 --- a/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/ScheduleHostDowntimeCommandForm.php @@ -29,8 +29,7 @@ class ScheduleHostDowntimeCommandForm extends ScheduleServiceDowntimeCommandForm 'description' => $this->translate( 'Schedule downtime for all services on the hosts and the hosts themselves.' ), - 'label' => $this->translate('All Services'), - 'value' => false + 'label' => $this->translate('All Services') ) ); diff --git a/modules/monitoring/application/forms/Command/Object/SendCustomNotificationCommandForm.php b/modules/monitoring/application/forms/Command/Object/SendCustomNotificationCommandForm.php index 0d04477f1..ba7a049f6 100644 --- a/modules/monitoring/application/forms/Command/Object/SendCustomNotificationCommandForm.php +++ b/modules/monitoring/application/forms/Command/Object/SendCustomNotificationCommandForm.php @@ -3,6 +3,7 @@ namespace Icinga\Module\Monitoring\Forms\Command\Object; +use Icinga\Application\Config; use Icinga\Module\Monitoring\Command\Object\SendCustomNotificationCommand; use Icinga\Web\Notification; @@ -34,6 +35,8 @@ class SendCustomNotificationCommandForm extends ObjectsCommandForm */ public function createElements(array $formData = array()) { + $config = Config::module('monitoring'); + $this->addElements(array( array( 'textarea', @@ -53,7 +56,7 @@ class SendCustomNotificationCommandForm extends ObjectsCommandForm 'forced', array( 'label' => $this->translate('Forced'), - 'value' => false, + 'value' => (bool) $config->get('settings', 'custom_notification_forced', false), 'description' => $this->translate( 'If you check this option, the notification is sent out regardless of time restrictions and' . ' whether or not notifications are enabled.' @@ -68,7 +71,7 @@ class SendCustomNotificationCommandForm extends ObjectsCommandForm 'broadcast', array( 'label' => $this->translate('Broadcast'), - 'value' => false, + 'value' => (bool) $config->get('settings', 'custom_notification_broadcast', false), 'description' => $this->translate( 'If you check this option, the notification is sent out to all normal and escalated contacts.' )