From 0fc97662f6a0aaf75e4b21dcf8d70bec4cffc798 Mon Sep 17 00:00:00 2001 From: Thomas Chazot Date: Fri, 23 Dec 2022 12:45:05 +0100 Subject: [PATCH] zzzz --- controllers/VisitorController.php | 12 ++++++------ gateway/ListeGateway.php | 12 ++++++++++++ modeles/MdlListe.php | 21 +++++++++++++++++++++ 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/controllers/VisitorController.php b/controllers/VisitorController.php index ee886da..8a38164 100644 --- a/controllers/VisitorController.php +++ b/controllers/VisitorController.php @@ -33,26 +33,26 @@ class VisitorController { break; case "supprimerListe": - $this->DelList(); + $this->DelList($dVueEreur); break; case "accessListInfos": - $this->accessListInfos(); + $this->accessListInfos($dVueEreur); break; case "modifierListe": - $this->UpdateList(); + $this->UpdateList($dVueEreur); break; case "ajouterTache": - $this->AddTask(); + $this->AddTask($dVueEreur); break; case "supprimerTache": - $this->DelTask(); + $this->DelTask($dVueEreur); break; case "modifierTache": - $this->UpdateTask(); + $this->UpdateTask($dVueEreur); break; default: diff --git a/gateway/ListeGateway.php b/gateway/ListeGateway.php index e76e989..dbfba12 100644 --- a/gateway/ListeGateway.php +++ b/gateway/ListeGateway.php @@ -59,6 +59,18 @@ class ListeGateway return $results; } + public function findById(string $id): array{ + $results=[]; + if (!empty($id)){ + $query = "SELECT * FROM Liste WHERE id=:id"; + $this->con->executeQuery($query, array(':id' => array($id, PDO::PARAM_STR))); + + $results=$this->con->getResults(); + return $results; + } + return $results; + } + public function findByUserId(string $userId): array{ $query = "SELECT * FROM Liste WHERE idCreator=:idCreator"; $this->con->executeQuery($query, array(':idCreator' => array($userId, PDO::PARAM_STR))); diff --git a/modeles/MdlListe.php b/modeles/MdlListe.php index 2017c6b..796fd22 100644 --- a/modeles/MdlListe.php +++ b/modeles/MdlListe.php @@ -55,6 +55,27 @@ class MdlListe{ return $tabListe; } + public function findById(string $id): array{ + $gate=new ListeGateway($this->con); + $gateTache=new TacheGateway($this->con); + $results=$gate->findById($id); + $tabListe=[]; + foreach ($results as $row ) { + $tabTache=[]; + $taches=$gateTache->getTacheFromIdList($row['id']); + foreach($taches as $tata){ + $tabTache[]=new Tache($tata['id'], $tata['name'], $tata['content'], $tata['completed']); + } + if ($row['private']==false){ + $tabListe[]=new Liste($row['id'], $row['name'], $row['private'], null, $tabTache); + } + if ($row['idCreator']==$u->getId()){ + $tabListe[]=new Liste($row['id'], $row['name'], $row['private'], $u, $tabTache); + } + } + return $tabListe; + } + public function findByUser(string $username): array{ $gate=new ListeGateway($this->con); $gateTache=new TacheGateway($this->con);