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

View File

@ -636,13 +636,15 @@ function notifications_get_user_label_status($source, $user, $label)
); );
// Clean default common groups error for mesagges. // Clean default common groups error for mesagges.
$group_enable = true;
if ($common_groups[0] === 0) { if ($common_groups[0] === 0) {
unset($common_groups[0]); unset($common_groups[0]);
$group_enable = false;
} }
// No group found, return no permissions. // No group found, return no permissions.
$value = empty($common_groups) ? false : $source[$label]; $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,6 +676,25 @@ function notifications_set_user_label_status($source, $user, $label, $value)
return false; return false;
} }
$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( return (bool) db_process_sql_update(
'tnotification_source_user', 'tnotification_source_user',
[$label => $value], [$label => $value],
@ -683,6 +704,7 @@ function notifications_set_user_label_status($source, $user, $label, $value)
] ]
); );
} }
}
/** /**