mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2025-07-02 02:38:30 +02:00
Adaptation de la plateforme aux besoins des correspondances (en cours)
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@ if (!isset($_SESSION["user_id"]) || $_SESSION["role"] != Role::ORGANIZER && $_SE
|
||||
$trigram = htmlspecialchars($_GET["trigram"]);
|
||||
|
||||
$team = Team::fromTrigram($trigram);
|
||||
$tournament = Tournament::fromId($team->getTournamentId());
|
||||
|
||||
if ($team === null)
|
||||
require_once "server_files/404.php";
|
||||
@ -15,29 +14,10 @@ if (isset($_POST["validate"])) {
|
||||
$team->setValidationStatus(ValidationStatus::VALIDATED);
|
||||
}
|
||||
|
||||
if (isset($_POST["select"])) {
|
||||
$team->selectForFinal(true);
|
||||
$team->setValidationStatus(ValidationStatus::NOT_READY);
|
||||
$sols = $tournament->getAllSolutions($team->getId());
|
||||
/** @var Solution $sol */
|
||||
foreach ($sols as $sol) {
|
||||
$old_id = $sol->getFileId();
|
||||
do
|
||||
$id = genRandomPhrase(64);
|
||||
while (file_exists("$LOCAL_PATH/files/$id"));
|
||||
|
||||
copy("$LOCAL_PATH/files/$old_id", "$LOCAL_PATH/files/$id");
|
||||
|
||||
$req = $DB->prepare("INSERT INTO `solutions`(`file_id`, `team`, `tournament`, `problem`) VALUES (?, ?, ?, ?);");
|
||||
$req->execute([$id, $team->getId(), $FINAL->getId(), $sol->getFileId()]);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST["download_zip"])) {
|
||||
$final = isset($_POST["final"]);
|
||||
$tournament_dest = $final ? $FINAL : $tournament;
|
||||
|
||||
$file_name = getZipFile(DocumentType::PARENTAL_CONSENT, $tournament_dest->getId(), $team->getId());
|
||||
$file_name = getZipFile(DocumentType::PARENTAL_CONSENT, $tournament->getId(), $team->getId());
|
||||
|
||||
header("Content-Type: application/zip");
|
||||
header("Content-Disposition: attachment; filename=\"Documents de l'équipe " . $team->getTrigram() . ".zip\"");
|
||||
@ -51,7 +31,4 @@ if (isset($_POST["download_zip"])) {
|
||||
$documents = $tournament->getAllDocuments($team->getId());
|
||||
$documents_final = null;
|
||||
|
||||
if ($team->isSelectedForFinal())
|
||||
$documents_final = $FINAL->getAllDocuments($team->getId());
|
||||
|
||||
require_once "server_files/views/equipe.php";
|
||||
|
@ -15,12 +15,9 @@ if ($user === null)
|
||||
require_once "server_files/404.php";
|
||||
|
||||
$team = Team::fromId($user->getTeamId());
|
||||
$tournaments = $user->getOrganizedTournaments();
|
||||
|
||||
if ($team != null) {
|
||||
$documents = $user->getAllDocuments($team->getTournamentId());
|
||||
if ($team->isSelectedForFinal())
|
||||
$documents_final = $user->getAllDocuments($FINAL->getId());
|
||||
//$documents = $user->getAllDocuments($team->getTournamentId());
|
||||
}
|
||||
|
||||
require_once "server_files/views/informations.php";
|
||||
|
@ -20,19 +20,10 @@ class NewUser
|
||||
public $email;
|
||||
public $first_name;
|
||||
public $surname;
|
||||
public $birth_date;
|
||||
public $gender;
|
||||
public $address = "";
|
||||
public $postal_code;
|
||||
public $city = "";
|
||||
public $country;
|
||||
public $phone_number;
|
||||
public $role;
|
||||
public $school;
|
||||
public $class;
|
||||
public $responsible_name;
|
||||
public $responsible_phone;
|
||||
public $responsible_email;
|
||||
|
||||
public $description;
|
||||
public $confirm_email_token;
|
||||
private $password;
|
||||
@ -46,8 +37,6 @@ class NewUser
|
||||
|
||||
public function makeVerifications()
|
||||
{
|
||||
global $YEAR;
|
||||
|
||||
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.");
|
||||
@ -55,23 +44,10 @@ class NewUser
|
||||
ensure($this->password == $this->confirm_password, "Les deux mots de passe sont différents.");
|
||||
ensure($this->surname != "", "Le nom de famille est obligatoire.");
|
||||
ensure($this->first_name != "", "Le prénom est obligatoire.");
|
||||
ensure(dateWellFormed($this->birth_date), "La date de naissance est invalide.");
|
||||
ensure($this->birth_date < $YEAR . "-01-01", "Vous devez être né.");
|
||||
ensure($this->gender == "M" || $this->gender == "F", "Le sexe indiqué est invalide.");
|
||||
ensure(preg_match("#^[0-9]{4}[0-9]?$#", $this->postal_code) && intval($this->postal_code) >= 01000 && intval($this->postal_code) <= 95999, "Le code postal est invalide.");
|
||||
if ($this->country == "")
|
||||
$this->country = "France";
|
||||
ensure(strlen($this->phone_number) >= 10, "Le numéro de téléphone est invalide.");
|
||||
$this->role = Role::fromName(strtoupper($this->role));
|
||||
|
||||
if ($this->role == Role::PARTICIPANT) {
|
||||
if ($this->role == Role::PARTICIPANT)
|
||||
$this->class = SchoolClass::fromName(strtoupper($this->class));
|
||||
if ($this->birth_date > strval($YEAR - 18) . "04-01") {
|
||||
ensure($this->responsible_name != "", "Veuillez spécifier un responsable légal.");
|
||||
ensure(strlen($this->responsible_phone) >= 10, "Veuillez rentrer le numéro de téléphone de votre responsable légal.");
|
||||
ensure(filter_var($this->responsible_email, FILTER_VALIDATE_EMAIL), "Veuillez spécifier un responsable légal.");
|
||||
}
|
||||
}
|
||||
|
||||
$this->confirm_email_token = genRandomPhrase(64);
|
||||
}
|
||||
@ -80,11 +56,10 @@ class NewUser
|
||||
{
|
||||
global $DB, $YEAR;
|
||||
|
||||
$req = $DB->prepare("INSERT INTO `users`(`email`, `pwd_hash`, `confirm_email`, `surname`, `first_name`, `birth_date`, `gender`,
|
||||
`address`, `postal_code`, `city`, `country`, `phone_number`, `school`, `class`, `role`, `description`, `year`)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
|
||||
$req->execute([$this->email, password_hash($this->password, PASSWORD_BCRYPT), $this->confirm_email_token, $this->surname, $this->first_name, $this->birth_date, $this->gender, $this->address,
|
||||
$this->postal_code, $this->city, $this->country, $this->phone_number, $this->school, SchoolClass::getName($this->class), Role::getName($this->role), $this->description, $YEAR]);
|
||||
$req = $DB->prepare("INSERT INTO `users`(`email`, `pwd_hash`, `confirm_email`, `surname`, `first_name`, `school`, `class`, `role`, `description`, `year`)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
|
||||
$req->execute([$this->email, password_hash($this->password, PASSWORD_BCRYPT), $this->confirm_email_token, $this->surname, $this->first_name,
|
||||
$this->school, SchoolClass::getName($this->class), Role::getName($this->role), $this->description, $YEAR]);
|
||||
|
||||
Mailer::sendRegisterMail($this);
|
||||
}
|
||||
|
@ -38,18 +38,8 @@ class MyAccount
|
||||
public $email;
|
||||
public $surname;
|
||||
public $first_name;
|
||||
public $birth_date;
|
||||
public $gender;
|
||||
public $address;
|
||||
public $postal_code;
|
||||
public $city;
|
||||
public $country;
|
||||
public $phone_number;
|
||||
public $school;
|
||||
public $class;
|
||||
public $responsible_name;
|
||||
public $responsible_phone;
|
||||
public $responsible_email;
|
||||
public $description;
|
||||
private $user;
|
||||
|
||||
@ -60,8 +50,7 @@ class MyAccount
|
||||
|
||||
$this->user = $_SESSION["user"];
|
||||
|
||||
$keys = ["email", "surname", "first_name", "birth_date", "gender", "address", "postal_code", "city", "country", "phone_number",
|
||||
"school", "class", "responsible_name", "responsible_phone", "responsible_email", "description"];
|
||||
$keys = ["email", "surname", "first_name", "school", "class", "description"];
|
||||
|
||||
if ($this->user->getRole() == Role::PARTICIPANT)
|
||||
$this->class = SchoolClass::fromName($this->class);
|
||||
@ -72,42 +61,17 @@ class MyAccount
|
||||
|
||||
public function makeVerifications()
|
||||
{
|
||||
global $YEAR;
|
||||
|
||||
ensure(filter_var($this->email, FILTER_VALIDATE_EMAIL), "L'adresse e-mail entrée est invalide.");
|
||||
$this->email = strtolower($this->email);
|
||||
ensure($this->email == $this->user->getEmail() || !userExists($this->email), "Un compte existe déjà avec cette adresse e-mail.");
|
||||
ensure(dateWellFormed($this->birth_date), "La date de naissance est invalide.");
|
||||
ensure($this->birth_date < $YEAR . "-01-01", "Vous devez être né.");
|
||||
ensure($this->gender == "M" || $this->gender == "F", "Le sexe indiqué est invalide.");
|
||||
ensure(preg_match("#^[0-9]{4}[0-9]?$#", $this->postal_code) && intval($this->postal_code) >= 01000 && intval($this->postal_code) <= 95999, "Le code postal est invalide.");
|
||||
ensure(strlen($this->phone_number) >= 10, "Le numéro de téléphone est invalide.");
|
||||
|
||||
if ($this->user->getRole() == Role::PARTICIPANT) {
|
||||
if ($this->birth_date > strval($YEAR - 18) . "04-01") {
|
||||
ensure($this->responsible_name != "", "Veuillez spécifier un responsable légal.");
|
||||
ensure(strlen($this->responsible_phone) >= 10, "Veuillez rentrer le numéro de téléphone de votre responsable légal.");
|
||||
ensure(filter_var($this->responsible_email, FILTER_VALIDATE_EMAIL), "Veuillez spécifier un responsable légal.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function updateAccount()
|
||||
{
|
||||
$this->user->setSurname($this->surname);
|
||||
$this->user->setFirstName($this->first_name);
|
||||
$this->user->setBirthDate($this->birth_date);
|
||||
$this->user->setGender($this->gender);
|
||||
$this->user->setAddress($this->address);
|
||||
$this->user->setPostalCode($this->postal_code);
|
||||
$this->user->setCity($this->city);
|
||||
$this->user->setCountry($this->country);
|
||||
$this->user->setPhoneNumber($this->phone_number);
|
||||
$this->user->setSchool($this->school);
|
||||
$this->user->setClass($this->class);
|
||||
$this->user->setResponsibleName($this->responsible_name);
|
||||
$this->user->setResponsiblePhone($this->responsible_phone);
|
||||
$this->user->setResponsibleEmail($this->responsible_email);
|
||||
$this->user->setDescription($this->description);
|
||||
|
||||
if ($this->email != $this->user->getEmail()) {
|
||||
|
@ -5,8 +5,6 @@ if (isset($_POST["leave_team"])) {
|
||||
exit();
|
||||
}
|
||||
|
||||
$tournaments = Tournament::getAllTournaments(false, true);
|
||||
|
||||
$has_error = false;
|
||||
$error_message = null;
|
||||
|
||||
@ -49,10 +47,7 @@ if (isset($_SESSION["user_id"]) && isset($_SESSION["team"]) && $_SESSION["team"]
|
||||
$user = $_SESSION["user"];
|
||||
$team = $_SESSION["team"];
|
||||
|
||||
$tournament = Tournament::fromId($team->getTournamentId());
|
||||
$documents = $user->getAllDocuments($team->getTournamentId());
|
||||
if ($team->isSelectedForFinal())
|
||||
$documents_final = $user->getAllDocuments($FINAL->getId());
|
||||
//$documents = $user->getAllDocuments($team->getTournamentId());
|
||||
}
|
||||
else
|
||||
require_once "server_files/403.php";
|
||||
|
Reference in New Issue
Block a user