implémentation des actions de la page my account (show + modify password + modify nickname)

php
Anthony RICHARD 1 year ago
parent 597103b4e4
commit 6b9657ac53

@ -23,6 +23,9 @@ class FrontController
);
private array $studentActions = array(
'showAccountInfos',
'modifyNickname',
'modifyPassword'
);
public function __construct()

@ -21,6 +21,17 @@ class StudentController
$this->getByName($_REQUEST['nom']);
break;
case 'showAccountInfos':
$this->showAccountInfos();
break;
case 'modifyNickname':
$this->modifyNickname();
break;
case 'modifyPassword':
$this->modifyPassword();
break;
case null:
echo $twig->render('home.html');
@ -38,14 +49,14 @@ class StudentController
}
}
public function affAllVocab(): void
{
global $twig;
$mdl = new MdlStudent();
$student = $mdl->getAll();
echo $twig->render('usersView.html', ['users' => $student]);
public function affAllVocab(): void
{
global $twig;
$mdl = new MdlStudent();
$student = $mdl->getAll();
echo $twig->render('usersView.html', ['users' => $student]);
}
}
public function affAllStudent(): void
{
@ -56,15 +67,46 @@ class StudentController
}
public function getByName($name): void
{
global $twig;
$mdl = new MdlStudent();
$vocab = $mdl->getVocabByName($name);
echo $twig->render('usersView.html', ['users' => $vocab]);
}
public function getByName($name): void
{
global $twig;
$mdl = new MdlStudent();
$vocab = $mdl->getVocabByName($name);
echo $twig->render('usersView.html', ['users' => $vocab]);
}
public function showAccountInfos(): void {
global $twig;
$userID = $_GET['user'];
$mdl = new MdlStudent();
$user = $mdl->getUser($userID);
echo $twig->render('myAccountView.html', ['user' => $user]);
}
public function modifyNickname(): void {
global $twig;
$userID = $_GET['user'];
$newNickname = $_GET['newNickname'];
$mdl = new MdlStudent();
$mdl->modifyNickname($userID, $newNickname);
$_GET['user'] = $userID;
$this->showAccountInfos();
}
public function modifyPassword(): void {
global $twig;
$userID = $_GET['user'];
$currentPassword = $_GET['currentPassword'];
$newPassword = $_GET['newPassword'];
$confirmNewPassword = $_GET['confirmNewPassword'];
$mdl = new MdlStudent();
$user = $mdl->getUser($userID);
}
if ($user->getPassword() == $currentPassword && $newPassword == $confirmNewPassword)
$mdl->ModifyPassword($userID, $newPassword);
$_GET['user'] = $userID;
$_REQUEST['action'] = 'showAccountInfos';
$this->showAccountInfos();
}
}

@ -45,10 +45,19 @@ class MdlStudent extends AbsModel
return $res;
}
public function getUser(int $id): User{
$gtw = new UserGateway();
return $gtw->findById($id);
}
public function modifyNickname(int $id, string $newNickname): void{
$gtw = new UserGateway();
$gtw->modifyNickname($id, $newNickname);
}
public function ModifyPassword(int $id, string $newPassword): void {
$gtw = new UserGateway();
$gtw->modifyPassword($id, $newPassword);
}
}

Loading…
Cancel
Save