Merge pull request #2777 from Icinga/bugfix/defaults-when-acknowledging-problems-2776

AcknowledgeProblemCommandForm: respect configuration when creating elements
This commit is contained in:
Eric Lippmann 2017-03-28 09:22:08 +02:00
commit c11601d458
1 changed files with 5 additions and 2 deletions

View File

@ -43,6 +43,8 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm
{ {
$config = Config::module('monitoring'); $config = Config::module('monitoring');
$acknowledgeExpire = (bool) $config->get('settings', 'acknowledge_expire', false);
$this->addElements(array( $this->addElements(array(
array( array(
'textarea', 'textarea',
@ -74,7 +76,7 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm
'expire', 'expire',
array( array(
'label' => $this->translate('Use Expire Time'), 'label' => $this->translate('Use Expire Time'),
'value' => (bool) $config->get('settings', 'acknowledge_expire', false), 'value' => $acknowledgeExpire,
'description' => $this->translate( 'description' => $this->translate(
'If the acknowledgement should expire, check this option.' 'If the acknowledgement should expire, check this option.'
), ),
@ -82,7 +84,8 @@ class AcknowledgeProblemCommandForm extends ObjectsCommandForm
) )
) )
)); ));
if (isset($formData['expire']) && (bool) $formData['expire'] === true) { $expire = isset($formData['expire']) ? $formData['expire'] : $acknowledgeExpire;
if ($expire) {
$expireTime = new DateTime(); $expireTime = new DateTime();
$expireTime->add(new DateInterval('PT1H')); $expireTime->add(new DateInterval('PT1H'));
$this->addElement( $this->addElement(