Quelques modifications

This commit is contained in:
galaxyoyo 2019-09-07 17:26:30 +02:00
parent 70cece8694
commit 945e1105b8
4 changed files with 27 additions and 9 deletions

View File

@ -59,7 +59,7 @@ class NewTeam {
$_SESSION["team"] = Team::fromTrigram($this->trigram); $_SESSION["team"] = Team::fromTrigram($this->trigram);
$_SESSION["user"]->setTeamId($_SESSION["team"]->getId()); $_SESSION["user"]->setTeamId($_SESSION["team"]->getId());
sendAddTeam($_SESSION["user"], $_SESSION["team"], $this->tournament); sendAddTeamMail($_SESSION["user"], $_SESSION["team"], $this->tournament);
} }
} }

View File

@ -49,6 +49,7 @@ class NewUser
global $YEAR; global $YEAR;
ensure(filter_var($this->email, FILTER_VALIDATE_EMAIL), "L'adresse e-mail entrée est invalide."); ensure(filter_var($this->email, FILTER_VALIDATE_EMAIL), "L'adresse e-mail entrée est invalide.");
$this->email = strtolower($this->email);
ensure(userExists($this->email), "Un compte existe déjà avec cette adresse e-mail."); ensure(userExists($this->email), "Un compte existe déjà avec cette adresse e-mail.");
ensure(strlen($this->password) >= 8, "Le mot de passe doit comporter au moins 8 caractères."); ensure(strlen($this->password) >= 8, "Le mot de passe doit comporter au moins 8 caractères.");
ensure($this->password == $this->confirm_password, "Les deux mots de passe sont différents."); ensure($this->password == $this->confirm_password, "Les deux mots de passe sont différents.");

View File

@ -1,17 +1,17 @@
<?php <?php
if (isset($_POST["submitted"])) {
$error_message = updateAccount();
} elseif (isset($_POST["submitted_password"])) {
$error_message = updatePassword();
}
if (!isset($_SESSION["user_id"])) if (!isset($_SESSION["user_id"]))
require_once "server_files/403.php"; require_once "server_files/403.php";
/** @var User $user */ /** @var User $user */
$user = $_SESSION["user"]; $user = $_SESSION["user"];
if (isset($_POST["submitted"])) {
$error_message = updateAccount();
} elseif (isset($_POST["submitted_password"])) {
$error_message = updatePassword();
}
function updateAccount() function updateAccount()
{ {
global $URL_BASE, $MAIL_ADDRESS, $user; global $URL_BASE, $MAIL_ADDRESS, $user;

View File

@ -34,7 +34,7 @@ function sendRegisterMail($new_user)
* @param $team Team * @param $team Team
* @param $tournament Tournament * @param $tournament Tournament
*/ */
function sendAddTeam($user, $team, $tournament) function sendAddTeamMail($user, $team, $tournament)
{ {
global $LOCAL_PATH, $YEAR; global $LOCAL_PATH, $YEAR;
@ -45,4 +45,21 @@ function sendAddTeam($user, $team, $tournament)
$content = preg_replace("#{TRIGRAM}#", $team->getTrigram(), $content); $content = preg_replace("#{TRIGRAM}#", $team->getTrigram(), $content);
$content = preg_replace("#{TOURNAMENT_NAME}#", $tournament->getName(), $content); $content = preg_replace("#{TOURNAMENT_NAME}#", $tournament->getName(), $content);
$content = preg_replace("#{ACCESS_CODE}#", $team->getAccessCode(), $content); $content = preg_replace("#{ACCESS_CODE}#", $team->getAccessCode(), $content);
sendMail($user->getEmail(), "Ajout d'une équipe TFJM² $YEAR", $content);
}
/**
* @param NewUser
*/
function sendAddOrganizerMail($new_orga)
{
global $LOCAL_PATH, $YEAR;
$content = file_get_contents("$LOCAL_PATH/server_files/services/mail_templates/add_organizer.html");
$content = preg_replace("#{FIRST_NAME}#", $new_orga->first_name, $content);
$content = preg_replace("#{SURNAME}#", $new_orga->surname, $content);
$content = preg_replace("#{PASSWORD}#", $new_orga->password, $content);
sendMail($new_orga->email, "Inscription au TFJM² $YEAR", $content);
} }