From e5e806a3a12a3fae824ce373dbb3071f8f32df44 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 12 Sep 2014 15:02:31 +0200 Subject: [PATCH] monitoring/commands: Fix instance command forms code compliance refs #6593 --- .../DisableNotificationsExpireCommandForm.php | 1 - .../ToggleInstanceFeaturesCommandForm.php | 28 ++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php b/modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php index 4ebe83c582..67d2c7fc61 100644 --- a/modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php +++ b/modules/monitoring/application/forms/Command/Instance/DisableNotificationsExpireCommandForm.php @@ -71,5 +71,4 @@ public function onSuccess(Request $request) Notification::success(mt('monitoring', 'Disabling host and service notifications..')); return true; } - } diff --git a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php index db584bc1a1..9b3f798016 100644 --- a/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php +++ b/modules/monitoring/application/forms/Command/Instance/ToggleInstanceFeaturesCommandForm.php @@ -59,6 +59,21 @@ public function getStatus() */ public function createElements(array $formData = array()) { + if ((bool) $this->status->notifications_enabled) { + $description = sprintf( + '%s', + mt('monitoring', 'Disable notifications for a specific time on a program-wide basis'), + $this->getView()->href('monitoring/process/disable-notifications'), + mt('monitoring', 'Disable temporarily') + ); + } elseif ($this->status->disable_notif_expire_time) { + $description = sprintf( + mt('monitoring', 'Notifications will be re-enabled in %s'), + $this->getView()->timeUntil($this->status->disable_notif_expire_time) + ); + } else { + $description = ''; + } $this->addElements(array( array( 'checkbox', @@ -97,7 +112,18 @@ public function createElements(array $formData = array()) ToggleInstanceFeatureCommand::FEATURE_NOTIFICATIONS, array( 'label' => mt('monitoring', 'Notifications Enabled'), - 'autosubmit' => true + 'autosubmit' => true, + 'description' => $description, + 'decorators' => array( + 'ViewHelper', + 'Errors', + array( + 'Description', + array('tag' => 'span', 'class' => 'feature-instance-notifications', 'escape' => false) + ), + 'Label', + array('HtmlTag', array('tag' => 'div')) + ), ) ), array(