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
{
public function __construct() {
public function __construct()
{
global $twig;
global $altorouterPath;
session_start();
//var_dump($_SESSION['login']);
//var_dump($_SESSION['roles']);
var_dump($_SESSION['login']);
var_dump($_SESSION['roles']);
try {
$router = new \AltoRouter();
@ -29,10 +30,19 @@ class FrontController
$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;
$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) {
case null:
@ -57,12 +67,15 @@ class FrontController
break;
}
}
catch (Exception $e) {
}
catch
(Exception $e) {
$dVueEreur[] = $e->getMessage();
echo $twig->render('erreur.html', ['dVueEreur' => $dVueEreur]);
}
}
public function home(): void {
global $twig;
echo $twig->render('home.html');

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

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

Loading…
Cancel
Save