fix plusieurs petits bugs

php
Anthony RICHARD 2 years ago
parent b815dbef75
commit f16c0de702

@ -42,9 +42,9 @@ class AdminController extends UserController
public function removeUser(): void {
try {
global $user;
$userToRemove = Validation::filter_int($_GET['userToRemove'] ?? null);
$model = new MdlAdmin();
$model->removeUser($user->getId());
$model->removeUser($userToRemove);
$this->showAllUsers();
}
catch (Exception $e) {
@ -80,9 +80,11 @@ class AdminController extends UserController
public function removeUserFromGroup(): void {
try {
$id = Validation::filter_int($_GET['id'] ?? null);
$userToRemove = Validation::filter_int($_GET['userToRemove'] ?? null);
$groupID = Validation::filter_int($_GET['selectedGroup'] ?? null);
$model = new MdlAdmin();
$model->removeUserFromGroup($id);
$model->removeUserFromGroup($userToRemove);
$_GET['selectedGroup'] = $groupID;
$this->showGroupDetails();
}
catch (Exception $e) {
@ -120,10 +122,10 @@ class AdminController extends UserController
public function addUserToGroup(): void {
try {
global $user;
$userToAdd = Validation::filter_int($_GET['userToAdd'] ?? null);
$group = Validation::filter_int($_GET['groupID'] ?? null);
$model = new MdlAdmin();
$model->addUserToGroup($user->getId(), $group);
$model->addUserToGroup($userToAdd, $group);
$_GET['selectedGroup'] = $group;
$this->showGroupDetails();
}

@ -57,16 +57,17 @@ class FrontController
global $user;
$user = call_user_func_array(array($mdl, 'is'), array($_SESSION['login'], $_SESSION['roles']));
if ($target == 'User' && $action == null) UserController::home();
else if (!$user || $user->getId() != $id) throw new Exception("erreur 403 permission denied");
$controller = '\\controller\\' . $target . 'Controller';
$controller = new $controller;
if ($target == 'User' && $action == null) $controller->home();
else if (!$user || $user->getId() != $id) throw new Exception("erreur 403 permission denied");
if (is_callable(array($controller, $action)))
call_user_func_array(array($controller, $action), array($match['params']));
}
}
else if ($target == 'User' && $action == null) UserController::home();
else (new UserController())->login();
}
}

@ -54,7 +54,7 @@ class UserController extends VisitorController
}
}
public function home(): void {
public static function home(): void {
global $twig;
global $user;
if(isset($user)){

@ -97,7 +97,7 @@ class VisitorController
if (!$this->checkLoginExist($login)) throw new Exception(("login invalide"));
$user = $model->connection($login, $password);
if ($user == null) throw new Exception("mot de passe invalide");
FrontController::home();
UserController::home();
}
public function checkLoginExist(string $login): bool {
@ -108,7 +108,7 @@ class VisitorController
public function disconnect(): void {
$mdl = new MdlUser();
$mdl->deconnection();
FrontController::home();
UserController::home();
}
public function resultatsJeux(): void{

@ -1,4 +1,4 @@
<form action="{{ base }}/admin/{{ userID }}/addGroup" method="GET">
<form action="{{ base }}/admin/{{ userID }}/addGroup" method="POST">
<input name="num" type="text" placeholder="number" required>
<input name="year" type="text" placeholder="year" required>
<input name="sector" type="text" placeholder="sector" required>

@ -1,5 +1,4 @@
<table>
{{ userID }}
{% if groups is defined %}
{% for row in groups %}
{% if selectedGroup is defined and selectedGroup == row.id %}

@ -28,8 +28,10 @@
{% endif %}
{% if userRole is empty %}
<li class="nav-item"><a class="nav-link" href="{{base}}/visitor/login">Login</a></li>
{% else %}
<li class="nav-item"><a class="nav-link" href="{{ base }}/visitor/disconnect">Log out</a></li>
{% endif %}
<li class="nav-item"><a class="nav-link" href="{{ base }}/visitor/disconnect">Log out</a></li>
</ul>
</div>
</div>

@ -24,17 +24,17 @@
{% if action is defined %}
{% if action == 'removeUserFromGroup' %}
<td><a href="{{base}}/admin/{{ userID }}/removeUserFromGroup?id={{row.id}}&selectedGroup={{selectedGroup}}">
<td><a href="{{base}}/admin/{{ userID }}/removeUserFromGroup?userToRemove={{row.id}}&selectedGroup={{ selectedGroup }}">
<input class="btn-black" type="button" value="Delete from group"/>
</a></td>
{% elseif action == 'addUserToGroup' %}
<td><a href="{{base}}/admin/{{ userID }}/addUserToGroup?userID={{row.id}}&groupID={{selectedGroup}}">
<td><a href="{{base}}/admin/{{ userID }}/addUserToGroup?userToAdd={{row.id}}&groupID={{selectedGroup}}">
<input class="btn-black" type="button" value="Add to group"/>
</a></td>
{% elseif action == 'removeUser' %}
<td><a href="{{base}}/admin/{{ userID }}/removeUser?userID={{row.id}}">
<td><a href="{{base}}/admin/{{ userID }}/removeUser?userToRemove={{row.id}}">
<input class="btn-black" type="button" value="Delete"/>
</a></td>
{% endif %}

Loading…
Cancel
Save