From 5eff0e7a0c996a16bb5b2805f77bcec9bfb814c6 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 11 Nov 2021 17:48:23 +0100 Subject: [PATCH] FIX only a superadmin can modify entity --- htdocs/user/card.php | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index dec885e11eb..68218ab16bd 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -448,23 +448,15 @@ if (empty($reshook)) { $object->lang = GETPOST('default_lang', 'aZ09'); // Do we update also ->entity ? - if (!empty($conf->multicompany->enabled)) { // If multicompany is not enabled, we never update the entity of a user. - if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { - if (GETPOST('superadmin', 'int')) { - $object->entity = 0; - } else { - $object->entity = 1; // all users are in master entity - } + if (!empty($conf->multicompany->enabled && $user->entity == 0 && !empty($user->admin))) { // If multicompany is not enabled, we never update the entity of a user. + if (GETPOST('superadmin', 'int')) { + $object->entity = 0; } else { - // A user should not be able to move a user into another entity. Only superadmin should be able to do this. - if ($user->entity == 0 && $user->admin) { - if (GETPOST('superadmin', 'int')) { - // We try to set the user as superadmin. - $object->entity = 0; - } else { - // We try to change the entity of user - $object->entity = (GETPOSTISSET('entity') ? GETPOSTINT('entity') : $object->entity); - } + if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { + $object->entity = 1; // all users are in master entity + } else { + // We try to change the entity of user + $object->entity = (GETPOSTISSET('entity') ? GETPOSTINT('entity') : $object->entity); } } }