@@ -48,7 +48,7 @@ public function __construct(
4848 public function assignUser (int $ cardId , string $ userId , int $ type = Assignment::TYPE_USER ): Assignment {
4949 $ this ->assignmentServiceValidator ->check (compact ('cardId ' , 'userId ' ));
5050
51- if ($ type !== Assignment::TYPE_USER && $ type !== Assignment::TYPE_GROUP && $ type !== Assignment::TYPE_REMOTE ) {
51+ if ($ type !== Assignment::TYPE_USER && $ type !== Assignment::TYPE_GROUP && $ type !== Assignment::TYPE_REMOTE && $ type !== Assignment:: TYPE_CIRCLE ) {
5252 throw new BadRequestException ('Invalid type provided for assignemnt ' );
5353 }
5454
@@ -63,10 +63,14 @@ public function assignUser(int $cardId, string $userId, int $type = Assignment::
6363 $ card = $ this ->cardMapper ->find ($ cardId );
6464 $ boardId = $ this ->cardMapper ->findBoardId ($ cardId );
6565 $ boardUsers = array_keys ($ this ->permissionService ->findUsers ($ boardId , true ));
66- $ groups = array_filter ($ this ->aclMapper ->findAll ($ boardId ), function (Acl $ acl ) use ($ userId ) {
66+ $ acls = $ this ->aclMapper ->findAll ($ boardId );
67+ $ groups = array_filter ($ acls , function (Acl $ acl ) use ($ userId ) {
6768 return $ acl ->getType () === Acl::PERMISSION_TYPE_GROUP && $ acl ->getParticipant () === $ userId ;
6869 });
69- if (!in_array ($ userId , $ boardUsers , true ) && count ($ groups ) !== 1 ) {
70+ $ teams = array_filter ($ acls , function (Acl $ acl ) use ($ userId ) {
71+ return $ acl ->getType () === Acl::PERMISSION_TYPE_CIRCLE && $ acl ->getParticipant () === $ userId ;
72+ });
73+ if (!in_array ($ userId , $ boardUsers , true ) && count ($ groups ) !== 1 && count ($ teams ) !== 1 ) {
7074 throw new BadRequestException ('The user is not part of the board ' );
7175 }
7276
0 commit comments