extends controller to absController + modif Student

php
Lucie GOIGOUX 1 year ago
parent 5f6e578362
commit 020a43e418

@ -6,7 +6,7 @@ use config\Validation;
use model\MdlAdmin;
use Exception;
class AdminController
class AdminController extends AbsController
{
public function showAllUsers(): void {
global $twig;

@ -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");
}
}
}

@ -6,7 +6,7 @@ use model\MdlTeacher;
use gateway\VocabularyListGateway;
use Exception;
class TeacherController
class TeacherController extends AbsController
{
public function affAllStudent(): void
{

Loading…
Cancel
Save