1
0
mirror of https://gitlab.com/animath/si/plateforme-corres2math.git synced 2025-06-25 07:40:29 +02:00

Nombreux changements mineurs

This commit is contained in:
Yohann
2019-10-04 22:36:23 +02:00
parent 7eba8b542b
commit 57b8f7bdfe
13 changed files with 142 additions and 43 deletions

View File

@ -22,6 +22,7 @@ class NewTeam {
public $name;
public $trigram;
public $problem;
public $allow_other_teams;
public $allow_publish;
public $access_code;
@ -32,6 +33,7 @@ class NewTeam {
$this->trigram = strtoupper($this->trigram);
$this->allow_other_teams = $this->allow_other_teams == "on" ? 1 : 0;
$this->allow_publish = $this->allow_publish == "on" ? 1 : 0;
}
@ -41,11 +43,12 @@ class NewTeam {
ensure(date("Y-m-d H:i:s") < $CONFIG->getInscriptionDate(), "La date limite d'inscription est dépassée.");
ensure($_SESSION["team"] == null, "Vous êtes déjà dans une équipe.");
ensure($this->name != null && $this->name != "", "Vous devez spécifier un nom d'équipe.");
ensure(preg_match("#^[\p{L} ]+$#ui", $this->name), "Le nom de l'équipe ne doit pas comporter de caractères spéciaux.");
ensure(preg_match("#^[\p{L} \d]+$#ui", $this->name), "Le nom de l'équipe ne doit pas comporter de caractères spéciaux.");
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.");
ensure(preg_match("#[0-4]#", $this->problem), "Le problème choisi n'a pas été reconnu.");
ensure($this->allow_other_teams, "Vous devez autoriser de diffuser vos vidéos aux autres équipes participantes pour pouvoir participer.");
}
public function register() {

View File

@ -22,6 +22,8 @@ class NewUser
public $surname;
public $role;
public $school;
public $city;
public $country;
public $class;
public $receive_animath_mails;
@ -66,10 +68,12 @@ class NewUser
if (!$DB->query("SELECT `id` FROM `users` WHERE `year` = $YEAR;")->fetch())
$this->role = Role::ADMIN;
$req = $DB->prepare("INSERT INTO `users`(`email`, `pwd_hash`, `confirm_email`, `surname`, `first_name`, `school`, `class`, `role`, `description`, `receive_animath_mails`, `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, $this->receive_animath_mails, $YEAR]);
$req = $DB->prepare("INSERT INTO `users`(`email`, `pwd_hash`, `confirm_email`, `surname`, `first_name`,
`school`, `city`, `country`, `class`, `role`, `description`, `receive_animath_mails`, `year`)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
$req->execute([$this->email, password_hash($this->password, PASSWORD_BCRYPT), $this->confirm_email_token,
$this->surname, $this->first_name, $this->school, $this->city, $this->country, SchoolClass::getName($this->class),
Role::getName($this->role), $this->description, $this->receive_animath_mails, $YEAR]);
Mailer::sendRegisterMail($this);
}

View File

@ -52,6 +52,8 @@ class MyAccount
public $surname;
public $first_name;
public $school;
public $city;
public $country;
public $class;
public $description;
public $receive_animath_mails;
@ -89,6 +91,8 @@ class MyAccount
$this->user->setSurname($this->surname);
$this->user->setFirstName($this->first_name);
$this->user->setSchool($this->school);
$this->user->setCity($this->city);
$this->user->setCountry($this->country);
$this->user->setClass($this->class);
$this->user->setDescription($this->description);
$this->user->setReceiveAnimathMails($this->receive_animath_mails);

View File

@ -78,7 +78,7 @@ class MyTeam
ensure($this->name != "" && $this->name != null, "Veuillez spécifier un nom d'équipe.");
ensure($this->name == $this->team->getName() || !teamExists($this->name), "Une équipe existe déjà avec ce nom.");
ensure(preg_match("#^[\p{L} ]+$#ui", $this->name), "Le nom de l'équipe ne doit pas comporter de caractères spéciaux.");
ensure(preg_match("#^[\p{L} \d]+$#ui", $this->name), "Le nom de l'équipe ne doit pas comporter de caractères spéciaux.");
ensure(preg_match("#^[A-Z]{3}$#", $this->trigram), "Le trigramme n'est pas valide.");
ensure($this->trigram == $this->team->getTrigram() || !trigramExists($this->trigram), "Une équipe a déjà choisi ce trigramme.");
ensure(preg_match("#^[0-4]$#", $this->problem), "Le problème indiqué n'existe pas.");