[icinga-checkins] icinga.org: icinga-core/test/ido: classic ui: fix setting send_notification or sticky_ack as GET param has no effect on cmd .cgi acks #2926

git at icinga.org git at icinga.org
Sat Aug 25 16:04:07 CEST 2012


Module: icinga-core
Branch: test/ido
Commit: 0634dd7192ba00e30ae48954193793beaf4dd89b
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=0634dd7192ba00e30ae48954193793beaf4dd89b

Author: Michael Friedrich <michael.friedrich at univie.ac.at>
Date:   Wed Aug  1 19:24:43 2012 +0200

classic ui: fix setting send_notification or sticky_ack as GET param has no effect on cmd.cgi acks #2926

now these GET params require 0 or 1 to be passed via url call,
previously one had to just set that option. this is due to keeping
them enabled as we know before, in order not to need to change the
urls everywhere.

this makes it basically possible, to disable send_notification and
sticky_ack via GET params.

refs #2926

---

 Changelog |    4 ++++
 cgi/cmd.c |   28 ++++++++++++++++++++--------
 2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/Changelog b/Changelog
index aa374df..b2d4b7e 100644
--- a/Changelog
+++ b/Changelog
@@ -46,6 +46,9 @@ FIXES
 * core: get rid of the instame macro usage while logging alerts and states (Andreas Ericsson) #2665 - MF
 * core: revamp the detection of embedded perl usage directive "# icinga: +epn" (Andreas Ericsson) #2197 - MF
 
+* classic ui: fix setting send_notification or sticky_ack as GET param has no effect on cmd.cgi acks #2926 - MF
+	** now you can finally disable checkboxes default ticked with these options
+
 * idoutils: set result handle explicitely to NULL after dbi_result_free() to prevent memory free'ing corruption #2612 - MF/GB
 
 CHANGES
@@ -59,6 +62,7 @@ classic ui: Changed cgi GET params
 	** Added "ts_start", "ts_end" and "order" to history.cgi and notifications.cgi - #2341
 	** Removed "archive" and "oldestfirst" from history.cgi and notifications.cgi - #2341
 	** Added "start_time", "end_time" and "timeperiod" to notifications.cgi - #2341
+	** "send_notification" and "sticky_ack" on cmd.cgi require 0|1 vars, if not set, default is 1 #2926
 
 * classic ui: Added/Changed cgi.cfg options
 	** authorized_for_comments_read_only - #2699
diff --git a/cgi/cmd.c b/cgi/cmd.c
index fab15aa..1a35ea7 100644
--- a/cgi/cmd.c
+++ b/cgi/cmd.c
@@ -139,8 +139,8 @@ int notification_delay = 0;			/**< delay for submitted notification in minutes *
 int schedule_delay = 0;				/**< delay for sheduled actions in minutes (Icinga restart, Notfications enable/disable)
 							!not implemented in GUI! */
 int persistent_comment = FALSE;			/**< bool if omment should survive Icinga restart */
-int sticky_ack = FALSE;				/**< bool to disable notifications until recover */
-int send_notification = FALSE;			/**< bool sends a notification if service gets acknowledged */
+int sticky_ack = TRUE;				/**< bool to disable notifications until recover */
+int send_notification = TRUE;			/**< bool sends a notification if service gets acknowledged */
 int use_ack_end_time = FALSE;			/**< bool if expire acknowledgement is selected or not */
 int force_check = FALSE;				/**< bool if check should be forced */
 int plugin_state = STATE_OK;			/**< plugin state for passive submitted check */
@@ -594,12 +594,24 @@ int process_cgivars(void) {
 			persistent_comment = TRUE;
 
 		/* we got the notification option for an acknowledgement */
-		else if (!strcmp(variables[x], "send_notification"))
-			send_notification = TRUE;
+		else if (!strcmp(variables[x], "send_notification")) {
+			x++;
+			if (variables[x] == NULL) {
+				error = TRUE;
+				break;
+			}
+			send_notification = (atoi(variables[x]) > 0) ? TRUE : FALSE;
+		}
 
 		/* we got the acknowledgement type */
-		else if (!strcmp(variables[x], "sticky_ack"))
-			sticky_ack = TRUE;
+		else if (!strcmp(variables[x], "sticky_ack")) {
+			x++;
+			if (variables[x] == NULL) {
+				error = TRUE;
+				break;
+			}
+			sticky_ack = (atoi(variables[x]) > 0) ? TRUE : FALSE;
+		}
 
 		/* we use the end_time as expire time */
 		else if (!strcmp(variables[x], "use_ack_end_time"))
@@ -908,7 +920,7 @@ void print_form_element(int element, int cmd) {
 		printf("<tr><td class=\"objectDescription descriptionleft\">Sticky Acknowledgement:");
 		print_help_box(help_text);
 		printf("</td><td align=\"left\">");
-		printf("<INPUT TYPE='checkbox' NAME='sticky_ack' CHECKED></td></tr>\n");
+		printf("<INPUT TYPE='checkbox' NAME='sticky_ack' %s></td></tr>\n", (sticky_ack == TRUE) ? "CHECKED" : "");
 		break;
 
 	case PRINT_SEND_NOTFICATION:
@@ -918,7 +930,7 @@ void print_form_element(int element, int cmd) {
 		printf("<tr><td class=\"objectDescription descriptionleft\">Send Notification:");
 		print_help_box(help_text);
 		printf("</td><td align=\"left\">");
-		printf("<INPUT TYPE='checkbox' NAME='send_notification' CHECKED></td></tr>\n");
+		printf("<INPUT TYPE='checkbox' NAME='send_notification' %s></td></tr>\n", (send_notification == TRUE) ? "CHECKED" : "");
 		break;
 
 	case PRINT_PERSISTENT:





More information about the icinga-checkins mailing list