Anthony RICHARD 1 year ago
parent 090f0c0025
commit faedf5654e

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

Before

Width:  |  Height:  |  Size: 4.3 MiB

After

Width:  |  Height:  |  Size: 4.3 MiB

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Before

Width:  |  Height:  |  Size: 210 KiB

After

Width:  |  Height:  |  Size: 210 KiB

Before

Width:  |  Height:  |  Size: 294 KiB

After

Width:  |  Height:  |  Size: 294 KiB

Before

Width:  |  Height:  |  Size: 181 KiB

After

Width:  |  Height:  |  Size: 181 KiB

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

Before

Width:  |  Height:  |  Size: 882 KiB

After

Width:  |  Height:  |  Size: 882 KiB

Before

Width:  |  Height:  |  Size: 6.6 MiB

After

Width:  |  Height:  |  Size: 6.6 MiB

Before

Width:  |  Height:  |  Size: 98 KiB

After

Width:  |  Height:  |  Size: 98 KiB

Before

Width:  |  Height:  |  Size: 65 KiB

After

Width:  |  Height:  |  Size: 65 KiB

@ -18,4 +18,4 @@ global $password;
$password = 'achanger'; $password = 'achanger';
global $altorouterPath; global $altorouterPath;
$altorouterPath = "/SAE_2A_Anglais/Project/php"; $altorouterPath = "/~anrichard7/SAE_2A_Anglais/Project/php";

