diff --git a/pandora_console/godmode/setup/setup_notifications.php b/pandora_console/godmode/setup/setup_notifications.php index 28c336aa92..9ee95f78cc 100644 --- a/pandora_console/godmode/setup/setup_notifications.php +++ b/pandora_console/godmode/setup/setup_notifications.php @@ -96,6 +96,10 @@ if (get_parameter('check_new_notifications', 0)) { return; } + if (messages_get_count() == 0) { + return; + } + $messages = messages_get_overview( 'timestamp', 'ASC', diff --git a/pandora_console/include/functions_messages.php b/pandora_console/include/functions_messages.php index a67bcb56e1..9266733a68 100644 --- a/pandora_console/include/functions_messages.php +++ b/pandora_console/include/functions_messages.php @@ -365,9 +365,16 @@ function messages_get_count( if ($ignore_source === true) { $source_sql = ''; } else { - $source_sql = 'INNER JOIN tnotification_source ns - ON tm.id_source = ns.id - AND ns.enabled = 1'; + $source_sql = sprintf( + 'INNER JOIN tnotification_source ns + ON tm.id_source = ns.id + AND ns.enabled = 1 + INNER JOIN tnotification_source_user nsu + ON nsu.id_source=ns.id + AND nsu.enabled = 1 + AND nsu.id_user = "%s"', + $user + ); } $sql = sprintf( @@ -478,7 +485,11 @@ function messages_get_overview( if ($incl_source_info) { $source_fields = ', tns.*'; $source_join = 'INNER JOIN tnotification_source tns - ON tns.id=tm.id_source'; + ON tns.id=tm.id_source + INNER JOIN tnotification_source_user nsu + ON nsu.id_source=tns.id + AND nsu.enabled = 1 + OR tns.enabled = 1'; } // Using distinct because could be double assignment due group/user. diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 23b1a90e70..26dcc248c5 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -525,7 +525,7 @@ function notifications_build_user_enable_return($status, $enabled) function notifications_get_user_label_status($source, $user, $label) { // If not enabled, it cannot be modificable. - if (!$source['enabled'] || !$source[$label]) { + if (!$source['enabled']) { return notifications_build_user_enable_return(false, false); } @@ -551,7 +551,10 @@ function notifications_get_user_label_status($source, $user, $label) ); // No group found, return no permissions. $value = empty($common_groups) ? false : $source[$label]; - return notifications_build_user_enable_return($value, false); + return notifications_build_user_enable_return( + $value, + false + ); } @@ -570,7 +573,6 @@ function notifications_set_user_label_status($source, $user, $label, $value) $source_info = notifications_get_all_sources(['id' => $source]); if (!isset($source_info[0]) || !$source_info[0]['enabled'] - || !$source_info[0][$label] || !$source_info[0]['user_editable'] ) { return false;