From 063106a5fe78b74c11e451af09c02a83cd2c4e53 Mon Sep 17 00:00:00 2001 From: Michael Vasseur <14887731+vmcj@users.noreply.github.com> Date: Tue, 23 Sep 2025 21:39:07 +0200 Subject: [PATCH] Restrict clarifications to teams in the contest When you have shared DOMjudge instance with 2 different contests with teams limited by categories (or directly assigned) we would still show all known teams (even teams not in that contest). We now let the DOMjudge service handle this. --- webapp/src/Form/Type/JuryClarificationType.php | 2 +- webapp/src/Service/DOMJudgeService.php | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/webapp/src/Form/Type/JuryClarificationType.php b/webapp/src/Form/Type/JuryClarificationType.php index a379c8ed5f..70b8a69689 100644 --- a/webapp/src/Form/Type/JuryClarificationType.php +++ b/webapp/src/Form/Type/JuryClarificationType.php @@ -44,7 +44,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void $recipientOptions[$this->getTeamLabel($limitToTeam)] = $limitToTeam->getTeamid(); } else { /** @var Team|null $limitToTeam */ - $teams = $this->em->getRepository(Team::class)->findAll(); + $teams = $this->dj->getTeamsForContest($this->dj->getCurrentContest()); foreach ($teams as $team) { $recipientOptions[$this->getTeamLabel($team)] = $team->getTeamid(); } diff --git a/webapp/src/Service/DOMJudgeService.php b/webapp/src/Service/DOMJudgeService.php index 74f699ffba..befafb631d 100644 --- a/webapp/src/Service/DOMJudgeService.php +++ b/webapp/src/Service/DOMJudgeService.php @@ -1699,4 +1699,20 @@ public function getAllowedLanguagesForContest(?Contest $contest) : array { ->getQuery() ->getResult(); } + + /** @return Team[] */ + public function getTeamsForContest(?Contest $contest) : array { + if ($contest && !$contest->isOpenToAllTeams()) { + $contestTeams = $contest->getTeams()->toArray(); + foreach ($contest->getTeamCategories() as $category) { + $contestTeams = array_merge($contestTeams, $category->getTeams()->toArray()); + } + return $contestTeams; + } + return $this->em->createQueryBuilder() + ->select('l') + ->from(Team::class, 'l') + ->getQuery() + ->getResult(); + } }