diff --git a/Project/php/controller/TeacherController.php b/Project/php/controller/TeacherController.php index 82a2197..f4f88b7 100755 --- a/Project/php/controller/TeacherController.php +++ b/Project/php/controller/TeacherController.php @@ -18,6 +18,14 @@ class TeacherController extends UserController $groups = $mdl->getAllGroups(); echo $twig->render('manageVocabListView.html', ['vocabularies' => $vocabularies, 'groups' => $groups, 'userID' => $user->getId(), 'userRole' => $user->getRoles()]); } + public function findByUser():void { + global $twig; + global $user; + $mdl = new MdlTeacher(); + $vocabularies = $mdl->findByUser($user->getId()); + $groups = $mdl->getAllGroups(); + echo $twig->render('manageVocabListView.html', ['vocabularies' => $vocabularies, 'groups' => $groups, 'userID' => $user->getId(), 'userRole' => $user->getRoles()]); + } public function DelById():void{ global $user; diff --git a/Project/php/gateway/VocabularyListGateway.php b/Project/php/gateway/VocabularyListGateway.php index 4714986..ee0b356 100755 --- a/Project/php/gateway/VocabularyListGateway.php +++ b/Project/php/gateway/VocabularyListGateway.php @@ -131,4 +131,19 @@ class VocabularyListGateway extends AbsGateway throw new Exception($e->getMessage()); } } + + public function findByUser(int $id): array { + try { + $query = "SELECT v.* FROM VocabularyList v, User_ u WHERE v.userID =u.id AND u.id=:id"; + $args = array(':id' => array($id, PDO::PARAM_INT)); + $this->con->executeQuery($query, $args); + $results = $this->con->getResults(); + $tab = array(); + foreach ($results as $row) $tab[] = new VocabularyList($row['id'], $row['name'], $row['image'], $row['userID']); + return $tab; + } + catch (PDOException $e) { + throw new Exception($e->getMessage()); + } + } } \ No newline at end of file diff --git a/Project/php/model/MdlTeacher.php b/Project/php/model/MdlTeacher.php index fddc44d..62ab657 100755 --- a/Project/php/model/MdlTeacher.php +++ b/Project/php/model/MdlTeacher.php @@ -24,6 +24,12 @@ class MdlTeacher extends MdlUser $gtw = new UserGateway(); return $gtw->findAll(); } + public function findByUser($id):array + { + $gtw = new VocabularyListGateway(); + return $gtw->findByUser($id); + } + public function getVocabByName(string $name):array{ $gtw = new VocabularyListGateway(); diff --git a/Project/php/templates/manageVocabListView.html b/Project/php/templates/manageVocabListView.html index 0a66216..d3cd868 100755 --- a/Project/php/templates/manageVocabListView.html +++ b/Project/php/templates/manageVocabListView.html @@ -29,7 +29,7 @@