From 50030b69332bd93a29957e9d213bd5aabfe7e80d Mon Sep 17 00:00:00 2001 From: fermin831 Date: Fri, 1 Feb 2019 14:48:52 +0100 Subject: [PATCH] Added notify all users and disable on first load Former-commit-id: d193a8375ce00f3f2cf2c1fc181d4eef47c92eb2 --- .../include/functions_notifications.php | 28 +++++++++++++------ pandora_console/include/styles/pandora.css | 4 +++ 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index d5cd4ac97f..3d62dc0429 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -195,16 +195,16 @@ function notifications_get_user_sources_for_select($source_id) { * @return array with the group id in keys and group name in value */ function notifications_get_group_sources_for_select($source_id) { - $users = db_get_all_rows_filter( + $groups = db_get_all_rows_filter( 'tnotification_source_group tnsg - INNER JOIN tgrupo tg ON tnsg.id_group = tg.id_grupo', + LEFT JOIN tgrupo tg ON tnsg.id_group = tg.id_grupo', array('id_source' => $source_id), - array ('tnsg.id_group', 'tg.nombre') + array ('tnsg.id_group', 'IFNULL(tg.nombre, "All") AS name') ); // If fails or no one is selected, return empty array - if ($users === false) return array(); + if ($groups === false) return array(); - return index_array($users, 'id_group', 'nombre'); + return index_array($groups, 'id_group', 'name'); } /** @@ -238,6 +238,12 @@ function notifications_print_global_source_configuration($source) { 'name' => "enable-" . $id, 'value' => $source['enabled'] ); + + // Search if group all is set and handle that situation + $source_groups = notifications_get_group_sources_for_select($source['id']); + $is_group_all = isset($source_groups["0"]); + if($is_group_all) unset($source_groups["0"]); + // Generate the title $html_title = "
"; $html_title .= html_print_switch($switch_values); @@ -246,13 +252,16 @@ function notifications_print_global_source_configuration($source) { // Generate the html for title $html_selectors = "
"; - $html_selectors .= notifications_print_source_select_box(notifications_get_user_sources_for_select($source['id']), 'users'); - $html_selectors .= notifications_print_source_select_box(notifications_get_group_sources_for_select($source['id']), 'groups'); + $html_selectors .= notifications_print_source_select_box(notifications_get_user_sources_for_select($source['id']), 'users', $is_group_all); + $html_selectors .= notifications_print_source_select_box($source_groups, 'groups', $is_group_all); $html_selectors .= "
"; // Generate the checkboxes and time select $html_checkboxes = "
"; $html_checkboxes .= " "; + $html_checkboxes .= html_print_checkbox("all-$id", 1, $is_group_all, true, false, 'notifications_disable_source(event)'); + $html_checkboxes .= __('Notify all users'); + $html_checkboxes .= "
"; $html_checkboxes .= html_print_checkbox("mail-$id", 1, $source['also_mail'], true); $html_checkboxes .= __('Also email users with notification content'); $html_checkboxes .= "
"; @@ -290,10 +299,11 @@ function notifications_print_global_source_configuration($source) { * * @param array $info_selec All info required for build the selector * @param string $id users|groups + * @param bool $disabled Disable the selectors * * @return string HTML with the generated selector */ -function notifications_print_source_select_box($info_selec, $id) { +function notifications_print_source_select_box($info_selec, $id, $disabled) { $title = $id == "users" ? __('Notified users') : __('Notified groups'); $add_title = $id == "users" ? __('Add users') : __('Add groups'); @@ -304,7 +314,7 @@ function notifications_print_source_select_box($info_selec, $id) { $html_select .= "
"; $html_select .= "

$title

"; // Put a true if empty sources to avoid to sow the 'None' value - $html_select .= html_print_select(empty($info_selec) ? true : $info_selec, "multi-{$id}[]", 0, false, '', '', true, true); + $html_select .= html_print_select(empty($info_selec) ? true : $info_selec, "multi-{$id}[]", 0, false, '', '', true, true, true,'', $disabled); $html_select .= "
"; $html_select .= "
"; $html_select .= html_print_image('images/input_add.png', true, array('title' => $add_title)); diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index e1545c8d5d..aee1b9dc5d 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -4939,6 +4939,10 @@ div#dialog_messages table th:last-child { margin-left: 10px; } +.global-config-notification-checkboxes :first-child { + font-weight: bold; +} + .global-config-notification-selectors { display: flex; flex-direction: row;