diff --git a/src/app/group/controllers/ServiceController.php b/src/app/group/controllers/ServiceController.php index d8a9e6914b80e443150aa165c16fb50f204bc775..9035bd685e8e56322baab1c9d126e4123f2a840c 100755 --- a/src/app/group/controllers/ServiceController.php +++ b/src/app/group/controllers/ServiceController.php @@ -189,4 +189,29 @@ class ServiceController return !empty($aServices); } + + public static function getPrivilegesByUser(array $args) { + ValidatorModel::notEmpty($args, ['userId']); + ValidatorModel::intVal($args, ['userId']); + + $user = UserModel::getById([ + 'select' => ['user_id'], + 'id' => $args['userId'] + ]); + if ($user['user_id'] == 'superadmin') { + $allPrivileges = array_merge( + ServiceController::PRIVILEGE_ADMIN_SUPERVISION, + ServiceController::PRIVILEGE_ADMIN_PRODUCTION, + ServiceController::PRIVILEGE_ADMIN_CLASSIFYING, + ServiceController::PRIVILEGE_ADMIN_ORGANIZATION, + ServiceController::PRIVILEGE_MENU); + + return $allPrivileges; + } + + $rawPrivilegesStoredInDB = ServiceModel::getByUser(['id' => $args['userId']]); + $privilegesStoredInDB = array_column($rawPrivilegesStoredInDB, 'service_id'); + + return $privilegesStoredInDB; + } } diff --git a/src/app/user/controllers/UserController.php b/src/app/user/controllers/UserController.php index 70e5f1aeefde744bff2da48735b6c45e2915b754..d572438528d3d52bee6c8f104cc6018ba138ad8c 100755 --- a/src/app/user/controllers/UserController.php +++ b/src/app/user/controllers/UserController.php @@ -455,6 +455,7 @@ class UserController $user['regroupedBaskets'] = BasketModel::getRegroupedBasketsByUserId(['userId' => $user['user_id']]); $user['passwordRules'] = PasswordModel::getEnabledRules(); $user['canModifyPassword'] = true; + $user['privileges'] = ServiceController::getPrivilegesByUser(['userId' => $user['id']]); $loggingMethod = CoreConfigModel::getLoggingMethod(); if (in_array($loggingMethod['id'], self::ALTERNATIVES_CONNECTIONS_METHODS)) {