Skip to content
Snippets Groups Projects
Verified Commit 95646649 authored by Damien's avatar Damien
Browse files

FEAT #7387 #7388 Add users from entities and groups

parent b6a13546
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
......@@ -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]);
}
......
......@@ -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'] = '';
......
......@@ -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');
......
......@@ -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');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment