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 = [];
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();
}
}
}

View File

@ -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();
}
}
}
}
}
}

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"]))) { ?>
<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>
<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) { ?>
<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>
<?php } ?>