@@ -400,6 +400,51 @@ public function findAllByCircles(string $userId, ?int $limit = null, ?int $offse
400400 return $ entries ;
401401 }
402402
403+ public function findAllByTeam (string $ teamId ): array {
404+ $ qb = $ this ->db ->getQueryBuilder ();
405+ $ qb ->select ('b.id ' , 'title ' , 'owner ' , 'color ' , 'archived ' , 'deleted_at ' , 'last_modified ' )
406+ ->from ('deck_boards ' , 'b ' )
407+ ->innerJoin ('b ' , 'deck_board_acl ' , 'acl ' , $ qb ->expr ()->eq ('b.id ' , 'acl.board_id ' ))
408+ ->where ($ qb ->expr ()->eq ('acl.type ' , $ qb ->createNamedParameter (Acl::PERMISSION_TYPE_CIRCLE , IQueryBuilder::PARAM_INT )))
409+ ->andWhere ($ qb ->expr ()->eq ('acl.participant ' , $ qb ->createNamedParameter ($ teamId , IQueryBuilder::PARAM_STR )));
410+ $ entries = $ this ->findEntities ($ qb );
411+ foreach ($ entries as $ entry ) {
412+ $ entry ->setShared (2 );
413+ }
414+ return $ entries ;
415+ }
416+
417+ public function findTeamsForBoard (int $ boardId ): array {
418+ $ qb = $ this ->db ->getQueryBuilder ();
419+ $ qb ->select ('acl.participant ' )
420+ ->from ('deck_boards ' , 'b ' )
421+ ->innerJoin ('b ' , 'deck_board_acl ' , 'acl ' , $ qb ->expr ()->eq ('b.id ' , 'acl.board_id ' ))
422+ ->where ($ qb ->expr ()->eq ('b.id ' , $ qb ->createNamedParameter ($ boardId , IQueryBuilder::PARAM_INT )))
423+ ->andWhere ($ qb ->expr ()->eq ('acl.type ' , $ qb ->createNamedParameter (Acl::PERMISSION_TYPE_CIRCLE , IQueryBuilder::PARAM_INT )));
424+
425+ $ result = $ qb ->executeQuery ();
426+ return array_map (function ($ entry ) {
427+ return $ entry ['participant ' ];
428+ }, $ result ->fetchAll ());
429+ }
430+
431+ public function isSharedWithTeam (int $ boardId , string $ teamId ): bool {
432+ $ qb = $ this ->db ->getQueryBuilder ();
433+ $ qb ->select ('b.id ' , 'title ' , 'owner ' , 'color ' , 'archived ' , 'deleted_at ' , 'last_modified ' )
434+ ->from ('deck_boards ' , 'b ' )
435+ ->innerJoin ('b ' , 'deck_board_acl ' , 'acl ' , $ qb ->expr ()->eq ('b.id ' , 'acl.board_id ' ))
436+ ->where ($ qb ->expr ()->eq ('b.id ' , $ qb ->createNamedParameter ($ boardId , IQueryBuilder::PARAM_INT )))
437+ ->andWhere ($ qb ->expr ()->eq ('acl.type ' , $ qb ->createNamedParameter (Acl::PERMISSION_TYPE_CIRCLE , IQueryBuilder::PARAM_INT )))
438+ ->andWhere ($ qb ->expr ()->eq ('acl.participant ' , $ qb ->createNamedParameter ($ teamId , IQueryBuilder::PARAM_STR )));
439+ try {
440+ $ this ->findEntity ($ qb );
441+ return true ;
442+ } catch (DoesNotExistException $ e ) {
443+ // Expected return falue
444+ }
445+ return false ;
446+ }
447+
403448 public function findAll (): array {
404449 $ qb = $ this ->db ->getQueryBuilder ();
405450 $ qb ->select ('id ' )
0 commit comments