diff --git a/Project/php/controller/AbsController.php b/Project/php/controller/AbsController.php index a82374c..0897f54 100644 --- a/Project/php/controller/AbsController.php +++ b/Project/php/controller/AbsController.php @@ -64,7 +64,7 @@ class AbsController global $twig; try{ - $idVoc = Validation::filter_int($match['params']['id'] ?? null); + $idVoc = Validation::filter_int($match['id'] ?? null); $wordList = (new \gateway\TranslationGateway)->findByIdVoc($idVoc); $wordShuffle = array(); @@ -95,7 +95,7 @@ class AbsController public function quiz($match): void { global $twig; - $vocabId = Validation::filter_int($match['params']['id'] ?? null); + $vocabId = Validation::filter_int($match['id'] ?? null); $mdl = new TranslationGateway(); $allTranslation = $mdl->findByIdVoc($vocabId); $shuffle = $allTranslation; diff --git a/Project/php/controller/FrontController.php b/Project/php/controller/FrontController.php index cdcb566..e259505 100755 --- a/Project/php/controller/FrontController.php +++ b/Project/php/controller/FrontController.php @@ -24,6 +24,7 @@ class FrontController $router->map('GET|POST', '/teacher/[i:id]/[a:action]?', 'Teacher'); $router->map('GET|POST', '/student/[i:id]/[a:action]?', 'Student'); $router->map('GET|POST', '/abs/[a:action]?', 'Abs'); + $router->map('GET|POST', '/abs/[a:action]/[i:id]', 'Abs'); $twig->addGlobal('base', $altorouterPath); @@ -37,38 +38,45 @@ class FrontController $action = Validation::val_action($match['params']['action'] ?? null); $id = $match['params']['id'] ?? null; - switch ($action) { - case null: - $this->home(); - break; + if ($target == 'Abs') { + $abs = new AbsController(); + if (is_callable(array($abs, $action))) + call_user_func_array(array($abs, $action), array($match['params'])); + } + else { + switch ($action) { + case null: + $this->home(); + break; - default : - if ($id != null && !$this->checkIdExist($id)) throw new Exception("identifiant invalide"); - if ($target == null) throw new Exception("pas de target"); + default : + if ($id != null && !$this->checkIdExist($id)) throw new Exception("identifiant invalide"); + if ($target == null) throw new Exception("pas de target"); - if (isset($_SESSION['login']) && isset($_SESSION['roles'])) { + if (isset($_SESSION['login']) && isset($_SESSION['roles'])) { - $_SESSION['login'] = strip_tags($_SESSION['login']); - for ($i=0 ; $igetId() != $id) throw new Exception("erreur 403 permission denied"); - } + if (!$user || $user->getId() != $id) throw new Exception("erreur 403 permission denied"); + } - $controller = '\\controller\\' . $target . 'Controller'; - $controller = new $controller; + $controller = '\\controller\\' . $target . 'Controller'; + $controller = new $controller; - if (is_callable(array($controller, $action))) - call_user_func_array(array($controller, $action), array($match['params'])); + if (is_callable(array($controller, $action))) + call_user_func_array(array($controller, $action), array($match['params'])); - break; - } - else (new AbsController())->login(); + break; + } + else (new AbsController())->login(); + } } } } diff --git a/Project/php/templates/quizzView.html b/Project/php/templates/quizzView.html index e188dd4..2413605 100755 --- a/Project/php/templates/quizzView.html +++ b/Project/php/templates/quizzView.html @@ -30,7 +30,7 @@ {% endif %} {% endfor %} {% endif %} - + {% if submitted %} {% if isCorrect %}