mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 00:04:37 +02:00
Added check for the profile is used by admin users before to delete. TICKET: #1753
This commit is contained in:
parent
cf84411c59
commit
39780da045
@ -65,6 +65,20 @@ $id_profile = (int) get_parameter ('id');
|
||||
|
||||
// Profile deletion
|
||||
if ($delete_profile) {
|
||||
|
||||
$count_users_admin_in_profile = db_get_value_sql("
|
||||
SELECT COUNT(*)
|
||||
FROM tusuario
|
||||
WHERE is_admin = 1 AND id_user IN (
|
||||
SELECT id_usuario
|
||||
FROM tusuario_perfil
|
||||
WHERE id_perfil = " . $id_profile . ")");
|
||||
|
||||
if ($count_users_admin_in_profile >= 1) {
|
||||
ui_print_error_message(
|
||||
__('Unsucessful delete profile. Because the profile is used by some admin users.'));
|
||||
}
|
||||
else {
|
||||
// Delete profile
|
||||
$profile = db_get_row('tperfil', 'id_perfil', $id_profile);
|
||||
$sql = sprintf ('DELETE FROM tperfil WHERE id_perfil = %d', $id_profile);
|
||||
@ -85,6 +99,7 @@ if ($delete_profile) {
|
||||
|
||||
$id_profile = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Store the variables when create or update
|
||||
if($create_profile || $update_profile) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user