diff --git a/Project/db/defaultinsert.sql b/Project/db/defaultinsert.sql index ac79364..5682267 100755 --- a/Project/db/defaultinsert.sql +++ b/Project/db/defaultinsert.sql @@ -73,8 +73,8 @@ INSERT INTO Vocabulary VALUES ("Motorbike"); INSERT INTO Register VALUES ("English", "Cat"); INSERT INTO Register VALUES ("English", "Dog"); INSERT INTO Register VALUES ("English", "Rabbit"); -INSERT INTO REGISTER VALUES ("English", "Mouse"); -INSERT INTO REGISTER VALUES ("English", "Fish"); +INSERT INTO Register VALUES ("English", "Mouse"); +INSERT INTO Register VALUES ("English", "Fish"); INSERT INTO Register VALUES ("English", "Computer"); INSERT INTO Register VALUES ("English", "Motorbike"); @@ -208,4 +208,4 @@ INSERT INTO Translate VALUES (null, "entreprises", "Corporations Firms / Compani INSERT INTO Translate VALUES (null, "président", "The Chairman", 4); INSERT INTO Translate VALUES (null, "la gestion, ou les cadres de l’entreprise", "Management", 4); INSERT INTO Translate VALUES (null, "fournisseur", "A Supplier", 4); -INSERT INTO Translate VALUES (null, "détaillant", "Retailer", 4); \ No newline at end of file +INSERT INTO Translate VALUES (null, "détaillant", "Retailer", 4); diff --git a/Project/php/controller/AdminController.php b/Project/php/controller/AdminController.php index 43d7b39..cbc9da9 100755 --- a/Project/php/controller/AdminController.php +++ b/Project/php/controller/AdminController.php @@ -10,37 +10,41 @@ class AdminController { public function showAllUsers(): void { global $twig; + global $user; $model = new MdlAdmin(); $users = $model->getAllUsers(); - echo $twig->render('usersView.html', ['users' => $users]); + echo $twig->render('usersView.html', ['users' => $users, 'userID' => $user->getId()]); } public function showAllAdmins(): void { global $twig; + global $user; $model = new MdlAdmin(); $users = $model->getAllAdmins(); - echo $twig->render('usersView.html', ['users' => $users]); + echo $twig->render('usersView.html', ['users' => $users, 'userID' => $user->getId()]); } public function showAllTeachers(): void { global $twig; + global $user; $model = new MdlAdmin(); $users = $model->getAllTeachers(); - echo $twig->render('usersView.html', ['users' => $users]); + echo $twig->render('usersView.html', ['users' => $users, 'userID' => $user->getId()]); } public function showAllStudents(): void { global $twig; + global $user; $model = new MdlAdmin(); $users = $model->getAllStudents(); - echo $twig->render('usersView.html', ['users' => $users]); + echo $twig->render('usersView.html', ['users' => $users, 'userID' => $user->getId()]); } public function removeUser(): void { try { - $id = Validation::filter_int($_GET['userID'] ?? null); + global $user; $model = new MdlAdmin(); - $model->removeUser($id); + $model->removeUser($user->getId()); $this->showAllUsers(); } catch (Exception $e) { @@ -50,21 +54,24 @@ class AdminController public function showAllGroups(): void { global $twig; + global $user; $model = new MdlAdmin(); $groups = $model->getAllGroups(); $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 { try { global $twig; + global $user; $selectedGroup = Validation::filter_int($_GET['selectedGroup'] ?? null); $model = new MdlAdmin(); $groups = $model->getAllGroups(); $users = $model->getUsersOfGroup($selectedGroup); $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) { throw new Exception("invalid group ID"); @@ -113,10 +120,10 @@ class AdminController public function addUserToGroup(): void { try { - $user = Validation::filter_int($_GET['userID'] ?? null); + global $user; $group = Validation::filter_int($_GET['groupID'] ?? null); $model = new MdlAdmin(); - $model->addUserToGroup($user, $group); + $model->addUserToGroup($user->getId(), $group); $_GET['selectedGroup'] = $group; $this->showGroupDetails(); } diff --git a/Project/php/controller/FrontController.php b/Project/php/controller/FrontController.php index cd24ccb..5c31005 100755 --- a/Project/php/controller/FrontController.php +++ b/Project/php/controller/FrontController.php @@ -50,7 +50,6 @@ class FrontController break; default : - if ($id != null && !$this->checkIdExist($id)) throw new Exception("identifiant invalide"); if ($target == null) throw new Exception("pas de target"); if (isset($_SESSION['login']) && isset($_SESSION['roles'])) { @@ -62,6 +61,7 @@ class FrontController $mdl = new $mdl; if (is_callable(array($mdl, 'is'))) { + global $user; $user = call_user_func_array(array($mdl, 'is'), array($_SESSION['login'], $_SESSION['roles'])); if (!$user || $user->getId() != $id) throw new Exception("erreur 403 permission denied"); diff --git a/Project/php/navBar.html b/Project/php/navBar.html new file mode 100755 index 0000000..de32be1 --- /dev/null +++ b/Project/php/navBar.html @@ -0,0 +1,43 @@ + + + + + + + + In English Please ! + + + + + + + + + + + + + + + + diff --git a/Project/php/templates/addGroupForm.twig b/Project/php/templates/addGroupForm.twig index 3109779..3c0ca32 100755 --- a/Project/php/templates/addGroupForm.twig +++ b/Project/php/templates/addGroupForm.twig @@ -1,4 +1,4 @@ -
+ diff --git a/Project/php/templates/addVocalList.html b/Project/php/templates/addVocalList.html index 7bd0c2e..461ebc3 100755 --- a/Project/php/templates/addVocalList.html +++ b/Project/php/templates/addVocalList.html @@ -21,11 +21,10 @@

Add words

{% if user is defined %} - + diff --git a/Project/php/templates/groupContainer.twig b/Project/php/templates/groupContainer.twig index 7bdb423..ec79f7a 100755 --- a/Project/php/templates/groupContainer.twig +++ b/Project/php/templates/groupContainer.twig @@ -1,4 +1,5 @@
-
+ {{ userID }} {% if groups is defined %} {% for row in groups %} {% if selectedGroup is defined and selectedGroup == row.id %} @@ -21,7 +22,7 @@ {% if 'showGroupDetails' in actions %} @@ -29,7 +30,7 @@ {% if 'removeGroup' in actions %} diff --git a/Project/php/templates/manageGroupView.html b/Project/php/templates/manageGroupView.html index 595945a..fd06196 100755 --- a/Project/php/templates/manageGroupView.html +++ b/Project/php/templates/manageGroupView.html @@ -24,22 +24,21 @@ } -
-

