From 41b660a88c097c403e7e7c7e9a8a49c13b9f5b68 Mon Sep 17 00:00:00 2001 From: "patrick.brugiere" Date: Mon, 20 Nov 2023 16:27:14 +0100 Subject: [PATCH] modification des view pour quelles fonctionnent avec le altoRouteur --- Project/php/controller/TeacherController.php | 13 +++++++++---- Project/php/templates/manageVocabListView.html | 6 +++--- Project/php/templates/vocabularyContainer.twig | 6 +++--- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Project/php/controller/TeacherController.php b/Project/php/controller/TeacherController.php index da42c5e..b0a06ba 100755 --- a/Project/php/controller/TeacherController.php +++ b/Project/php/controller/TeacherController.php @@ -20,27 +20,32 @@ class TeacherController public function affAllVocab(): void { global $twig; + global $user; + $id = $user->getId(); $mdl = new MdlTeacher(); $vocabularies = $mdl->getAll(); - echo $twig->render('manageVocabListView.html', ['vocabularies' => $vocabularies]); + echo $twig->render('manageVocabListView.html', ['vocabularies' => $vocabularies, 'userId' => $id]); } public function getByName(): void { global $twig; + global $user; $mdl = new MdlTeacher(); + $id = $user->getId(); $name = Validation::filter_str_simple($_GET['listName'] ?? null); $vocab = $mdl->getVocabByName($name); - echo $twig->render('manageVocabListView.html', ['vocabularies' => $vocab, 'selectedName' => $name]); + echo $twig->render('manageVocabListView.html', ['vocabularies' => $vocab, 'selectedName' => $name, 'userId' => $id ]); } public function DelById():void{ global $twig; + global $user; $mdl = new MdlTeacher(); - $id = Validation::filter_int($_GET['vocabID'] ?? null); + $id = $user->getId(); $vocab = $mdl->removeVocById($id); - echo $twig->render('manageVocabListView.html', [ 'vocabularies' => $vocab]); + echo $twig->render('manageVocabListView.html', [ 'vocabularies' => $vocab, 'userId' => $id ]); } public function showVocabListForm(): void { diff --git a/Project/php/templates/manageVocabListView.html b/Project/php/templates/manageVocabListView.html index f5d5689..9e668f6 100755 --- a/Project/php/templates/manageVocabListView.html +++ b/Project/php/templates/manageVocabListView.html @@ -8,12 +8,12 @@

Vocab list

- {% include 'vocabularyContainer.twig' with {'actions' : 'affAllVocab', 'vocabularies' : vocabularies } %} + {% include 'vocabularyContainer.twig' with {'actions' : 'affAllVocab', 'vocabularies' : vocabularies , 'userId' : userId} %}

Vocab of the user

- {% include 'vocabularyContainer.twig' with {'vocabularies' : vocabularies , 'actions' : 'getByName', 'selectedName' : 'selectedName' } %} + {% include 'vocabularyContainer.twig' with {'vocabularies' : vocabularies , 'actions' : 'getByName', 'selectedName' : 'selectedName', 'userId' : userId } %}
@@ -23,7 +23,7 @@

Unassigned vocab

- {% include 'vocabularyContainer.twig' with {'vocabularies' : vocabularies , 'actions' : 'delById'} %} + {% include 'vocabularyContainer.twig' with {'vocabularies' : vocabularies , 'actions' : 'delById', 'userId' : userId } %}
diff --git a/Project/php/templates/vocabularyContainer.twig b/Project/php/templates/vocabularyContainer.twig index 85ae52d..3e3c453 100755 --- a/Project/php/templates/vocabularyContainer.twig +++ b/Project/php/templates/vocabularyContainer.twig @@ -17,14 +17,14 @@ {% if actions is defined %} {% if actions == 'affAllVocab' %} - + {% elseif actions == 'getByName' %} - + {% elseif actions == 'delById' %} - + {% endif %}