From a561e00fe589fc40a75eda34a6cf62412c803aec Mon Sep 17 00:00:00 2001 From: Antoine Jourdain Date: Sat, 11 Nov 2023 17:38:08 +0100 Subject: [PATCH 1/5] Correspondance avec la nouvelle conception de la BD pour liste de vocabulaire --- ...yGateway.php => VocabularyListGateway.php} | 31 ++++++++++++------- .../{Vocabulary.php => VocabularyList.php} | 2 +- 2 files changed, 21 insertions(+), 12 deletions(-) rename Project/php/gateway/{VocabularyGateway.php => VocabularyListGateway.php} (69%) rename Project/php/model/{Vocabulary.php => VocabularyList.php} (99%) diff --git a/Project/php/gateway/VocabularyGateway.php b/Project/php/gateway/VocabularyListGateway.php similarity index 69% rename from Project/php/gateway/VocabularyGateway.php rename to Project/php/gateway/VocabularyListGateway.php index b0ed969..6bfcd5c 100755 --- a/Project/php/gateway/VocabularyGateway.php +++ b/Project/php/gateway/VocabularyListGateway.php @@ -4,9 +4,9 @@ namespace gateway; use PDO; use PDOException; use Exception; -use model\Vocabulary; +use model\VocabularyList; -class VocabularyGateway extends AbsGateway +class VocabularyListGateway extends AbsGateway { public function __construct(){ parent::__construct(); @@ -15,7 +15,7 @@ class VocabularyGateway extends AbsGateway public function add(array $parameters): int // require 4 elements { try{ - $query = "INSERT INTO Vocabulary values(:id,:name,:img,:aut)"; + $query = "INSERT INTO VocabularyList VALUES(:id,:name,:img,:aut)"; $args = array(':id'=>array($parameters[0],PDO::PARAM_INT), ':name'=>array($parameters[1],PDO::PARAM_STR), ':img'=>array($parameters[2],PDO::PARAM_STR), @@ -31,7 +31,7 @@ class VocabularyGateway extends AbsGateway public function remove(int $id): void { try{ - $query = "DELETE FROM Vocabulary v WHERE v.id=:id "; + $query = "DELETE FROM VocabularyList v WHERE v.id=:id "; $args = array(':id'=>array($id,PDO::PARAM_INT)); $this->con->ExecuteQuery($query,$args); } @@ -44,13 +44,13 @@ class VocabularyGateway extends AbsGateway { try{ - $query = "SELECT * FROM Vocabulary"; + $query = "SELECT * FROM VocabularyList"; $this->con->ExecuteQuery($query); $res = $this->con->getResults(); $tab_vocab=[]; foreach($res as $r){ - $tab_vocab[]=new Vocabulary($r['id'],$r['name'],$r['image'],$r['creator']); + $tab_vocab[]=new VocabularyList($r['id'],$r['name'],$r['image'],$r['userID']); } Return $tab_vocab; } @@ -61,20 +61,29 @@ class VocabularyGateway extends AbsGateway public function findById(int $id) { - // TODO: Implement findById() method. + try{ + $query = "SELECT * FROM VocabularyList WHERE id = :id"; + $args = array(':id' => array($id, PDO::PARAM_INT)); + $this->con->executeQuery($query, $args); + + return $this->con->getResults(); + } + catch (PDOException $e){ + throw new Exception($e->getMessage()); + } } public function findByName(String $name): array { try{ - $query = "SELECT * FROM Vocabulary v WHERE v.name = :name"; + $query = "SELECT * FROM VocabularyList v WHERE v.name = :name"; $args = array(':name'=>array($name,PDO::PARAM_STR)); $this->con->ExecuteQuery($query,$args); $res = $this->con->getResults(); $tab_vocab=[]; foreach($res as $r){ - $tab_vocab[]=new Vocabulary($r['id'],$r['name'],$r['image'],$r['creator']); + $tab_vocab[]=new VocabularyList($r['id'],$r['name'],$r['image'],$r['userID']); } Return $tab_vocab; } @@ -85,9 +94,9 @@ class VocabularyGateway extends AbsGateway } - public function ModifVocabById(int $id, String $name,String $img,String $aut):void{ + public function ModifVocabListById(int $id, String $name,String $img,String $aut):void{ try{ - $query = "UPDATE Vocabulary SET name=:name, image=:img, creator=:aut WHERE id=:id"; + $query = "UPDATE VocabularyList SET name=:name, image=:img, userID=:aut WHERE id=:id"; $args = array(':id'=>array($id,PDO::PARAM_INT), ':name'=>array($name,PDO::PARAM_STR), ':img'=>array($img,PDO::PARAM_STR), diff --git a/Project/php/model/Vocabulary.php b/Project/php/model/VocabularyList.php similarity index 99% rename from Project/php/model/Vocabulary.php rename to Project/php/model/VocabularyList.php index 353aa68..4c1ae50 100755 --- a/Project/php/model/Vocabulary.php +++ b/Project/php/model/VocabularyList.php @@ -2,7 +2,7 @@ namespace model; -class Vocabulary +class VocabularyList { protected String $name; protected String $image; From b7590c9ac72cba78f27d2489d5ba33447af41a34 Mon Sep 17 00:00:00 2001 From: Antoine Jourdain Date: Sat, 11 Nov 2023 17:38:50 +0100 Subject: [PATCH 2/5] =?UTF-8?q?Fix=20par=20rapport=20=C3=A0=20nouvelle=20B?= =?UTF-8?q?D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Project/php/gateway/GroupGateway.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Project/php/gateway/GroupGateway.php b/Project/php/gateway/GroupGateway.php index 3cae42d..a7f5537 100755 --- a/Project/php/gateway/GroupGateway.php +++ b/Project/php/gateway/GroupGateway.php @@ -32,13 +32,13 @@ class GroupGateway extends AbsGateway public function remove(int $id): void { try{ - $query = "DELETE FROM Group_ g WHERE g.id=:id "; - $args = array(':id'=>array($id,PDO::PARAM_INT)); - $this->con->ExecuteQuery($query,$args); + $query="UPDATE User_ SET groupID=NULL WHERE groupID=:id"; + $args = array(':id' => array($id, PDO::PARAM_INT)); + $this->con->executeQuery($query, $args); $query = "DELETE FROM Practice WHERE groupID=:id "; $args = array(':id' => array($id, PDO::PARAM_INT)); $this->con->executeQuery($query, $args); - $query="UPDATE User_ SET groupID=0 WHERE groupID=:id"; + $query = "DELETE FROM Group_ WHERE id=:id "; $args = array(':id' => array($id, PDO::PARAM_INT)); $this->con->executeQuery($query, $args); } @@ -67,7 +67,16 @@ class GroupGateway extends AbsGateway public function findById(int $id) { - // TODO: Implement findById() method. + try{ + $query = "SELECT * FROM Group_ WHERE id = :id"; + $args = array(':id'=>array($id, PDO::PARAM_INT)); + $this->con->executeQuery($query, args); + + return $this->con->getResults(); + } + catch (PDOException $e){ + throw new Exception($e->getMessage()); + } } public function findByNum(String $num): array{ From 81fd523b69b9eda2c7b657f58a3379c9754482f3 Mon Sep 17 00:00:00 2001 From: Antoine Jourdain Date: Sat, 11 Nov 2023 17:39:56 +0100 Subject: [PATCH 3/5] =?UTF-8?q?Fix=20pour=20nouvelle=20BD=20Encore=20=3F?= =?UTF-8?q?=20=C3=87a=20fait=20beaucoup=20l=C3=A0=20non=20=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Project/php/gateway/UserGateway.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Project/php/gateway/UserGateway.php b/Project/php/gateway/UserGateway.php index fcb5557..6917ddf 100755 --- a/Project/php/gateway/UserGateway.php +++ b/Project/php/gateway/UserGateway.php @@ -46,7 +46,7 @@ class UserGateway extends AbsGateway public function remove(int $id): void { try { - $query="DELETE FROM Vocabulary WHERE creator=:id"; + $query="DELETE FROM VocabularyList WHERE userID=:id"; $args = array(':id' => array($id, PDO::PARAM_INT)); $this->con->executeQuery($query, $args); @@ -278,10 +278,10 @@ class UserGateway extends AbsGateway } } - public function findUnassignedUsers() + public function findUnassignedUsers(): array { try { - $query = "SELECT * FROM User_ WHERE groupID=0"; + $query = "SELECT * FROM User_, Be WHERE groupID=NULL AND id = userID AND roleID = 3 "; $this->con->executeQuery($query); $results = $this->con->getResults(); $tab = array(); From a9a7a358b3104577e474a871b818d657e1897fc4 Mon Sep 17 00:00:00 2001 From: Antoine Jourdain Date: Sat, 11 Nov 2023 17:53:02 +0100 Subject: [PATCH 4/5] Fix requete UnassignedUsers --- Project/php/gateway/UserGateway.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project/php/gateway/UserGateway.php b/Project/php/gateway/UserGateway.php index 6917ddf..f62343b 100755 --- a/Project/php/gateway/UserGateway.php +++ b/Project/php/gateway/UserGateway.php @@ -281,7 +281,7 @@ class UserGateway extends AbsGateway public function findUnassignedUsers(): array { try { - $query = "SELECT * FROM User_, Be WHERE groupID=NULL AND id = userID AND roleID = 3 "; + $query = "SELECT * FROM User_, Be WHERE groupID IS NULL AND id = userID AND roleID = 3 "; $this->con->executeQuery($query); $results = $this->con->getResults(); $tab = array(); From 47ea602b471769b2e1375fab08c3809a1ab3c361 Mon Sep 17 00:00:00 2001 From: Antoine Jourdain Date: Sat, 11 Nov 2023 17:54:13 +0100 Subject: [PATCH 5/5] Affichage role et extra time --- Project/php/templates/myAccountView.html | 2 +- Project/php/templates/userContainer.twig | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Project/php/templates/myAccountView.html b/Project/php/templates/myAccountView.html index 1c15f8a..06b5edd 100644 --- a/Project/php/templates/myAccountView.html +++ b/Project/php/templates/myAccountView.html @@ -49,7 +49,7 @@ Email: {{user.email}} Group : {{user.group}} - Extra Time : {{user.extraTime}} + Extra Time : {{user.extraTime? 'yes' : 'no'}}
diff --git a/Project/php/templates/userContainer.twig b/Project/php/templates/userContainer.twig index ce38ddd..0e20492 100644 --- a/Project/php/templates/userContainer.twig +++ b/Project/php/templates/userContainer.twig @@ -18,8 +18,8 @@ {{row.surname}} {{row.email}} {{row.group}} - {{row.role}} - {{row.extraTime}} + {{row.roles|join(', ')}} + {{row.extraTime? 'yes' : 'no' }} {% if action is defined %}