Group list

- {% include 'groupContainer.twig' with {'actions' : ['showGroupDetails', 'removeGroup']} %} -
- -
-

Users of the group

- {% include 'userContainer.twig' with {'users' : users, 'action' : 'removeUserFromGroup'} %} -
-
-

Add group

- {% include 'addGroupForm.twig' %} -
-
-

Unassigned users

- {% include 'userContainer.twig' with {'users' : unassignedUsers, 'action' : 'addUserToGroup'} %} -
+
+

Group list

+ {% include 'groupContainer.twig' with {'actions' : ['showGroupDetails', 'removeGroup']} %} +
+
+

Users of the group

+ {% include 'userContainer.twig' with {'users' : users, 'action' : 'removeUserFromGroup'} %} +
+
+

Add group

+ {% include 'addGroupForm.twig' %} +
+
+

Unassigned users

+ {% include 'userContainer.twig' with {'users' : unassignedUsers, 'action' : 'addUserToGroup'} %} +
\ No newline at end of file diff --git a/Project/php/templates/modifyPasswordForm.twig b/Project/php/templates/modifyPasswordForm.twig index 0b3e503..817c662 100755 --- a/Project/php/templates/modifyPasswordForm.twig +++ b/Project/php/templates/modifyPasswordForm.twig @@ -1,4 +1,4 @@ - + diff --git a/Project/php/templates/myAccountView.html b/Project/php/templates/myAccountView.html index a9dfded..d20200b 100755 --- a/Project/php/templates/myAccountView.html +++ b/Project/php/templates/myAccountView.html @@ -32,7 +32,7 @@
- + - +
ID : {{user.id}}
Nickname : {{user.nickname}} - + diff --git a/Project/php/templates/quizContainer.twig b/Project/php/templates/quizContainer.twig deleted file mode 100755 index 8a9d371..0000000 --- a/Project/php/templates/quizContainer.twig +++ /dev/null @@ -1,61 +0,0 @@ - - - - {% if translations is defined %} - {% for row in translations %} - - - - - - - - - - - Manage groups - - - -
-

Quiz

- - {% if translations is defined %} - {% for translation in translations %} -

{{ translation.word1 }}

- {% set answers = [translation.word2] %} - {% for i in 0..3 %} - {{ answers[i] }}
- {% endfor %} - {% endfor %} - {% endif %} - - - -

Translator

-
- {% if translations is defined %} -
{{ row.id }}{{ row.word1 }}{{ row.word2 }}{{ row.listVocab }}
- - - - - - - {% for translation in translations %} - - - - - - - {% endfor %} -
IDWord 1Word 2List Vocabulary
{{ translation.id }}{{ translation.word1 }}{{ translation.word2 }}{{ translation.listVocab }}
- {% endif %} - - - - - - -
\ No newline at end of file diff --git a/Project/php/templates/userContainer.twig b/Project/php/templates/userContainer.twig index fb83c49..d13345b 100755 --- a/Project/php/templates/userContainer.twig +++ b/Project/php/templates/userContainer.twig @@ -24,17 +24,17 @@ {% if action is defined %} {% if action == 'removeUserFromGroup' %} - + {% elseif action == 'addUserToGroup' %} - + {% elseif action == 'removeUser' %} - + {% endif %}