From 5f6e5783628c02f9a12a68751132b9feeaacb2f4 Mon Sep 17 00:00:00 2001 From: Lucie GOIGOUX Date: Sun, 19 Nov 2023 12:17:16 +0100 Subject: [PATCH 1/5] ajout de l'absController pour les jeux et les fonctions communes --- Project/php/controller/AbsController.php | 64 ++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 Project/php/controller/AbsController.php diff --git a/Project/php/controller/AbsController.php b/Project/php/controller/AbsController.php new file mode 100644 index 0000000..0dd5f91 --- /dev/null +++ b/Project/php/controller/AbsController.php @@ -0,0 +1,64 @@ +getUser($userID); + echo $twig->render('myAccountView.html', ['user' => $user]); + } + catch (Exception $e){ + throw new Exception("invalid user ID"); + } + } + + public function modifyPassword(): void { + try { + $userID = $_GET['user']; + $currentPassword = Validation::val_password($_GET['currentPassword'] ?? null); + $newPassword = Validation::val_password($_GET['newPassword'] ?? null); + $confirmNewPassword = Validation::val_password($_GET['confirmNewPassword'] ?? null); + $mdl = new MdlStudent(); + $user = $mdl->getUser($userID); + + if ($user->getPassword() != $currentPassword || $newPassword != $confirmNewPassword) + throw new Exception(""); + + $mdl->ModifyPassword($userID, $newPassword); + $_GET['user'] = $userID; + $this->showAccountInfos(); + } + catch (Exception $e){ + throw new Exception("invalid entries"); + } + } + + public function modifyNickname(): void { + try { + $userID = Validation::filter_int($_GET['user'] ?? null); + $newNickname = Validation::filter_str_nospecialchar($_GET['newNickname'] ?? null); + $mdl = new MdlStudent(); + $mdl->modifyNickname($userID, $newNickname); + $_GET['user'] = $userID; + $this->showAccountInfos(); + } + catch (Exception $e){ + throw new Exception("invalid entries"); + } + } + + public function memory(): void{ + global $twig; + } +} \ No newline at end of file From 020a43e4182e62af656d934b42274a1698332eb4 Mon Sep 17 00:00:00 2001 From: Lucie GOIGOUX Date: Sun, 19 Nov 2023 12:18:41 +0100 Subject: [PATCH 2/5] extends controller to absController + modif Student --- Project/php/controller/AdminController.php | 2 +- Project/php/controller/StudentController.php | 48 -------------------- Project/php/controller/TeacherController.php | 2 +- 3 files changed, 2 insertions(+), 50 deletions(-) diff --git a/Project/php/controller/AdminController.php b/Project/php/controller/AdminController.php index 43d7b39..c4a1474 100755 --- a/Project/php/controller/AdminController.php +++ b/Project/php/controller/AdminController.php @@ -6,7 +6,7 @@ use config\Validation; use model\MdlAdmin; use Exception; -class AdminController +class AdminController extends AbsController { public function showAllUsers(): void { global $twig; diff --git a/Project/php/controller/StudentController.php b/Project/php/controller/StudentController.php index a218a5f..3bec371 100755 --- a/Project/php/controller/StudentController.php +++ b/Project/php/controller/StudentController.php @@ -34,52 +34,4 @@ class StudentController $vocab = $mdl->getVocabByName($name); echo $twig->render('manageVocabView.html', ['vocabularies' => $vocab]); } - - public function showAccountInfos(): void { - try { - global $twig; - $userID = Validation::filter_int($_GET['user'] ?? null); - $mdl = new MdlStudent(); - $user = $mdl->getUser($userID); - echo $twig->render('myAccountView.html', ['user' => $user]); - } - catch (Exception $e){ - throw new Exception("invalid user ID".$e->getFile().$e->getLine()); - } - } - - public function modifyNickname(): void { - try { - $userID = Validation::filter_int($_GET['user'] ?? null); - $newNickname = Validation::filter_str_nospecialchar($_GET['newNickname'] ?? null); - $mdl = new MdlStudent(); - $mdl->modifyNickname($userID, $newNickname); - $_GET['user'] = $userID; - $this->showAccountInfos(); - } - catch (Exception $e){ - throw new Exception("invalid entries"); - } - } - - public function modifyPassword(): void { - try { - $userID = $_GET['user']; - $currentPassword = Validation::val_password($_GET['currentPassword'] ?? null); - $newPassword = Validation::val_password($_GET['newPassword'] ?? null); - $confirmNewPassword = Validation::val_password($_GET['confirmNewPassword'] ?? null); - $mdl = new MdlStudent(); - $user = $mdl->getUser($userID); - - if ($user->getPassword() != $currentPassword || $newPassword != $confirmNewPassword) - throw new Exception(""); - - $mdl->ModifyPassword($userID, $newPassword); - $_GET['user'] = $userID; - $this->showAccountInfos(); - } - catch (Exception $e){ - throw new Exception("invalid entries"); - } - } } \ No newline at end of file diff --git a/Project/php/controller/TeacherController.php b/Project/php/controller/TeacherController.php index da42c5e..ed1fb94 100755 --- a/Project/php/controller/TeacherController.php +++ b/Project/php/controller/TeacherController.php @@ -6,7 +6,7 @@ use model\MdlTeacher; use gateway\VocabularyListGateway; use Exception; -class TeacherController +class TeacherController extends AbsController { public function affAllStudent(): void { From 61c24e12b51cc0a56263e63c522e645e7535a589 Mon Sep 17 00:00:00 2001 From: Antoine Jourdain Date: Sun, 19 Nov 2023 12:19:32 +0100 Subject: [PATCH 3/5] Suppression oublie vardump --- Project/php/controller/FrontController.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/Project/php/controller/FrontController.php b/Project/php/controller/FrontController.php index bdccfec..2ca5bdd 100755 --- a/Project/php/controller/FrontController.php +++ b/Project/php/controller/FrontController.php @@ -15,9 +15,6 @@ class FrontController session_start(); - var_dump($_SESSION['login']); - var_dump($_SESSION['roles']); - try { $router = new \AltoRouter(); $router->setBasePath($altorouterPath); From bb04f79f9bcbd5afec5bca2d6d22b3345866dead Mon Sep 17 00:00:00 2001 From: Lucie GOIGOUX Date: Sun, 19 Nov 2023 12:50:29 +0100 Subject: [PATCH 4/5] =?UTF-8?q?d=C3=A9but=20memory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Project/php/controller/AbsController.php | 14 ++++++++++++++ Project/php/controller/FrontController.php | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Project/php/controller/AbsController.php b/Project/php/controller/AbsController.php index 0dd5f91..f364ce2 100644 --- a/Project/php/controller/AbsController.php +++ b/Project/php/controller/AbsController.php @@ -4,6 +4,8 @@ namespace controller; use config\Validation; use Exception; +use gateway\TranslationGateway; +use gateway\VocabularyListGateway; use model\MdlStudent; use model\VocabularyList; @@ -60,5 +62,17 @@ abstract class AbsController public function memory(): void{ global $twig; + + try{ + $idVoc = Validation::filter_int($_GET['id'] ?? null); + $wordList = (new \gateway\TranslationGateway)->findByIdVoc($idVoc); + + } + catch (Exception $e){ + throw new Exception("Erreur"); + } + + + echo $twig->render('memory.html'); } } \ No newline at end of file diff --git a/Project/php/controller/FrontController.php b/Project/php/controller/FrontController.php index 2ca5bdd..32b710d 100755 --- a/Project/php/controller/FrontController.php +++ b/Project/php/controller/FrontController.php @@ -20,7 +20,7 @@ class FrontController $router->setBasePath($altorouterPath); $router->map('GET', '/', 'AppController'); - $router->map('GET|POST', '/[a:action]?', 'NULL'); + $router->map('GET|POST', '/[a:action]?/[i:id]?', 'NULL'); $router->map('GET|POST', '/admin/[i:id]/[a:action]?', 'Admin'); $router->map('GET|POST', '/teacher/[i:id]/[a:action]?', 'Teacher'); $router->map('GET|POST', '/student/[i:id]/[a:action]?', 'Student'); From ecda59e3a0e209a5e9e29dedf89d22bcdf08b384 Mon Sep 17 00:00:00 2001 From: Antoine Jourdain Date: Sun, 19 Nov 2023 13:15:55 +0100 Subject: [PATCH 5/5] Fix --- Project/db/defaultinsert.sql | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Project/db/defaultinsert.sql b/Project/db/defaultinsert.sql index 53fef82..f91785f 100755 --- a/Project/db/defaultinsert.sql +++ b/Project/db/defaultinsert.sql @@ -34,9 +34,6 @@ INSERT INTO Be VALUES (3, 3); INSERT INTO Be VALUES (6, 3); INSERT INTO Be VALUES (10, 3); - -INSERT INTO Be VALUES (4, 1); -INSERT INTO Be VALUES (4, 2); INSERT INTO Be VALUES (20, 2); INSERT INTO Be VALUES (5, 2); @@ -45,7 +42,7 @@ INSERT INTO Be VALUES (30, 1); -- Vocabulary list INSERT INTO VocabularyList VALUES (1, "Animaux", "", 5); INSERT INTO VocabularyList VALUES (2, "Informatique", "", 5); -INSERT INTO VocabularyList VALUES (3, "Moyens de transport", "", 4); +INSERT INTO VocabularyList VALUES (3, "Moyens de transport", "", 20); -- Vocabulary creation : FR INSERT INTO Vocabulary VALUES ("Chat");