Merge branch 'ent-12156-usuario-agregado-con-grupo-agregado-a-categoria-de-notificaciones-no-puede-habilitar-su-envio' into 'develop'

Ent 12156 usuario agregado con grupo agregado a categoria de notificaciones no puede habilitar su envio

See merge request artica/pandorafms!6797
This commit is contained in:
Rafael Ameijeiras 2024-01-18 11:14:35 +00:00
commit 4a0d8058c5
1 changed files with 31 additions and 9 deletions

View File

@ -636,13 +636,15 @@ function notifications_get_user_label_status($source, $user, $label)
);
// Clean default common groups error for mesagges.
$group_enable = true;
if ($common_groups[0] === 0) {
unset($common_groups[0]);
$group_enable = false;
}
// 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, $group_enable);
}
@ -674,14 +676,34 @@ function notifications_set_user_label_status($source, $user, $label, $value)
return false;
}
return (bool) db_process_sql_update(
'tnotification_source_user',
[$label => $value],
[
'id_user' => $user,
'id_source' => $source,
]
);
$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'])) {
$sql = sprintf('DELETE FROM tnotification_source_user WHERE id_user = "%s" AND id_source = "%s"', $user, $source);
db_process_sql($sql);
$exists = false;
}
if ($exists === false) {
db_process_sql_insert(
'tnotification_source_user',
[
'id_user' => $user,
'id_source' => $source,
'enabled' => '1',
'also_mail' => '1',
]
);
return true;
} else {
return (bool) db_process_sql_update(
'tnotification_source_user',
[$label => $value],
[
'id_user' => $user,
'id_source' => $source,
]
);
}
}