Corrections dans les mails
This commit is contained in:
parent
95ab142702
commit
9e7a7308be
|
@ -51,7 +51,7 @@ class NewTeam {
|
||||||
$req = $DB->prepare("INSERT INTO `teams` (`name`, `trigram`, `tournament`, `encadrant_1`, `participant_1`, `validation_status`, `access_code`, `year`)
|
$req = $DB->prepare("INSERT INTO `teams` (`name`, `trigram`, `tournament`, `encadrant_1`, `participant_1`, `validation_status`, `access_code`, `year`)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?);");
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?);");
|
||||||
$req->execute([$this->name, $this->trigram, $this->tournament_id, $_SESSION["role"] == Role::ENCADRANT ? $_SESSION["user_id"] : NULL,
|
$req->execute([$this->name, $this->trigram, $this->tournament_id, $_SESSION["role"] == Role::ENCADRANT ? $_SESSION["user_id"] : NULL,
|
||||||
$_SESSION["role"] == Role::PARTICIPANT ? $_SESSION["user_id"] : NULL, ValidationStatus::NOT_READY, $this->access_code, $YEAR]);
|
$_SESSION["role"] == Role::PARTICIPANT ? $_SESSION["user_id"] : NULL, ValidationStatus::getName(ValidationStatus::NOT_READY), $this->access_code, $YEAR]);
|
||||||
|
|
||||||
$_SESSION["team"] = Team::fromTrigram($this->trigram);
|
$_SESSION["team"] = Team::fromTrigram($this->trigram);
|
||||||
$_SESSION["user"]->setTeamId($_SESSION["team"]->getId());
|
$_SESSION["user"]->setTeamId($_SESSION["team"]->getId());
|
||||||
|
|
|
@ -13,7 +13,13 @@ if ($team === null)
|
||||||
|
|
||||||
if (isset($_POST["validate"])) {
|
if (isset($_POST["validate"])) {
|
||||||
$team->setValidationStatus(ValidationStatus::VALIDATED);
|
$team->setValidationStatus(ValidationStatus::VALIDATED);
|
||||||
|
Mailer::sendValidateTeam($team, $_POST["message"]);
|
||||||
}
|
}
|
||||||
|
elseif (isset($_POST["unvalidate"])) {
|
||||||
|
$team->setValidationStatus(ValidationStatus::NOT_READY);
|
||||||
|
Mailer::sendUnvalidateTeam($team, $_POST["message"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (isset($_POST["select"])) {
|
if (isset($_POST["select"])) {
|
||||||
$team->selectForFinal(true);
|
$team->selectForFinal(true);
|
||||||
|
|
|
@ -41,8 +41,10 @@ else
|
||||||
if (isset($_POST["request_validation"])) {
|
if (isset($_POST["request_validation"])) {
|
||||||
if (!canValidate($team, $tournament))
|
if (!canValidate($team, $tournament))
|
||||||
$error_message = "Votre équipe ne peut pas demander la validation : il manque soit des participants, soit des documents.";
|
$error_message = "Votre équipe ne peut pas demander la validation : il manque soit des participants, soit des documents.";
|
||||||
else
|
else {
|
||||||
$team->setValidationStatus(ValidationStatus::WAITING);
|
$team->setValidationStatus(ValidationStatus::WAITING);
|
||||||
|
Mailer::sendRequestValidationMail($team, $team->isSelectedForFinal() ? $FINAL : $tournament);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyTeam
|
class MyTeam
|
||||||
|
|
|
@ -16,6 +16,56 @@ class Mailer
|
||||||
mail($email, $subject, $content, $headers);
|
mail($email, $subject, $content, $headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static function broadcastToTeam(Team $team, $subject, $content, $from = "contact")
|
||||||
|
{
|
||||||
|
$content = preg_replace("#{TEAM_NAME}#", $team->getName(), $content);
|
||||||
|
$content = preg_replace("#{TRIGRAM}#", $team->getTrigram(), $content);
|
||||||
|
|
||||||
|
foreach ($team->getEncadrants() as $participant_id) {
|
||||||
|
$participant = User::fromId($participant_id);
|
||||||
|
if ($participant == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$c = preg_replace("#{FIRST_NAME}#", $participant->getFirstName(), $content);
|
||||||
|
$c = preg_replace("#{SURNAME}#", $participant->getSurname(), $c);
|
||||||
|
self::sendMail($participant->getEmail(), $subject, $c, $from);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($team->getParticipants() as $participant_id) {
|
||||||
|
$participant = User::fromId($participant_id);
|
||||||
|
if ($participant == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$c = preg_replace("#{FIRST_NAME}#", $participant->getFirstName(), $content);
|
||||||
|
$c = preg_replace("#{SURNAME}#", $participant->getSurname(), $c);
|
||||||
|
self::sendMail($participant->getEmail(), $subject, $c, $from);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function broadcastToAdmins($subject, $content, $from = "contact")
|
||||||
|
{
|
||||||
|
/** @var User $admin */
|
||||||
|
foreach (User::getAdmins() as $admin) {
|
||||||
|
$c = preg_replace("#{FIRST_NAME}#", $admin->getFirstName(), $content);
|
||||||
|
$c = preg_replace("#{SURNAME}#", $admin->getSurname(), $c);
|
||||||
|
self::sendMail($admin->getEmail(), $subject, $c, $from);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function brodcastToOrgas(Tournament $tournament, $subject, $content, $from = "contact")
|
||||||
|
{
|
||||||
|
foreach ($tournament->getOrganizers() as $orga) {
|
||||||
|
if ($orga->getRole() == Role::ADMIN)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$c = preg_replace("#{FIRST_NAME}#", $orga->getFirstName(), $content);
|
||||||
|
$c = preg_replace("#{SURNAME}#", $orga->getSurname(), $c);
|
||||||
|
self::sendMail($orga->getEmail(), $subject, $c, $from);
|
||||||
|
}
|
||||||
|
|
||||||
|
self::broadcastToAdmins($subject, $content, $from);
|
||||||
|
}
|
||||||
|
|
||||||
private static function getTemplate($name)
|
private static function getTemplate($name)
|
||||||
{
|
{
|
||||||
global $LOCAL_PATH;
|
global $LOCAL_PATH;
|
||||||
|
@ -146,11 +196,46 @@ class Mailer
|
||||||
else
|
else
|
||||||
$content = preg_replace("#{PAYMENT_INFOS}#", $payment->getTransactionInfos(), $content);
|
$content = preg_replace("#{PAYMENT_INFOS}#", $payment->getTransactionInfos(), $content);
|
||||||
|
|
||||||
foreach (User::getAdmins() as $admin) {
|
self::broadcastToAdmins("Demande de validation de paiement pour le tournoi " . $tournament->getName() . " – TFJM² $YEAR", $content);
|
||||||
$content = preg_replace("#{FIRST_NAME}#", $admin->getFirstName(), $content);
|
}
|
||||||
$content = preg_replace("#{SURNAME}#", $admin->getSurname(), $content);
|
|
||||||
self::sendMail($admin->getEmail(), "Demande de validation de paiement pour le tournoi " . $tournament->getName() . " – TFJM² $YEAR", $content);
|
public static function sendRequestValidationMail(Team $team, Tournament $tournament)
|
||||||
}
|
{
|
||||||
|
global $YEAR;
|
||||||
|
|
||||||
|
$content = self::getTemplate("request_validation");
|
||||||
|
$content = preg_replace("#{TEAM_NAME}#", $team->getName(), $content);
|
||||||
|
$content = preg_replace("#{TRIGRAM}#", $team->getTrigram(), $content);
|
||||||
|
$content = preg_replace("#{TOURNAMENT}#", $tournament->getName(), $content);
|
||||||
|
$content = preg_replace("#{ACCESS_CODE}#", $team->getAccessCode(), $content);
|
||||||
|
|
||||||
|
self::brodcastToOrgas($tournament, "Demande de validation – Correspondances des Jeunes Mathématicien·ne·s $YEAR - " . ($YEAR + 1), $content);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function sendValidateTeam($team, $message)
|
||||||
|
{
|
||||||
|
global $YEAR;
|
||||||
|
|
||||||
|
$content = self::getTemplate("validate_team");
|
||||||
|
if (strlen($message) > 0)
|
||||||
|
$message = " L'équipe d'organisation vous transmet le message suivant :\n\n" . $message;
|
||||||
|
$message = preg_replace("#\n#", "<br/>\n", $message);
|
||||||
|
$content = preg_replace("#{MESSAGE}#", $message, $content);
|
||||||
|
|
||||||
|
self::broadcastToTeam($team, "Équipe validée – Correspondances des Jeunes Mathématicien·ne·s $YEAR - " . ($YEAR + 1), $content);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function sendUnvalidateTeam($team, $message)
|
||||||
|
{
|
||||||
|
global $YEAR;
|
||||||
|
|
||||||
|
$content = self::getTemplate("unvalidate_team");
|
||||||
|
if (strlen($message) > 0)
|
||||||
|
$message = " L'équipe d'organisation vous transmet le message suivant :\n\n" . $message;
|
||||||
|
$message = preg_replace("#\n#", "<br/>\n", $message);
|
||||||
|
$content = preg_replace("#{MESSAGE}#", $message, $content);
|
||||||
|
|
||||||
|
self::broadcastToTeam($team, "Équipe non validée – Correspondances des Jeunes Mathématicien·ne·s $YEAR - " . ($YEAR + 1), $content);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function sendValidatePayment(User $user, Team $team, Tournament $tournament, Payment $payment, $message)
|
public static function sendValidatePayment(User $user, Team $team, Tournament $tournament, Payment $payment, $message)
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<!--suppress HtmlUnknownTarget -->
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Demande de validation - TFJM²</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
Bonjour {FIRST_NAME} {SURNAME},<br />
|
||||||
|
<br />
|
||||||
|
L'équipe « {TEAM_NAME} » ({TRIGRAM}) vient de demander à valider son équipe pour participer au tournoi {TOURNAMENT} du
|
||||||
|
TFJM². Vous pouvez décider d'accepter ou de refuser l'équipe en vous rendant sur la page de l'équipe :
|
||||||
|
<a href="{URL_BASE}/equipe/{TRIGRAM}">{URL_BASE}/equipe/{TRIGRAM}</a><br/>
|
||||||
|
<br/>
|
||||||
|
Cordialement,<br/>
|
||||||
|
<br />
|
||||||
|
Le comité national d'organisation du TFJM<sup>2</sup>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,19 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Équipe non validée – TFJM² {YEAR}</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
Bonjour {FIRST_NAME} {SURNAME},<br/>
|
||||||
|
<br/>
|
||||||
|
Maleureusement, votre équipe « {TEAM_NAME} » ({TRIGRAM}) n'a pas été validée. Veuillez vérifier que vos autorisations sont correctes.
|
||||||
|
{MESSAGE}<br />
|
||||||
|
<br />
|
||||||
|
N'hésitez pas à nous contacter à l'adresse <a href="contact@tfjm.org">contact@tfjm.org</a> pour plus d'informations.
|
||||||
|
<br/>
|
||||||
|
Cordialement,<br/>
|
||||||
|
<br/>
|
||||||
|
Le comité national d'organisation du TFJM<sup>2</sup>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,18 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Équipe validée – Correspondances des Jeunes Mathématicien·ne·s {YEAR}</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
Bonjour {FIRST_NAME} {SURNAME},<br/>
|
||||||
|
<br/>
|
||||||
|
Félicitations ! Votre équipe « {TEAM_NAME} » ({TRIGRAM}) est désormais validée ! Vous êtes désormais apte à travailler sur
|
||||||
|
votre problème. Lorsque les Correspondances auront débutées, vous pourrez soumettre votre vidéo sur la plateforme d'inscription.
|
||||||
|
{MESSAGE}<br />
|
||||||
|
<br/>
|
||||||
|
Cordialement,<br/>
|
||||||
|
<br/>
|
||||||
|
Le comité national d'organisation du TFJM<sup>2</sup>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue