From 79b757c4bdc2d355212b7eba9b6f7563cbdbfc63 Mon Sep 17 00:00:00 2001 From: Jorge Rincon Date: Tue, 30 Apr 2024 17:07:29 +0200 Subject: [PATCH] #13291 Fixed notifications based on user --- .../include/ajax/notifications.ajax.php | 2 +- .../include/functions_notifications.php | 2 +- .../users/user_edit_notifications.php | 32 +++++++++++-------- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/pandora_console/include/ajax/notifications.ajax.php b/pandora_console/include/ajax/notifications.ajax.php index a69ad1b56e..0295ddd915 100644 --- a/pandora_console/include/ajax/notifications.ajax.php +++ b/pandora_console/include/ajax/notifications.ajax.php @@ -37,7 +37,7 @@ if ($change_label === '1') { $label = get_parameter('label', ''); $source = get_parameter('source', 0); $user = get_parameter('user', ''); - $value = get_parameter('value', 0) ? 1 : 0; + $value = get_parameter('value', 0); $user_info = get_user_info($config['id_user']); if ((bool) $user_info['is_admin'] === false && $config['id_user'] !== $user) { return false; diff --git a/pandora_console/include/functions_notifications.php b/pandora_console/include/functions_notifications.php index 947b2d8657..9b3ef61a2e 100644 --- a/pandora_console/include/functions_notifications.php +++ b/pandora_console/include/functions_notifications.php @@ -680,7 +680,7 @@ function notifications_set_user_label_status($source, $user, $label, $value) } $exists = db_process_sql(sprintf('SELECT * FROM tnotification_source_user WHERE id_user = "%s" AND id_source = "%s"', $user, $source)); - if (empty($exists['enabled']) && empty($exists['also_mail'])) { + if (empty($exists[0]['enabled']) && empty($exists[0]['also_mail'])) { $sql = sprintf('DELETE FROM tnotification_source_user WHERE id_user = "%s" AND id_source = "%s"', $user, $source); db_process_sql($sql); $exists = false; diff --git a/pandora_console/operation/users/user_edit_notifications.php b/pandora_console/operation/users/user_edit_notifications.php index 77ef1caebe..bef578d2f4 100644 --- a/pandora_console/operation/users/user_edit_notifications.php +++ b/pandora_console/operation/users/user_edit_notifications.php @@ -48,24 +48,28 @@ $sources = notifications_get_all_sources(); $disabled_flag = false; foreach ($sources as $source) { - echo '
'; - $table_content = [ - $source['description'], - notifications_print_user_switch($source, $id, 'enabled'), - notifications_print_user_switch($source, $id, 'also_mail'), - ]; + // Enabled notification user. + $users = notifications_get_user_sources_for_select($source['id']); + if ((boolean) $source['enabled'] === true && $users[$id] !== null) { + echo '
'; + $table_content = [ + notifications_print_user_switch($source, $id, 'enabled'), + notifications_print_user_switch($source, $id, 'also_mail'), + ]; + $notifications_enabled = notifications_print_user_switch($source, $id, 'enabled'); + $notifications_also_mail = notifications_print_user_switch($source, $id, 'also_mail'); - $notifications_enabled = notifications_print_user_switch($source, $id, 'enabled'); - $notifications_also_mail = notifications_print_user_switch($source, $id, 'also_mail'); + if ($notifications_enabled['disabled'] == 1 || $notifications_also_mail['disabled'] == 1) { + $disabled_flag = true; + } - if ($notifications_enabled['disabled'] == 1 || $notifications_also_mail['disabled'] == 1) { + echo '
'.$source['description'].'
'; + echo '
'.$notifications_enabled['switch'].'
'; + echo '
'.$notifications_also_mail['switch'].'
'; + echo '
'; + } else { $disabled_flag = true; } - - echo '
'.$source['description'].'
'; - echo '
'.$notifications_enabled['switch'].'
'; - echo '
'.$notifications_also_mail['switch'].'
'; - echo '
'; } if ((bool) $disabled_flag === true) {