1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2024-12-25 17:02:28 +00:00

Fix broken send mail link

This commit is contained in:
Yohann D'ANELLO 2020-04-27 14:25:40 +02:00
parent 85f16ebd07
commit a064cc1817
4 changed files with 47 additions and 25 deletions

View File

@ -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 = []; $emails = [];
foreach ($tournament->getOrganizers() as $organizer) $emails_validated = [];
$emails[] = $organizer->getEmail(); foreach ($tournament->getOrganizers() as $organizer) {
$emails[] = $organizer->getEmail();
$emails_validated[] = $organizer->getEmail();
}
foreach ($teams as $team) { foreach ($teams as $team) {
foreach ($team->getEncadrants() as $encadrant_id) { foreach ($team->getEncadrants() as $encadrant_id) {
$encadrant = User::fromId($encadrant_id); $encadrant = User::fromId($encadrant_id);
if ($encadrant != null) if ($encadrant != null) {
$emails[] = $encadrant->getEmail(); $emails[] = $encadrant->getEmail();
if ($team->getValidationStatus() == ValidationStatus::VALIDATED)
$emails_validated[] = $encadrant->getEmail();
}
} }
foreach ($team->getParticipants() as $participant_id) { foreach ($team->getParticipants() as $participant_id) {
$participant = User::fromId($participant_id); $participant = User::fromId($participant_id);
if ($participant != null) { if ($participant != null) {
$emails[] = $participant->getEmail(); $emails[] = $participant->getEmail();
if ($team->getValidationStatus() == ValidationStatus::VALIDATED)
$emails_validated[] = $participant->getEmail();
if ($participant->getResponsibleEmail() != null) { if ($participant->getResponsibleEmail() != null) {
$emails[] = $participant->getResponsibleEmail(); $emails[] = $participant->getResponsibleEmail();
if ($team->getValidationStatus() == ValidationStatus::VALIDATED)
$emails_validated[] = $participant->getResponsibleEmail();
} }
} }
} }

View File

@ -3,29 +3,39 @@
$tournaments = Tournament::getAllTournaments(); $tournaments = Tournament::getAllTournaments();
$emails = []; $emails = [];
$emails_validated = [];
if ($_SESSION["role"] == Role::ORGANIZER || $_SESSION["role"] == Role::ADMIN) { if ($_SESSION["role"] == Role::ORGANIZER || $_SESSION["role"] == Role::ADMIN) {
foreach ($tournaments as $tournament) { foreach ($tournaments as $tournament) {
foreach ($tournament->getOrganizers() as $organizer) foreach ($tournament->getOrganizers() as $organizer) {
$emails[] = $organizer->getEmail(); $emails[] = $organizer->getEmail();
$emails_validated[] = $organizer->getEmail();
}
foreach ($tournament->getAllTeams() as $team) { foreach ($tournament->getAllTeams() as $team) {
foreach ($team->getEncadrants() as $encadrant_id) { foreach ($team->getEncadrants() as $encadrant_id) {
$encadrant = User::fromId($encadrant_id); $encadrant = User::fromId($encadrant_id);
if ($encadrant != null) if ($encadrant != null) {
$emails[] = $encadrant->getEmail(); $emails[] = $encadrant->getEmail();
} if ($team->getValidationStatus() == ValidationStatus::VALIDATED)
$emails_validated[] = $encadrant->getEmail();
}
}
foreach ($team->getParticipants() as $participant_id) { foreach ($team->getParticipants() as $participant_id) {
$participant = User::fromId($participant_id); $participant = User::fromId($participant_id);
if ($participant != null) { if ($participant != null) {
$emails[] = $participant->getEmail(); $emails[] = $participant->getEmail();
if ($participant->getResponsibleEmail() != null) { if ($team->getValidationStatus() == ValidationStatus::VALIDATED)
$emails[] = $participant->getResponsibleEmail(); $emails_validated[] = $participant->getEmail();
} if ($participant->getResponsibleEmail() != null) {
} $emails[] = $participant->getResponsibleEmail();
} if ($team->getValidationStatus() == ValidationStatus::VALIDATED)
} $emails_validated[] = $participant->getResponsibleEmail();
}
}
}
}
} }
} }

View File

@ -60,7 +60,8 @@ if ($tournament->isFinal())
<?php if (!isset($_GET["modifier"]) && ($_SESSION["role"] == Role::ADMIN || $_SESSION["role"] == Role::ORGANIZER && $tournament->organize($_SESSION["user_id"]))) { ?> <?php if (!isset($_GET["modifier"]) && ($_SESSION["role"] == Role::ADMIN || $_SESSION["role"] == Role::ORGANIZER && $tournament->organize($_SESSION["user_id"]))) { ?>
<div class="alert alert-info"> <div class="alert alert-info">
<a href="mailto:contact@tfjm.org?<? foreach ($emails as $email) echo "bcc=" . $email . "&" ?>subject=TFJM² <?= $YEAR ?>" target="_blank">Envoyer un mail à toutes les personnes inscrites au tournoi</a> <a href="mailto:contact@tfjm.org?<? foreach ($emails as $email) echo "bcc=" . $email . "&" ?>subject=TFJM² <?= $YEAR ?>" target="_blank">Envoyer un mail à toutes les personnes inscrites au tournoi</a><br>
<a href="mailto:contact@tfjm.org?<? foreach ($emails_validated as $email) echo "bcc=" . $email . "&" ?>subject=TFJM² <?= $YEAR ?>" target="_blank">Envoyer un mail à toutes les personnes inscrites au tournoi dans une équipe validée</a>
</div> </div>
<a href="/tournoi/<?= $tournament->getName() ?>/modifier"><button class="btn btn-secondary btn-lg btn-block">Éditer le tournoi</button></a> <a href="/tournoi/<?= $tournament->getName() ?>/modifier"><button class="btn btn-secondary btn-lg btn-block">Éditer le tournoi</button></a>

View File

@ -6,7 +6,8 @@
<?php if ($_SESSION["role"] == Role::ADMIN) { ?> <?php if ($_SESSION["role"] == Role::ADMIN) { ?>
<div class="alert alert-info"> <div class="alert alert-info">
<a href="mailto:contact@tfjm.org?<? foreach ($emails as $email) echo "bcc=" . $email . "&" ?>subject=TFJM² <?= $YEAR ?>" target="_blank">Envoyer un mail à toutes les personnes inscrites au tournoi</a> <a href="mailto:contact@tfjm.org?<? foreach ($emails as $email) echo "bcc=" . $email . "&" ?>subject=TFJM² <?= $YEAR ?>" target="_blank">Envoyer un mail à toutes les personnes inscrites au tournoi</a><br>
<a href="mailto:contact@tfjm.org?<? foreach ($emails_validated as $email) echo "bcc=" . $email . "&" ?>subject=TFJM² <?= $YEAR ?>" target="_blank">Envoyer un mail à toutes les personnes inscrites au tournoi dans une équipe validée</a>
</div> </div>
<?php } ?> <?php } ?>