From a064cc18179c5120e00e2e9ee75a13e99cac8640 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Mon, 27 Apr 2020 14:25:40 +0200 Subject: [PATCH] Fix broken send mail link --- server_files/controllers/tournoi.php | 20 +++++++++--- server_files/controllers/tournois.php | 46 ++++++++++++++++----------- server_files/views/tournoi.php | 3 +- server_files/views/tournois.php | 3 +- 4 files changed, 47 insertions(+), 25 deletions(-) diff --git a/server_files/controllers/tournoi.php b/server_files/controllers/tournoi.php index 3b5b451..0cc0155 100644 --- a/server_files/controllers/tournoi.php +++ b/server_files/controllers/tournoi.php @@ -122,24 +122,34 @@ class UpdateTournament } } -if ($_SESSION["role"] == Role::ENCADRANT || $_SESSION["role"] == Role::ADMIN) { +if ($_SESSION["role"] == Role::ORGANIZER || $_SESSION["role"] == Role::ADMIN) { $emails = []; - foreach ($tournament->getOrganizers() as $organizer) - $emails[] = $organizer->getEmail(); + $emails_validated = []; + foreach ($tournament->getOrganizers() as $organizer) { + $emails[] = $organizer->getEmail(); + $emails_validated[] = $organizer->getEmail(); + } foreach ($teams as $team) { foreach ($team->getEncadrants() as $encadrant_id) { $encadrant = User::fromId($encadrant_id); - if ($encadrant != null) - $emails[] = $encadrant->getEmail(); + if ($encadrant != null) { + $emails[] = $encadrant->getEmail(); + if ($team->getValidationStatus() == ValidationStatus::VALIDATED) + $emails_validated[] = $encadrant->getEmail(); + } } foreach ($team->getParticipants() as $participant_id) { $participant = User::fromId($participant_id); if ($participant != null) { $emails[] = $participant->getEmail(); + if ($team->getValidationStatus() == ValidationStatus::VALIDATED) + $emails_validated[] = $participant->getEmail(); if ($participant->getResponsibleEmail() != null) { $emails[] = $participant->getResponsibleEmail(); + if ($team->getValidationStatus() == ValidationStatus::VALIDATED) + $emails_validated[] = $participant->getResponsibleEmail(); } } } diff --git a/server_files/controllers/tournois.php b/server_files/controllers/tournois.php index 68430cf..7a304fc 100644 --- a/server_files/controllers/tournois.php +++ b/server_files/controllers/tournois.php @@ -3,29 +3,39 @@ $tournaments = Tournament::getAllTournaments(); $emails = []; +$emails_validated = []; if ($_SESSION["role"] == Role::ORGANIZER || $_SESSION["role"] == Role::ADMIN) { foreach ($tournaments as $tournament) { - foreach ($tournament->getOrganizers() as $organizer) - $emails[] = $organizer->getEmail(); + foreach ($tournament->getOrganizers() as $organizer) { + $emails[] = $organizer->getEmail(); + $emails_validated[] = $organizer->getEmail(); + } - foreach ($tournament->getAllTeams() as $team) { - foreach ($team->getEncadrants() as $encadrant_id) { - $encadrant = User::fromId($encadrant_id); - if ($encadrant != null) - $emails[] = $encadrant->getEmail(); - } + foreach ($tournament->getAllTeams() as $team) { + foreach ($team->getEncadrants() as $encadrant_id) { + $encadrant = User::fromId($encadrant_id); + if ($encadrant != null) { + $emails[] = $encadrant->getEmail(); + if ($team->getValidationStatus() == ValidationStatus::VALIDATED) + $emails_validated[] = $encadrant->getEmail(); + } + } - foreach ($team->getParticipants() as $participant_id) { - $participant = User::fromId($participant_id); - if ($participant != null) { - $emails[] = $participant->getEmail(); - if ($participant->getResponsibleEmail() != null) { - $emails[] = $participant->getResponsibleEmail(); - } - } - } - } + foreach ($team->getParticipants() as $participant_id) { + $participant = User::fromId($participant_id); + if ($participant != null) { + $emails[] = $participant->getEmail(); + if ($team->getValidationStatus() == ValidationStatus::VALIDATED) + $emails_validated[] = $participant->getEmail(); + if ($participant->getResponsibleEmail() != null) { + $emails[] = $participant->getResponsibleEmail(); + if ($team->getValidationStatus() == ValidationStatus::VALIDATED) + $emails_validated[] = $participant->getResponsibleEmail(); + } + } + } + } } } diff --git a/server_files/views/tournoi.php b/server_files/views/tournoi.php index 7db87ce..52190a7 100644 --- a/server_files/views/tournoi.php +++ b/server_files/views/tournoi.php @@ -60,7 +60,8 @@ if ($tournament->isFinal()) organize($_SESSION["user_id"]))) { ?>
- subject=TFJM² " target="_blank">Envoyer un mail à toutes les personnes inscrites au tournoi + subject=TFJM² " target="_blank">Envoyer un mail à toutes les personnes inscrites au tournoi
+ subject=TFJM² " target="_blank">Envoyer un mail à toutes les personnes inscrites au tournoi dans une équipe validée
diff --git a/server_files/views/tournois.php b/server_files/views/tournois.php index a90ecb9..5c7526d 100644 --- a/server_files/views/tournois.php +++ b/server_files/views/tournois.php @@ -6,7 +6,8 @@
- subject=TFJM² " target="_blank">Envoyer un mail à toutes les personnes inscrites au tournoi + subject=TFJM² " target="_blank">Envoyer un mail à toutes les personnes inscrites au tournoi
+ subject=TFJM² " target="_blank">Envoyer un mail à toutes les personnes inscrites au tournoi dans une équipe validée