diff --git a/src/Controller/CtrlVisiteur.php b/src/Controller/CtrlVisiteur.php index b8426fd..31c506e 100644 --- a/src/Controller/CtrlVisiteur.php +++ b/src/Controller/CtrlVisiteur.php @@ -41,6 +41,14 @@ class CtrlVisiteur { $this->redirectionInscription($dVueEreur); break; + case "SupprimerTache": + $this->SupprimerTache(); + break; + + case "SupprimerListe": + $this->SupprimerListe(); + break; + //mauvaise action default: $dVueEreur[] = "Erreur d'appel php"; @@ -93,11 +101,29 @@ class CtrlVisiteur { function ConsulterListePublic(array $dVueEreur) { global $rep,$vues; $listes = MdlVisiteur::RecupererListePublic(); + $taches = MdlVisiteur::RecupererTache(); require ($rep.$vues['listPublic']); } + function SupprimerTache(){ + global $rep,$vues; + $id = $_GET['idTache']; + $tache = MdlVisiteur::SupprimerTache($id); + $listes = MdlVisiteur::RecupererListePublic(); + $taches = MdlVisiteur::RecupererTache(); + require ($rep.$vues['listPublic']); + } + + function SupprimerListe(){ + global $rep,$vues; + $id = $_GET['idListe']; + $liste = MdlVisiteur::SupprimerListe($id); + $listes = MdlVisiteur::RecupererListePublic(); + $taches = MdlVisiteur::RecupererTache(); + require ($rep.$vues['listPublic']); + } }//fin class ?> diff --git a/src/Modele/Liste.php b/src/Modele/Liste.php index e8f6101..a9a01bb 100644 --- a/src/Modele/Liste.php +++ b/src/Modele/Liste.php @@ -32,6 +32,10 @@ class Liste return $this->nom; } + public function getDescription(){ + return $this->description; + } + public function setNom($nom){ $this->nom=$nom; } diff --git a/src/Modele/ListeGateway.php b/src/Modele/ListeGateway.php index 257ae58..5e4ec24 100644 --- a/src/Modele/ListeGateway.php +++ b/src/Modele/ListeGateway.php @@ -17,13 +17,13 @@ class ListeGateway{ } public function Editer(Liste $Liste){ - $query='UPDATE ToDoListe_Liste SET nom=:nom WHERE id=:id'; + $query='UPDATE ToDoList_Liste SET nom=:nom WHERE id=:id'; $this->con->executeQuery($query, array('nom' => array($Liste->getNom(), PDO::PARAM_STRING)), array('id' => array($Liste->getId()),PDO::PARAM_INT)); } public function Supprimer(int $id){ - $query='DELETE FROM ToDoListe_Liste WHERE id=:id'; - $this->con->executeQuery($query,array('id' => array($id, PDO::PARAM_STRING))); + $query='DELETE FROM ToDoList_Liste WHERE id=:id'; + $this->con->executeQuery($query,array('id' => array($id, PDO::PARAM_INT))); } public function getListe(int $offset, int $limit){ @@ -34,14 +34,14 @@ class ListeGateway{ } public function getTacheListe(Liste $liste){ - $query = 'SELECT tache FROM ToDoListe_Liste WHERE id=:id '; + $query = 'SELECT tache FROM ToDoList_Liste WHERE id=:id '; $this->con->executeQuery($query, array('id' => array($liste->getId, PDO::PARAM_INT))); $results=$this->con->getResults(); return $results; } public function getListePublic($offset,$limit){ - $query = "SELECT * FROM ToDoList_Liste "; + $query = "SELECT * FROM ToDoList_Liste WHERE estPublic LIMIT $offset, $limit"; $this->con->executeQuery($query); $listes = []; foreach ($this->con->getResults() as $liste) { diff --git a/src/Modele/MdlAdmin.php b/src/Modele/MdlAdmin.php index af0c25b..9e409ea 100644 --- a/src/Modele/MdlAdmin.php +++ b/src/Modele/MdlAdmin.php @@ -7,6 +7,23 @@ class MdlAdmin } + public function Connexion(string $pseudo, string $mdp){ + /*Pas d'admin gateway pour l'instant*/ + /*$gtw = new AdminGateway();*/ + /*test avec utilisateur gateway*/ + $gtw = new UtilisateurGateway(); + $login = Validation::cleanLogin($pseudo); + $mdp = Validation::cleanString($mdp); + + if(password_verify($mdp, $gtw->getCredential($login))){ + $_SESSION['role'] = 'admin'; + $_SESSION['login'] = $pseudo; + return new Admin(); + } + else{ + $dVueEreur[] = "Vous n'etes pas Admin"; + } + } } diff --git a/src/Modele/MdlVisiteur.php b/src/Modele/MdlVisiteur.php index 0aa0ad3..5aa72f0 100644 --- a/src/Modele/MdlVisiteur.php +++ b/src/Modele/MdlVisiteur.php @@ -24,4 +24,21 @@ class MdlVisiteur return $userGtw->getListePublic(0,10); } + public static function RecupererTache(){ + $userGtw = new TacheGateway(); + + return $userGtw->getTache(); + } + + public static function SupprimerTache(string $id){ + $userGtw = new TacheGateway(); + + return $userGtw->Supprimer($id); + } + + public static function SupprimerListe(string $id){ + $userGtw = new ListeGateway(); + + return $userGtw->Supprimer($id); + } } diff --git a/src/Modele/Tache.php b/src/Modele/Tache.php index 8682b72..844c230 100644 --- a/src/Modele/Tache.php +++ b/src/Modele/Tache.php @@ -65,7 +65,7 @@ class Tache //idList public function getIdListe(){ - return $this->estValide; + return $this->idListe; } public function setIdListe($idListe){ diff --git a/src/Modele/TacheGateway.php b/src/Modele/TacheGateway.php index 28c98c3..150c97d 100644 --- a/src/Modele/TacheGateway.php +++ b/src/Modele/TacheGateway.php @@ -2,6 +2,7 @@ class TacheGateway{ private $con; public function __construct(){ + global $dsn,$user,$pass; $this->con=new Connection($dsn,$user,$pass); } @@ -19,9 +20,19 @@ class TacheGateway{ $this->con->executeQuery($query, array('nom' => array($tache->getNom(), PDO::PARAM_STRING)), array('description' => array($tache->getdescription(), PDO::PARAM_STRING)), array('id' => array($tache->getId(),PDO::PARAM_INT))); } - public function Supprimer(Tache $tache){ + public function Supprimer(string $id){ $query='DELETE FROM ToDoList_Tache WHERE id=:id'; - $this->con->executeQuery($query,'id' => array($tache->getId(), PDO::PARAM_STRING)); + $this->con->executeQuery($query,array('id' => array($id, PDO::PARAM_INT))); + } + + public function getTache(){ + $query='SELECT * FROM ToDoList_Tache'; + $this->con->executeQuery($query); + $taches = []; + foreach ($this->con->getResults() as $tache) { + $taches[] = new Tache($tache["id"],$tache["nom"],$tache["description"],$tache["dateCreation"],$tache["estValide"],$tache["idListe"]); + } + return $taches; } } ?> \ No newline at end of file diff --git a/src/Modele/Utilisateur.php b/src/Modele/Utilisateur.php index b4483f3..a526b81 100644 --- a/src/Modele/Utilisateur.php +++ b/src/Modele/Utilisateur.php @@ -7,6 +7,7 @@ class Utilisateur private $prenom; private $pseudo; private $email; + private $isAdmin; public function __construct($id, $nom, $prenom, $pseudo, $email, $motDePasse, $isAdmin){ $this->id = $id; @@ -14,6 +15,7 @@ class Utilisateur $this->prenom = $prenom; $this->pseudo = $pseudo; $this->email = $email; + $this->isAdmin = $isAdmin; } //Nom diff --git a/src/Modele/UtilisateurGateway.php b/src/Modele/UtilisateurGateway.php index dbe10c5..3167ace 100644 --- a/src/Modele/UtilisateurGateway.php +++ b/src/Modele/UtilisateurGateway.php @@ -20,7 +20,19 @@ class UtilisateurGateway{ public function SupprimerUtilisateur(int $id){ $query='DELETE FROM ToDoList_Utilisateur WHERE id=:id;'; $this->con->executeQuery($query, array( - 'id' => array($id, PDO::PARAM_STRING))); + 'id' => array($id, PDO::PARAM_INT))); + } + + public getCredential(string $id){ + $query = 'SELECT motDePasse FROM ToDoList_Utilisateur WHERE id=:id'; + + if(this->con->executeQuery($query, array('id' => array($id, PDO::PARAM_INT)))){ + return (this->con->getResults[0]['motDePasse']) + } + else{ + /* pas sur de ça*/ + throw new PDOexception; + } } public function RechercheUtilisateurViaPseudo(string $pseudo){ diff --git a/src/Vue/Images/edit.png b/src/Vue/Images/edit.png new file mode 100644 index 0000000..036ece0 Binary files /dev/null and b/src/Vue/Images/edit.png differ diff --git a/src/Vue/Images/trash.png b/src/Vue/Images/trash.png new file mode 100644 index 0000000..8d541ad Binary files /dev/null and b/src/Vue/Images/trash.png differ diff --git a/src/Vue/html/NavBar.php b/src/Vue/php/NavBar.php similarity index 100% rename from src/Vue/html/NavBar.php rename to src/Vue/php/NavBar.php diff --git a/src/Vue/html/PageListePublic.php b/src/Vue/php/PageListePublic.php similarity index 84% rename from src/Vue/html/PageListePublic.php rename to src/Vue/php/PageListePublic.php index 73db482..c627abb 100644 --- a/src/Vue/html/PageListePublic.php +++ b/src/Vue/php/PageListePublic.php @@ -16,11 +16,66 @@ - '.$liste->getNom().''; - } - ?> + ?> +
+
+
+
+
+ +
+

+ getNom()?> + + + + + +

+

getDescription()?> +

getDateCreation()?>

+ +
+ +
    + getIdListe() == $liste->getId()){ + ?> +
  • + + getNom() ?> : getDescription() ?> + + + + + + +
  • + +
+
+
+
+
+
+ +