diff --git a/core/Test/AutocompleteControllerTest.php b/core/Test/AutocompleteControllerTest.php index 38a912a7ca7ea7cf84d12abc1af169a296fdf5ac..2e68b6d615504871b72588c01cc5a8d98f052c9e 100644 --- a/core/Test/AutocompleteControllerTest.php +++ b/core/Test/AutocompleteControllerTest.php @@ -50,7 +50,7 @@ class AutocompleteControllerTest extends TestCase $this->assertNotEmpty($responseBody); $this->assertSame('user', $responseBody[0]->type); - $this->assertInternalType('string', $responseBody[0]->id); + $this->assertInternalType('int', $responseBody[0]->id); $this->assertNotEmpty($responseBody[0]->id); $this->assertInternalType('string', $responseBody[0]->idToDisplay); $this->assertNotEmpty($responseBody[0]->idToDisplay); diff --git a/src/app/entity/controllers/EntityController.php b/src/app/entity/controllers/EntityController.php index 3c7bb27ba7fe059baeea9421cc5e5cee191bc8c1..e05b4ca0088ef59e85f005cff82ca537a13279cc 100644 --- a/src/app/entity/controllers/EntityController.php +++ b/src/app/entity/controllers/EntityController.php @@ -145,6 +145,7 @@ class EntityController $entity['instances'] = count($instances); $redirects = BasketModel::getGroupActionRedirect(['select' => [1], 'where' => ['entity_id = ?'], 'data' => [$aArgs['id']]]); $entity['redirects'] = count($redirects); + $entity['canAdminUsers'] = ServiceModel::hasService(['id' => 'admin_users', 'userId' => $GLOBALS['userId'], 'location' => 'apps', 'type' => 'admin']); return $response->withJson(['entity' => $entity]); } diff --git a/src/app/user/controllers/UserController.php b/src/app/user/controllers/UserController.php index 22b4f6f3377f142282ebcd790d9c55862ddbed0b..9d993de9aa82e258fc570531139627cbcfc790fa 100644 --- a/src/app/user/controllers/UserController.php +++ b/src/app/user/controllers/UserController.php @@ -633,7 +633,7 @@ class UserController if (empty($group)) { return $response->withStatus(400)->withJson(['errors' => 'Group not found']); } elseif (UserModel::hasGroup(['id' => $aArgs['id'], 'groupId' => $data['groupId']])) { - return $response->withStatus(400)->withJson(['errors' => 'User is already linked to this group']); + return $response->withStatus(400)->withJson(['errors' => _USER_ALREADY_LINK_GROUP]); } if (empty($data['role'])) { $data['role'] = ''; @@ -745,7 +745,7 @@ class UserController if (empty(EntityModel::getById(['entityId' => $data['entityId']]))) { return $response->withStatus(400)->withJson(['errors' => 'Entity not found']); } elseif (UserModel::hasEntity(['id' => $aArgs['id'], 'entityId' => $data['entityId']])) { - return $response->withStatus(400)->withJson(['errors' => 'User is already linked to this entity']); + return $response->withStatus(400)->withJson(['errors' => _USER_ALREADY_LINK_ENTITY]); } if (empty($data['role'])) { $data['role'] = ''; diff --git a/src/core/lang/lang-en.php b/src/core/lang/lang-en.php index 83d8ea51deba1f89ac9423e410fc1ad36841db5f..2553deed59eb197a0ae40dcec4925233ffba80dd 100644 --- a/src/core/lang/lang-en.php +++ b/src/core/lang/lang-en.php @@ -75,6 +75,8 @@ define('_USER_GROUP_SUPPRESSION', 'Group deleted for user'); define('_USER_ENTITY_CREATION', 'Entity added for user'); define('_USER_ENTITY_MODIFICATION', 'Entity updated for user'); define('_USER_ENTITY_SUPPRESSION', 'Entity deleted for user'); +define('_USER_ALREADY_LINK_GROUP', 'User is already linked to this group'); +define('_USER_ALREADY_LINK_ENTITY', 'User is already linked to this entity'); define('_VISA_USER', 'For visa'); define('_WRONG_FILE_TYPE', 'This type of file is not allowed'); define('_CAN_NOT_MOVE_IN_CHILD_ENTITY', 'Parent entity must not be a subentity'); diff --git a/src/core/lang/lang-fr.php b/src/core/lang/lang-fr.php index d8e3ad5979ff8547bc28cfbdab2adfca42189ed2..1d40889e155c4129e841f8f35a1326efbe170a20 100644 --- a/src/core/lang/lang-fr.php +++ b/src/core/lang/lang-fr.php @@ -75,6 +75,8 @@ define('_USER_GROUP_SUPPRESSION', 'Groupe supprimé pour utilisateur'); define('_USER_ENTITY_CREATION', 'Entité ajoutée pour utilisateur'); define('_USER_ENTITY_MODIFICATION', 'Entité modifiée pour utilisateur'); define('_USER_ENTITY_SUPPRESSION', 'Entité supprimée pour utilisateur'); +define('_USER_ALREADY_LINK_GROUP', 'L\'utilisateur est déjà lié à ce groupe'); +define('_USER_ALREADY_LINK_ENTITY', 'L\'utilisateur est déjà lié à cette entité'); define('_VISA_USER', 'Pour visa'); define('_WRONG_FILE_TYPE', 'Ce type de fichier n\'est pas permis'); define('_CAN_NOT_MOVE_IN_CHILD_ENTITY', 'L\'entité parente ne doit pas être dans une entité fille');