#13291 Fixed notifications based on user

This commit is contained in:
Jorge Rincon 2024-04-30 17:07:29 +02:00
parent 8d0898ec1e
commit 79b757c4bd
3 changed files with 20 additions and 16 deletions

View File

@ -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;

View File

@ -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;

View File

@ -48,24 +48,28 @@ $sources = notifications_get_all_sources();
$disabled_flag = false;
foreach ($sources as $source) {
echo '<div class="table_tbody">';
$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 '<div class="table_tbody">';
$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 '<div class="table_td">'.$source['description'].'</div>';
echo '<div class="table_td">'.$notifications_enabled['switch'].'</div>';
echo '<div class="table_td">'.$notifications_also_mail['switch'].'</div>';
echo '</div>';
} else {
$disabled_flag = true;
}
echo '<div class="table_td">'.$source['description'].'</div>';
echo '<div class="table_td">'.$notifications_enabled['switch'].'</div>';
echo '<div class="table_td">'.$notifications_also_mail['switch'].'</div>';
echo '</div>';
}
if ((bool) $disabled_flag === true) {