From bf668612f461eb88ba5fe5b6cbe99f59eac94eee Mon Sep 17 00:00:00 2001 From: "johan.lachenal" Date: Wed, 23 Nov 2022 21:41:06 +0100 Subject: [PATCH] =?UTF-8?q?Changement=20de=20joueur=20et=20admin=20en=20ut?= =?UTF-8?q?ilisateur=20ajout=20du=20booleen=20est=20admin=20dans=20la=20bd?= =?UTF-8?q?d=20et=20le=20code=20php=20ajout=20de=20la=20methode=20resoudre?= =?UTF-8?q?Enigme=20et=20calcul=20des=20points=20effectu=C3=A9=20dans=20ce?= =?UTF-8?q?lle-ci?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WEB/Controller/PartieGateway.php | 15 +------ WEB/Controller/UserController.php | 14 +++++++ WEB/Model/Admin.php | 67 ------------------------------- WEB/Model/Utilisateur.php | 22 ++++++++++ 4 files changed, 38 insertions(+), 80 deletions(-) delete mode 100644 WEB/Model/Admin.php diff --git a/WEB/Controller/PartieGateway.php b/WEB/Controller/PartieGateway.php index 355955c1..6160c77a 100644 --- a/WEB/Controller/PartieGateway.php +++ b/WEB/Controller/PartieGateway.php @@ -51,22 +51,11 @@ class PartieGateway AND c.enigme = e.id"; $this->con->executeQuery($query); $listeEnigme=$this->con->getResults(); - $listePartie=PartieFactory::createPartie($max,$listeEnigme); + $listePartie[]=PartieFactory::createPartie($max,$listeEnigme); } return $listePartie; } - - public function findOldListeEnigme(string $partie) : array{ - $query= "SELECT * FROM Enigme e,Contenir c - AND c.partie = :idPartie - AND c.enigme = e.id"; - $this->con->executeQuery($query, array(':idPartie' => array( - ':idPartie' => array($partie, PDO::PARAM_STR), - ))); - $results=$this->con->getResults(); - $tabEnigme=EnigmeFactory::create($results); - return $tabEnigme; - } + public function showAll() : void{ $query= "SELECT * FROM Partie"; $this->con->executeQuery($query); diff --git a/WEB/Controller/UserController.php b/WEB/Controller/UserController.php index 29dd807d..f4df147a 100644 --- a/WEB/Controller/UserController.php +++ b/WEB/Controller/UserController.php @@ -66,13 +66,22 @@ class UserController throw(new Exception("Mot de passe non valide")); } $j = $gateway->getUtilisateurByEmail($_REQUEST['email']); +<<<<<<< HEAD:WEB/Controller/UserController.php if ($j->getEmail() != "null") { +======= + if ($j != null) { +>>>>>>> d82ece50 (Changement de joueur et admin):WEB/Controller/Controller.php $error = "Email déjà utilisé."; throw (new Exception("Email déjà utilisé")); } $password = password_hash($_REQUEST['password'], PASSWORD_DEFAULT); +<<<<<<< HEAD:WEB/Controller/UserController.php $utilisateur = new Utilisateur($_REQUEST['email'], $_REQUEST['username'], $password, false); $gateway->insert($utilisateur); +======= + $Utilisateur = new Utilisateur($_REQUEST['email'], $_REQUEST['username'], $password); + $gateway->insert($Utilisateur); +>>>>>>> d82ece50 (Changement de joueur et admin):WEB/Controller/Controller.php $_SESSION['connected'] = 'true'; $_SESSION['role'] = 'utilisateur'; require ($rep.$vues['main']); @@ -89,8 +98,13 @@ class UserController global $rep, $vues, $sel, $error; try { $gateway = new UtilisateurGateway($this->con); +<<<<<<< HEAD:WEB/Controller/UserController.php $utilisateur = $gateway->getUtilisateurByEmail($_REQUEST['email']); if ($utilisateur->getEmail() == null){ +======= + $Utilisateur = $gateway->getUtilisateurByEmail($_REQUEST['email']); + if ($Utilisateur->getEmail() == null){ +>>>>>>> d82ece50 (Changement de joueur et admin):WEB/Controller/Controller.php $error = "Utilisateur non trouvé."; throw new Exception("Utilisateur introuvable"); } diff --git a/WEB/Model/Admin.php b/WEB/Model/Admin.php deleted file mode 100644 index 12a9b324..00000000 --- a/WEB/Model/Admin.php +++ /dev/null @@ -1,67 +0,0 @@ -email = $email; - $this->pseudo = $pseudo; - $this->mdp = $mdp; - } - /** - * @return string - */ - public function getEmail(): string - { - return $this->email; - } - - /** - * @param string $email - */ - public function setEmail(string $email): void - { - $this->email = $email; - } - - /** - * @return mixed - */ - public function getPseudo() - { - return $this->pseudo; - } - - /** - * @param mixed $pseudo - */ - public function setPseudo($pseudo): void - { - $this->pseudo = $pseudo; - } - - /** - * @return mixed - */ - public function getMdp() - { - return $this->mdp; - } - - /** - * @param mixed $mdp - */ - public function setMdp($mdp): void - { - $this->mdp = $mdp; - } -} \ No newline at end of file diff --git a/WEB/Model/Utilisateur.php b/WEB/Model/Utilisateur.php index 50be44ed..b77d042b 100644 --- a/WEB/Model/Utilisateur.php +++ b/WEB/Model/Utilisateur.php @@ -13,12 +13,20 @@ class Utilisateur * @param string $mdp * @param bool $estAdmin */ +<<<<<<< HEAD public function __construct(string $email, string $pseudo, string $mdp, bool $estAdmin) +======= + public function __construct(string $email, string $pseudo, string $mdp ,bool $estAdmin) +>>>>>>> d82ece50 (Changement de joueur et admin) { $this->email = $email; $this->pseudo = $pseudo; $this->mdp = $mdp; +<<<<<<< HEAD $this->estAdmin = $estAdmin; +======= + $this->estAdmin=$estAdmin; +>>>>>>> d82ece50 (Changement de joueur et admin) } /** @@ -70,17 +78,31 @@ class Utilisateur } /** +<<<<<<< HEAD * @return bool +======= + * @param bool $estAdmin +>>>>>>> d82ece50 (Changement de joueur et admin) */ public function getEstAdmin(): bool { return $this->estAdmin; } +<<<<<<< HEAD /** * @param bool $estAdmin */ public function setEstAdmin(bool $estAdmin): void { $this->estAdmin = $estAdmin; +======= + + /** + * @param bool $estAdmin + */ + public function setEstAdmin(bool $estAdmin) + { + $this->estAdmin=$estAdmin; +>>>>>>> d82ece50 (Changement de joueur et admin) } } \ No newline at end of file