modification du modele de student et de son controller pour rendre certaines methodes fonctionnel, début de modification du frontController pour rendre les connexion plus securisé

php
Patrick BRUGIERE 1 year ago
parent 899071b307
commit dbb85c2c68

@ -8,14 +8,15 @@ use model\MdlStudent;
class FrontController class FrontController
{ {
public function __construct() { public function __construct()
{
global $twig; global $twig;
global $altorouterPath; global $altorouterPath;
session_start(); session_start();
//var_dump($_SESSION['login']); var_dump($_SESSION['login']);
//var_dump($_SESSION['roles']); var_dump($_SESSION['roles']);
try { try {
$router = new \AltoRouter(); $router = new \AltoRouter();
@ -29,10 +30,19 @@ class FrontController
$match = $router->match(); $match = $router->match();
if (!$match) { throw new Exception("Erreur 404");} if (!$match) {
throw new Exception("Erreur 404");
}
if ($match) {
//list($controller, $action) = explode('#', $match['target'] );
$controller = $match['target'] ?? null; $controller = $match['target'] ?? null;
$action = Validation::val_action($match['params']['action'] ?? null); $action = Validation::val_action($match['params']['action'] ?? null);
$id = $match['params']['id'] ?? null;
print 'user Id received ' . $id . '<br>';
print 'controleur appelé ' . $controller . '<br>';
print $action . '<br>';
print $id . '<br>';
switch ($action) { switch ($action) {
case null: case null:
@ -57,12 +67,15 @@ class FrontController
break; break;
} }
} }
catch (Exception $e) { }
catch
(Exception $e) {
$dVueEreur[] = $e->getMessage(); $dVueEreur[] = $e->getMessage();
echo $twig->render('erreur.html', ['dVueEreur' => $dVueEreur]); echo $twig->render('erreur.html', ['dVueEreur' => $dVueEreur]);
} }
} }
public function home(): void { public function home(): void {
global $twig; global $twig;
echo $twig->render('home.html'); echo $twig->render('home.html');

@ -12,8 +12,8 @@ class StudentController
{ {
global $twig; global $twig;
$mdl = new MdlStudent(); $mdl = new MdlStudent();
$student = $mdl->getAll(); $voc = $mdl->getAll();
echo $twig->render('usersView.html', ['users' => $student]); echo $twig->render('manageVocabListView.html', ['vocabularies' => $voc]);
} }
@ -26,12 +26,13 @@ class StudentController
} }
public function getByName($name): void public function getByName(): void
{ {
global $twig; global $twig;
$mdl = new MdlStudent(); $mdl = new MdlStudent();
$name = Validation::filter_str_simple($_GET['listName'] ?? null);
$vocab = $mdl->getVocabByName($name); $vocab = $mdl->getVocabByName($name);
echo $twig->render('usersView.html', ['users' => $vocab]); echo $twig->render('manageVocabView.html', ['vocabularies' => $vocab]);
} }
public function showAccountInfos(): void { public function showAccountInfos(): void {

@ -4,6 +4,8 @@ namespace model;
use gateway\UserGateway; use gateway\UserGateway;
use gateway\VocabularyGateway; use gateway\VocabularyGateway;
use gateway\VocabularyListGateway;
class MdlStudent extends AbsModel class MdlStudent extends AbsModel
{ {
@ -14,7 +16,7 @@ class MdlStudent extends AbsModel
public function getAll():array{ public function getAll():array{
global $twig; global $twig;
$gtw = new VocabularyGateway(); $gtw = new VocabularyListGateway();
return $gtw->findAll(); return $gtw->findAll();
/* /*
foreach ($data as $row){ foreach ($data as $row){
@ -25,7 +27,7 @@ class MdlStudent extends AbsModel
} }
public function getVocabByName(string $name):array{ public function getVocabByName(string $name):array{
$gtw = new VocabularyGateway(); $gtw = new VocabularyListGateway();
$res = $gtw->findByName($name); $res = $gtw->findByName($name);
return $res; return $res;
} }

Loading…
Cancel
Save