From 020a43e4182e62af656d934b42274a1698332eb4 Mon Sep 17 00:00:00 2001 From: Lucie GOIGOUX Date: Sun, 19 Nov 2023 12:18:41 +0100 Subject: [PATCH] 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 {