1
0
mirror of https://gitlab.com/animath/si/plateforme-corres2math.git synced 2025-06-25 18:57:23 +02:00

Adaptation de la plateforme aux besoins des correspondances (en cours)

This commit is contained in:
galaxyoyo
2019-09-11 01:17:05 +02:00
parent e908ad1923
commit 07e7b94f5c
18 changed files with 65 additions and 520 deletions

View File

@ -3,8 +3,6 @@
if (!isset($_SESSION["role"]) || ($_SESSION["role"] != Role::PARTICIPANT && $_SESSION["role"] != Role::ENCADRANT))
require_once "server_files/403.php";
$tournaments_response = $DB->query("SELECT `id`, `name` FROM `tournaments` WHERE `date_inscription` > CURRENT_DATE AND `year` = '$YEAR';");
$has_error = false;
$error_message = null;
@ -23,8 +21,7 @@ if (isset($_POST["submitted"])) {
class NewTeam {
public $name;
public $trigram;
public $tournament_id;
public $tournament;
public $problem;
public $access_code;
public function __construct($data)
@ -39,8 +36,7 @@ class NewTeam {
ensure(preg_match("#^[A-Z]{3}$#", $this->trigram), "Le trigramme entré n'est pas valide.");
ensure(!teamExists($this->name), "Une équipe existe déjà avec ce nom.");
ensure(!trigramExists($this->trigram), "Une équipe a déjà choisi ce trigramme.");
$this->tournament = Tournament::fromId($this->tournament_id);
ensure($this->tournament != null, "Le tournoi spécifié n'existe pas.");
ensure(preg_match("#[1-4]#", $this->problem), "Le problème choisi n'a pas été reconnu.");
}
public function register() {
@ -48,15 +44,15 @@ class NewTeam {
$this->access_code = genRandomPhrase(6);
$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`, `problem`, `encadrant`, `participant_1`, `validation_status`, `access_code`, `year`)
VALUES (?, ?, ?, ?, ?, ?, ?, ?);");
$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]);
$req->execute([$this->name, $this->trigram, $this->problem, $_SESSION["role"] == Role::ENCADRANT ? $_SESSION["user_id"] : NULL,
$_SESSION["role"] == Role::PARTICIPANT ? $_SESSION["user_id"] : NULL, ValidationStatus::getName(ValidationStatus::NOT_READY), $this->access_code, $YEAR]);
$_SESSION["team"] = Team::fromTrigram($this->trigram);
$_SESSION["user"]->setTeamId($_SESSION["team"]->getId());
Mailer::sendAddTeamMail($_SESSION["user"], $_SESSION["team"], $this->tournament);
Mailer::sendAddTeamMail($_SESSION["user"], $_SESSION["team"], $this->problem);
}
}