mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-06-26 04:37:37 +02:00
Utilisation des nouvelles classes, amélioration du code
This commit is contained in:
@ -27,6 +27,7 @@ class User
|
||||
private $year;
|
||||
private $confirm_email;
|
||||
private $forgotten_password;
|
||||
private $inscription_date;
|
||||
|
||||
private function __construct() {}
|
||||
|
||||
@ -38,7 +39,7 @@ class User
|
||||
$data = $req->fetch();
|
||||
|
||||
if ($data === false)
|
||||
throw new InvalidArgumentException("L'utilisateur spécifié n'existe pas.");
|
||||
return null;
|
||||
|
||||
$user = new User();
|
||||
$user->fill($data);
|
||||
@ -53,7 +54,7 @@ class User
|
||||
$data = $req->fetch();
|
||||
|
||||
if ($data === false)
|
||||
throw new InvalidArgumentException("L'utilisateur spécifié n'existe pas.");
|
||||
return null;
|
||||
|
||||
$user = new User();
|
||||
$user->fill($data);
|
||||
@ -85,6 +86,7 @@ class User
|
||||
$this->year = $data["year"];
|
||||
$this->confirm_email = $data["confirm_email"];
|
||||
$this->forgotten_password = $data["forgotten_password"];
|
||||
$this->inscription_date = $data["inscription_date"];
|
||||
}
|
||||
|
||||
public function getEmail()
|
||||
@ -166,7 +168,7 @@ class User
|
||||
{
|
||||
global $DB;
|
||||
$this->gender = $gender;
|
||||
$DB->prepare("UPDATE `users` SET `email` = ? WHERE `id` = ?;")->execute([$gender, $this->getId()]);
|
||||
$DB->prepare("UPDATE `users` SET `gender` = ? WHERE `id` = ?;")->execute([$gender, $this->getId()]);
|
||||
}
|
||||
|
||||
public function getAddress()
|
||||
@ -311,7 +313,7 @@ class User
|
||||
global $DB;
|
||||
$this->role = $role;
|
||||
/** @noinspection PhpUndefinedMethodInspection */
|
||||
$DB->prepare("UPDATE `users` SET `email` = ? WHERE `id` = ?;")->execute([$role->getName(), $this->getId()]);
|
||||
$DB->prepare("UPDATE `users` SET `role` = ? WHERE `id` = ?;")->execute([Role::getName($role), $this->getId()]);
|
||||
}
|
||||
|
||||
public function getTeamId()
|
||||
@ -354,4 +356,9 @@ class User
|
||||
$this->forgotten_password = $token;
|
||||
$DB->prepare("UPDATE `users` SET `forgotten_password` = ? WHERE `id` = ?;")->execute([$token, $this->getId()]);
|
||||
}
|
||||
|
||||
public function getInscriptionDate()
|
||||
{
|
||||
return $this->inscription_date;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user