Merge branch '2517-api-listar-y-crear-perfiles-de-usuario-en-meta-6168-eucomm-2' into 'develop'

Fixed profile_delete_profile_and_clean_users to not fail when a profile is not assigned to an user

See merge request artica/pandorafms!2037
This commit is contained in:
vgilc 2018-12-04 12:21:26 +01:00
commit 7e5667c227
1 changed files with 9 additions and 4 deletions

View File

@ -152,10 +152,15 @@ function profile_delete_profile ($id_profile) {
* @return bool Whether or not it's deleted in both tables
*/
function profile_delete_profile_and_clean_users ($id_profile) {
return
(bool)db_process_sql_delete('tperfil', array('id_perfil' => $id_profile)) &&
(bool)db_process_sql_delete('tusuario_perfil', array('id_perfil' => $id_profile))
;
$profile_deletion = (bool)db_process_sql_delete('tperfil', array('id_perfil' => $id_profile));
// Delete in tusuario_perfil only if is needed
if (!(bool)db_get_value('id_perfil', 'tusuario_perfil', 'id_perfil', $id_profile)) {
return $profile_deletion;
}
return $profile_deletion &&
(bool)db_process_sql_delete('tusuario_perfil', array('id_perfil' => $id_profile));
}
/**