mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2025-07-06 18:54:00 +02:00
Adaptation de la plateforme aux besoins des correspondances (en cours)
This commit is contained in:
@ -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()) {
|
||||
|
Reference in New Issue
Block a user