From b396e8f8889ce7506318a533a7640fa59b574e6d Mon Sep 17 00:00:00 2001 From: Lung Date: Sat, 27 Apr 2024 11:06:38 +0200 Subject: [PATCH] filtered out admins from participant lists --- src/Import/ImportSrs.php | 5 ++--- src/Participant/Ist/IstService.php | 4 ++-- src/Participant/ParticipantRepository.php | 10 ++++++++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Import/ImportSrs.php b/src/Import/ImportSrs.php index 5f09cca3..89555152 100644 --- a/src/Import/ImportSrs.php +++ b/src/Import/ImportSrs.php @@ -128,7 +128,6 @@ private function mapDataIntoNewIst(array $data, Event $event, ?User $existingUse $contingent = EventTypeObrok::CONTINGENT_ORG; } - $skautisUserId = $data['skautis_user_id']; if (is_numeric($skautisUserId) === false) { $this->flashMessages->warning('flash.warning.importSrs.skautisUserIdNotNumeric'); @@ -148,6 +147,7 @@ private function mapDataIntoNewIst(array $data, Event $event, ?User $existingUse 'Ano' => true, default => false, }; + $participant = null; if ($existingUser === null) { $existingUser = $this->userService->createSkautisUser( @@ -156,11 +156,10 @@ private function mapDataIntoNewIst(array $data, Event $event, ?User $existingUse $email, $userStatus, ); - } else { $participant = $this->participantRepository->findParticipantFromUser($existingUser); - } + return $this->istService->createIstPayment( $existingUser, $event, diff --git a/src/Participant/Ist/IstService.php b/src/Participant/Ist/IstService.php index e752aab2..e368b4dc 100644 --- a/src/Participant/Ist/IstService.php +++ b/src/Participant/Ist/IstService.php @@ -58,11 +58,11 @@ public function createIstPayment( string $swift, DateTimeImmutable $due, ): Participant { - if ($participant == null) { + if ($participant === null) { $participant = new Participant(); } $participant->user = $user; - $participant->role = ParticipantRole::Ist; + $participant->role = ParticipantRole::Ist; // TODO fix case with TL/PL having troop participants/patrol patrol participants $participant->contingent = $contingent; $participant->firstName = $firstName; $participant->lastName = $lastName; diff --git a/src/Participant/ParticipantRepository.php b/src/Participant/ParticipantRepository.php index 5e8b4359..99eeea02 100755 --- a/src/Participant/ParticipantRepository.php +++ b/src/Participant/ParticipantRepository.php @@ -44,6 +44,7 @@ public function getAllParticipantsWithStatus( $qb->join('user')->as('u')->on('u.id = participant.user_id'); $qb->where('participant.role IN %in', $roles); + $qb->where('u.role = %s', UserRole::Participant); $qb->where('u.status IN %in', $statuses); $qb->where('u.event_id = %i', $event->id); @@ -102,6 +103,7 @@ public function getParticipantsCount( $qb->join('user')->as('u')->on('u.id = participant.user_id'); $qb->where('participant.role IN %in', $roles); + $qb->where('u.role = %s', UserRole::Participant); $qb->where('u.status IN %in', $statuses); $qb->where('u.event_id = %i', $event->id); @@ -208,6 +210,7 @@ public function getParticipantsForEntry(Event $event): array $qb->join('user')->as('u')->on('u.id = participant.user_id'); $qb->leftJoin('deal')->as('d')->on('participant.id = d.participant_id')->and('d.slug = %s', 'sfh'); + $qb->where('u.role = %s', UserRole::Participant); $qb->where('u.status = %s', UserStatus::Paid); $qb->where('u.event_id = %i', $event->id); @@ -274,9 +277,10 @@ public function getIstArrivalStatistic( $qb = $this->connection->select('date(participant.arrival_date) as ad, COUNT(*)')->from($this->getTable()); $qb->join('user')->as('u')->on('u.id = participant.user_id'); - $qb->where('u.event_id = %i', $event->id); $qb->where('participant.role = %s', ParticipantRole::Ist); + $qb->where('u.role = %s', UserRole::Participant); $qb->where('u.status = %s', UserStatus::Paid); + $qb->where('u.event_id = %i', $event->id); $qb->groupBy('date(participant.arrival_date)'); $qb->orderBy('date(participant.arrival_date)'); @@ -296,8 +300,9 @@ public function getFoodStatistic( $qb = $this->connection->select('participant.food_preferences as f, COUNT(*)')->from($this->getTable()); $qb->join('user')->as('u')->on('u.id = participant.user_id'); - $qb->where('u.event_id = %i', $event->id); + $qb->where('u.role = %s', UserRole::Participant); $qb->where('u.status = %s', UserStatus::Paid); + $qb->where('u.event_id = %i', $event->id); $qb->groupBy('participant.food_preferences'); $qb->orderBy('participant.food_preferences'); @@ -322,6 +327,7 @@ public function getStatistic( $qb->where('participant.contingent = %s', $contingent); } + $qb->where('u.role = %s', UserRole::Participant); $qb->groupBy('u.status'); $rows = $qb->fetchPairs('status', 'count');