@ -10,37 +10,41 @@ class AdminController
{ {
public function showAllUsers(): void { public function showAllUsers(): void {
global $twig; global $twig;
global $user;
$model = new MdlAdmin(); $model = new MdlAdmin();
$users = $model->getAllUsers(); $users = $model->getAllUsers();
echo $twig->render('usersView.html', ['users' => $users]); echo $twig->render('usersView.html', ['users' => $users, 'userID' => $user->getId()]);
} }
public function showAllAdmins(): void { public function showAllAdmins(): void {
global $twig; global $twig;
global $user;
$model = new MdlAdmin(); $model = new MdlAdmin();
$users = $model->getAllAdmins(); $users = $model->getAllAdmins();
echo $twig->render('usersView.html', ['users' => $users]); echo $twig->render('usersView.html', ['users' => $users, 'userID' => $user->getId()]);
} }
public function showAllTeachers(): void { public function showAllTeachers(): void {
global $twig; global $twig;
global $user;
$model = new MdlAdmin(); $model = new MdlAdmin();
$users = $model->getAllTeachers(); $users = $model->getAllTeachers();
echo $twig->render('usersView.html', ['users' => $users]); echo $twig->render('usersView.html', ['users' => $users, 'userID' => $user->getId()]);
} }
public function showAllStudents(): void { public function showAllStudents(): void {
global $twig; global $twig;
global $user;
$model = new MdlAdmin(); $model = new MdlAdmin();
$users = $model->getAllStudents(); $users = $model->getAllStudents();
echo $twig->render('usersView.html', ['users' => $users]); echo $twig->render('usersView.html', ['users' => $users, 'userID' => $user->getId()]);
} }
public function removeUser(): void { public function removeUser(): void {
try { try {
$id = Validation::filter_int($_GET['userID'] ?? null); global $user;
$model = new MdlAdmin(); $model = new MdlAdmin();
$model->removeUser($id); $model->removeUser($user->getId());
$this->showAllUsers(); $this->showAllUsers();
} }
catch (Exception $e) { catch (Exception $e) {
@ -50,21 +54,24 @@ class AdminController
public function showAllGroups(): void { public function showAllGroups(): void {
global $twig; global $twig;
global $user;
$model = new MdlAdmin(); $model = new MdlAdmin();
$groups = $model->getAllGroups(); $groups = $model->getAllGroups();
$unassignedUsers = $model->getUnassignedUsers(); $unassignedUsers = $model->getUnassignedUsers();
echo $twig->render('manageGroupView.html', ['groups' => $groups, 'unassignedUsers' => $unassignedUsers]); echo $twig->render('manageGroupView.html', ['groups' => $groups, 'unassignedUsers' => $unassignedUsers, 'userID' => $user->getId()]);
} }
public function showGroupDetails(): void { public function showGroupDetails(): void {
try { try {
global $twig; global $twig;
global $user;
$selectedGroup = Validation::filter_int($_GET['selectedGroup'] ?? null); $selectedGroup = Validation::filter_int($_GET['selectedGroup'] ?? null);
$model = new MdlAdmin(); $model = new MdlAdmin();
$groups = $model->getAllGroups(); $groups = $model->getAllGroups();
$users = $model->getUsersOfGroup($selectedGroup); $users = $model->getUsersOfGroup($selectedGroup);
$unassignedUsers = $model->getUnassignedUsers(); $unassignedUsers = $model->getUnassignedUsers();
echo $twig->render('manageGroupView.html', ['groups' => $groups, 'selectedGroup' => $selectedGroup, 'users' => $users, 'unassignedUsers' => $unassignedUsers]);
echo $twig->render('manageGroupView.html', ['groups' => $groups, 'selectedGroup' => $selectedGroup, 'users' => $users, 'unassignedUsers' => $unassignedUsers, 'userID' => $user->getId()]);
} }
catch (Exception $e) { catch (Exception $e) {
throw new Exception("invalid group ID"); throw new Exception("invalid group ID");
@ -113,10 +120,10 @@ class AdminController
public function addUserToGroup(): void { public function addUserToGroup(): void {
try { try {
$user = Validation::filter_int($_GET['userID'] ?? null); global $user;
$group = Validation::filter_int($_GET['groupID'] ?? null); $group = Validation::filter_int($_GET['groupID'] ?? null);
$model = new MdlAdmin(); $model = new MdlAdmin();
$model->addUserToGroup($user, $group); $model->addUserToGroup($user->getId(), $group);
$_GET['selectedGroup'] = $group; $_GET['selectedGroup'] = $group;
$this->showGroupDetails(); $this->showGroupDetails();
} }

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

@ -21,11 +21,10 @@
<section> <section>
<h1>Add words</h1> <h1>Add words</h1>
{% if user is defined %} {% if user is defined %}
<form action="index.php" method="GET"> <form action="{{base}}/teacher/addVocabList" method="GET">
<table> <table>
<tr> <tr>
<td colspan="2"> <td colspan="2">
<input type="hidden" name="action" value="addVocabList">
<input type="hidden" name="userID" value="{{user}}"> <input type="hidden" name="userID" value="{{user}}">
<input type="text" name="listName" placeholder="list name" required> <input type="text" name="listName" placeholder="list name" required>
</td> </td>

@ -1,4 +1,5 @@
<table> <table>
{{ userID }}
{% if groups is defined %} {% if groups is defined %}
{% for row in groups %} {% for row in groups %}
{% if selectedGroup is defined and selectedGroup == row.id %} {% if selectedGroup is defined and selectedGroup == row.id %}
@ -21,7 +22,7 @@
{% if 'showGroupDetails' in actions %} {% if 'showGroupDetails' in actions %}
<td> <td>
<a href="showGroupDetails?selectedGroup={{ row.id }}"> <a href="{{base}}/admin/{{userID}}/showGroupDetails?selectedGroup={{ row.id }}">
<input class="btn-black" type="button" value="Show"/> <input class="btn-black" type="button" value="Show"/>
</a> </a>
</td> </td>
@ -29,7 +30,7 @@
{% if 'removeGroup' in actions %} {% if 'removeGroup' in actions %}
<td> <td>
<a href="removeGroup?selectedGroup={{ row.id }}"> <a href="{{base}}/admin/{{userID}}/removeGroup?selectedGroup={{ row.id }}">
<input class="btn-black" type="button" value="Remove"/> <input class="btn-black" type="button" value="Remove"/>
</a> </a>
</td> </td>

@ -28,7 +28,6 @@
<h2>Group list</h2> <h2>Group list</h2>
{% include 'groupContainer.twig' with {'actions' : ['showGroupDetails', 'removeGroup']} %} {% include 'groupContainer.twig' with {'actions' : ['showGroupDetails', 'removeGroup']} %}
</section> </section>
<section class="users"> <section class="users">
<h2>Users of the group</h2> <h2>Users of the group</h2>
{% include 'userContainer.twig' with {'users' : users, 'action' : 'removeUserFromGroup'} %} {% include 'userContainer.twig' with {'users' : users, 'action' : 'removeUserFromGroup'} %}

@ -1,4 +1,4 @@
<form action="modifyPassword" method="GET"> <form action="{{base}}/user/modifyPassword" method="GET">
<input type="hidden" name="user" value={{user.id}}> <input type="hidden" name="user" value={{user.id}}>
<input type="text" name="currentPassword" placeholder="current password" required> <input type="text" name="currentPassword" placeholder="current password" required>
<input type="text" name="newPassword" placeholder="new password" required> <input type="text" name="newPassword" placeholder="new password" required>

@ -32,7 +32,7 @@
<tr><td>ID : </td><td>{{user.id}}</td></tr> <tr><td>ID : </td><td>{{user.id}}</td></tr>
<tr><td>Nickname : </td><td>{{user.nickname}}</td> <tr><td>Nickname : </td><td>{{user.nickname}}</td>
<td> <td>
<form action="modifyNickname" method="GET"> <form action="{{base}}/user/modifyNickname" method="GET">
<input type="hidden" name="user" value={{user.id}}> <input type="hidden" name="user" value={{user.id}}>
<input name="newNickname" type="text" placeholder="new nickname" required> <input name="newNickname" type="text" placeholder="new nickname" required>
<input type="submit" value="Modify your nickname"> <input type="submit" value="Modify your nickname">

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

Loading…
Cancel
Save