@ -49,6 +49,7 @@ class UserControler {
global $vues;
global $vues;
$p = $this->uMod->getUsername($_SESSION["user"]);
$p = $this->uMod->getUsername($_SESSION["user"]);
$listImg = $this->iMod->getAllImg() ;
// Pour les messages d'erreur
// Pour les messages d'erreur
$error_message = null;
$error_message = null;
@ -121,8 +122,7 @@ class UserControler {
* @throws RuntimeError
* @throws RuntimeError
* @throws LoaderError
* @throws LoaderError
*/
*/
public function continueQuiz(int $id_quiz, int $total_questions) : void
public function continueQuiz(int $id_quiz, int $total_questions) : void{
{
global $racine;
global $racine;
$score = $_SESSION['score'];
$score = $_SESSION['score'];
$_SESSION['no_question'] = Verification::verifChar( isset($_SESSION['no_question']) ? ($_SESSION['no_question'] + 1) : 1);
$_SESSION['no_question'] = Verification::verifChar( isset($_SESSION['no_question']) ? ($_SESSION['no_question'] + 1) : 1);
@ -140,8 +140,7 @@ class UserControler {
* @throws RuntimeError
* @throws RuntimeError
* @throws LoaderError
* @throws LoaderError
*/
*/
public function endQuiz(int $id_quiz, int $score) : void
public function endQuiz(int $id_quiz, int $score) : void{
{
global $vues,$co;
global $vues,$co;
$gw = new QuizGateway($co);
$gw = new QuizGateway($co);
@ -155,8 +154,7 @@ class UserControler {
require_once $vues['endQuiz'];
require_once $vues['endQuiz'];
}
}
public function CorrectAnswer() : bool
public function CorrectAnswer() : bool{
{
$answera = Verification::verifChar($_POST['answera'] ?? null);
$answera = Verification::verifChar($_POST['answera'] ?? null);
$answerb = Verification::verifChar($_POST['answerb'] ?? null);
$answerb = Verification::verifChar($_POST['answerb'] ?? null);
$answerc = Verification::verifChar($_POST['answerc'] ?? null);
$answerc = Verification::verifChar($_POST['answerc'] ?? null);
@ -182,8 +180,7 @@ class UserControler {
return $answer == $res->getCanswer();
return $answer == $res->getCanswer();
}
}
public function GetQuestion(int $id): array
public function GetQuestion(int $id): array{
{
global $co;
global $co;
$gw = new QuizQuestionGateway($co);
$gw = new QuizQuestionGateway($co);
$mdl = new QuizQuestionModel($gw);
$mdl = new QuizQuestionModel($gw);
@ -195,8 +192,7 @@ class UserControler {
* @throws SyntaxError
* @throws SyntaxError
* @throws LoaderError
* @throws LoaderError
*/
*/
public function showQuestion(int $id, int $num) : void
public function showQuestion(int $id, int $num) : void{
{
global $vues,$twig;
global $vues,$twig;
$q = $this->GetQuestion($id);
$q = $this->GetQuestion($id);
$question = $q[$num] ?? $q[0];
$question = $q[$num] ?? $q[0];
@ -208,8 +204,7 @@ class UserControler {
}
}
public function getNumberOfQuestion(int $id) : int
public function getNumberOfQuestion(int $id) : int{
{
global $co;
global $co;
$gw = new QuizGateway($co);
$gw = new QuizGateway($co);
$mdl = new QuizModel($gw);
$mdl = new QuizModel($gw);
@ -232,8 +227,8 @@ class UserControler {
}
}
// ===================== UPDATE DATA USER FUNCTION =====================
// ===================== UPDATE DATA USER FUNCTION =====================
public function changedata() : void{
public function changedata() : void{
global $vues, $racine;
global $vues, $racine;
if ($_POST)
if ($_POST)
@ -251,12 +246,13 @@ class UserControler {
}
}
else if($newEmail){//Modif l'email
else if($newEmail){//Modif l'email
$this->updateEmail($newEmail);
$this->updateEmail($newEmail);
$this->sendEmailChangeLogin($newEmail); //Envoie un email confirmant le changement d'email
}
}
else if($newMdpFirst & & $newMdpSecond){ //Modif le mot de passe
else if($newMdpFirst & & $newMdpSecond){ //Modif le mot de passe
$this->updatePassWd($oldPasswd, $newMdpFirst,$newMdpSecond);
$this->updatePassWd($oldPasswd, $newMdpFirst,$newMdpSecond);
}
}
else if($newImage){//Modif l'image
else if($newImage){//Modif l'image
$this->updateImg();
$this->updateImg($newImage );
}
}
}
}
header("Location: ". $racine."/profil");
header("Location: ". $racine."/profil");
@ -313,8 +309,8 @@ class UserControler {
}
}
}
}
public function updateImg(){
public function updateImg(string $newImage ){
$user = $this->uMod->setImage($_SESSION['user']);
$user = $this->uMod->setImage($_SESSION['user'],$newImage );
}
}
@ -328,8 +324,7 @@ class UserControler {
* @throws RuntimeError
* @throws RuntimeError
* @throws LoaderError
* @throws LoaderError
*/
*/
public function submit() : void
public function submit() : void{
{
global $vues;
global $vues;
$p = $this->caMod->getAllPerso();
$p = $this->caMod->getAllPerso();
$s = $this->srcMod->getAllSources();
$s = $this->srcMod->getAllSources();
@ -341,6 +336,7 @@ class UserControler {
* @throws RuntimeError
* @throws RuntimeError
* @throws LoaderError
* @throws LoaderError
*/
*/
public function toSubmit(string $content,string $character, string $source)
public function toSubmit(string $content,string $character, string $source)
{
{
global $co;
global $co;
@ -539,4 +535,21 @@ class UserControler {
public function questionSuivantAleatoire(){
public function questionSuivantAleatoire(){
}
}
public function sendEmailChangeLogin(string $email) : void{
$to = $email; // Adresse email de destination
$subject = "What The Fantasy - Changement d'Email"; // Sujet de l'email
$message = "
Bonjour,
L'adresse mail $email est désormais votre nouvelle adresse.
L'équipe du site
"; // Contenu de l'email
$headers = "From: noreply@whatTheFantasy.com"; // Adresse email de l'expéditeur
// Envoyer l'email
mail($to, $subject, $message, $headers);
}
}
}