From b97d796715b3f27b5b8859e4215a4e0dd76aa4df Mon Sep 17 00:00:00 2001 From: fredtempez Date: Mon, 9 Oct 2023 19:10:48 +0200 Subject: [PATCH] Ajoute le filtre dans la liste des membres --- core/core.php | 8 +- core/module/course/course.php | 8 +- core/module/course/view/user/user.php | 2 +- core/module/user/user.php | 237 ++++++++++++++++---------- core/module/user/view/index/index.php | 37 ++++ 5 files changed, 193 insertions(+), 99 deletions(-) diff --git a/core/core.php b/core/core.php index cf046c6..af5c311 100644 --- a/core/core.php +++ b/core/core.php @@ -146,24 +146,24 @@ class common public static $groups = [ self::GROUP_BANNED => 'Banni', self::GROUP_VISITOR => 'Visiteur', - self::GROUP_MEMBER => 'Etudiant', + self::GROUP_MEMBER => 'Étudiant', self::GROUP_EDITOR => 'Enseignant', self::GROUP_ADMIN => 'Administrateur' ]; public static $groupEdits = [ self::GROUP_BANNED => 'Banni', - self::GROUP_MEMBER => 'Etudiant', + self::GROUP_MEMBER => 'Étudiant', self::GROUP_EDITOR => 'Enseignant', self::GROUP_ADMIN => 'Administrateur' ]; public static $groupNews = [ - self::GROUP_MEMBER => 'Etudiant', + self::GROUP_MEMBER => 'Étudiant', self::GROUP_EDITOR => 'Enseignant', self::GROUP_ADMIN => 'Administrateur' ]; public static $groupPublics = [ self::GROUP_VISITOR => 'Visiteur', - self::GROUP_MEMBER => 'Etudiant', + self::GROUP_MEMBER => 'Étudiant', self::GROUP_EDITOR => 'Enseignant', self::GROUP_ADMIN => 'Administrateur' ]; diff --git a/core/module/course/course.php b/core/module/course/course.php index e9fc7a4..c38a4c2 100644 --- a/core/module/course/course.php +++ b/core/module/course/course.php @@ -54,7 +54,7 @@ class course extends common public static $alphabet = []; - public static $groups = [ + public static $courseGroups = [ 'all' => 'Tous' ]; @@ -382,8 +382,8 @@ class course extends common public function user() { // Liste des groupes et des profils - $groups = $this->getData(['profil']); - foreach ($groups as $groupId => $groupValue) { + $courseGroups = $this->getData(['profil']); + foreach ($courseGroups as $groupId => $groupValue) { switch ($groupId) { case "-1": case "0": @@ -393,7 +393,7 @@ class course extends common case "2": foreach ($groupValue as $profilId => $profilValue) { if ($profilId) { - self::$groups[$groupId . $profilId] = sprintf(helper::translate('Groupe %s - Profil %s'), self::$groupPublics[$groupId], $profilValue['name']); + self::$courseGroups[$groupId . $profilId] = sprintf(helper::translate('Groupe %s - Profil %s'), self::$groupPublics[$groupId], $profilValue['name']); } } } diff --git a/core/module/course/view/user/user.php b/core/module/course/view/user/user.php index af7fa28..f7cdea9 100644 --- a/core/module/course/view/user/user.php +++ b/core/module/course/view/user/user.php @@ -26,7 +26,7 @@
- 'Groupes / Profils', 'selected' => isset($_POST['courseFilterGroup']) ? $_POST['courseFilterGroup'] : 'all', ]); ?> diff --git a/core/module/user/user.php b/core/module/user/user.php index df67dcb..1d6a007 100644 --- a/core/module/user/user.php +++ b/core/module/user/user.php @@ -73,6 +73,12 @@ class user extends common public static $profils = []; + public static $alphabet = []; + + public static $courseGroups = [ + 'all' => 'Tous' + ]; + /** * Ajout */ @@ -430,10 +436,59 @@ class user extends common */ public function index() { + // Liste des groupes et des profils + $courseGroups = $this->getData(['profil']); + foreach ($courseGroups as $groupId => $groupValue) { + switch ($groupId) { + case "-1": + case "0": + case "3": + break; + case "1": + case "2": + foreach ($groupValue as $profilId => $profilValue) { + if ($profilId) { + self::$courseGroups[$groupId . $profilId] = sprintf(helper::translate('Groupe %s - Profil %s'), self::$groupPublics[$groupId], $profilValue['name']); + } + } + } + } + // Liste alphabétique + self::$alphabet = range('A', 'Z'); + $alphabet = range('A', 'Z'); + self::$alphabet = array_combine($alphabet, self::$alphabet); + self::$alphabet = array_merge(['all' => 'Toute'], self::$alphabet); + $userIdsFirstnames = helper::arrayColumn($this->getData(['user']), 'firstname'); ksort($userIdsFirstnames); foreach ($userIdsFirstnames as $userId => $userFirstname) { if ($this->getData(['user', $userId, 'group'])) { + // Filtres + if ($this->isPost()) { + // Groupe et profils + $group = (string) $this->getData(['user', $userId, 'group']); + $profil = (string) $this->getData(['user', $userId, 'profil']); + $firstName = $this->getData(['user', $userId, 'firstname']); + $lastName = $this->getData(['user', $userId, 'lastname']); + if ( + $this->getInput('userFilterGroup', helper::FILTER_INT) > 0 + && $this->getInput('userFilterGroup', helper::FILTER_STRING_SHORT) !== $group . $profil + ) + continue; + // Première lettre du prénom + if ( + $this->getInput('userFilterFirstName', helper::FILTER_STRING_SHORT) !== 'all' + && $this->getInput('userFilterFirstName', helper::FILTER_STRING_SHORT) !== strtoupper(substr($firstName, 0, 1)) + ) + continue; + // Première lettre du nom + if ( + $this->getInput('userFilterLastName', helper::FILTER_STRING_SHORT) !== 'all' + && $this->getInput('userFilterLastName', helper::FILTER_STRING_SHORT) !== strtoupper(substr($lastName, 0, 1)) + ) + continue; + } + // Formatage de la liste $group = helper::translate(self::$groups[(int) $this->getData(['user', $userId, 'group'])]); $profil = $this->getData(['profil', $this->getData(['user', $userId, 'group']), $this->getData(['user', $userId, 'profil']), 'name']); self::$users[] = [ @@ -499,7 +554,7 @@ class user extends common foreach ($groupData as $profilId => $profilData) { self::$userGroups[$groupId . '.' . $profilId] = [ $groupId . '-' . $profilId, - helper::translate(self::$groups[$groupId]). '
Profil : ' . helper::translate($profilData['name']), + helper::translate(self::$groups[$groupId]) . '
Profil : ' . helper::translate($profilData['name']), nl2br(helper::translate($profilData['comment'])), template::button('profilEdit' . $groupId . $profilId, [ 'href' => helper::baseUrl() . 'user/profilEdit/' . $groupId . '/' . $profilId, @@ -535,96 +590,97 @@ class user extends common if ( $this->getUser('permission', __CLASS__, __FUNCTION__) === true && $this->isPost() - ) { + ) { - // Effacer les données du numéro de profil ancien - $group = $this->getInput('profilEditGroup', helper::FILTER_STRING_SHORT, true); - // Les profils 1 sont désactivés dans le formulaire - $profil = empty($this->getInput('profilEditProfil')) ? '1' : $this->getInput('profilEditProfil') ; - $oldProfil = $this->getInput('profilEditOldProfil', helper::FILTER_STRING_SHORT); - // Gère le chemin - $fileManager = $this->getInput('profilEditFileManager', helper::FILTER_BOOLEAN); - $path = $this->getInput('profilEditPath'); - if ($group <= self::GROUP_ADMIN - && $fileManager - && empty($path) - ) { - $fileManager = false; - } - if ($profil !== $profil) { - $this->deleteData(['profil', $group, $oldProfil]); - } - // Données du formulaire - $data = [ - 'name' => $this->getInput('profilEditName', helper::FILTER_STRING_SHORT, true), - 'readonly' => false, - 'permanent' => $group === '1' ? true : false, - 'comment' => $this->getInput('profilEditComment', helper::FILTER_STRING_SHORT, true), - 'filemanager' => $fileManager, - 'file' => [ - 'download' => $this->getInput('profilEditDownload', helper::FILTER_BOOLEAN), - 'edit' => $this->getInput('profilEditEdit', helper::FILTER_BOOLEAN), - 'create' => $this->getInput('profilEditCreate', helper::FILTER_BOOLEAN), - 'rename' => $this->getInput('profilEditRename', helper::FILTER_BOOLEAN), - 'upload' => $this->getInput('profilEditUpload', helper::FILTER_BOOLEAN), - 'delete' => $this->getInput('profilEditDelete', helper::FILTER_BOOLEAN), - 'preview' => $this->getInput('profilEditPreview', helper::FILTER_BOOLEAN), - 'duplicate' => $this->getInput('profilEditDuplicate', helper::FILTER_BOOLEAN), - 'extract' => $this->getInput('profilEditExtract', helper::FILTER_BOOLEAN), - 'copycut' => $this->getInput('profilEditCopycut', helper::FILTER_BOOLEAN), - 'chmod' => $this->getInput('profilEditChmod', helper::FILTER_BOOLEAN), - ], - 'folder' => [ - 'create' => $this->getInput('profilEditFolderCreate', helper::FILTER_BOOLEAN), - 'delete' => $this->getInput('profilEditFolderDelete', helper::FILTER_BOOLEAN), - 'rename' => $this->getInput('profilEditFolderRename', helper::FILTER_BOOLEAN), - 'copycut' => $this->getInput('profilEditFolderCopycut', helper::FILTER_BOOLEAN), - 'chmod' => $this->getInput('profilEditFolderChmod', helper::FILTER_BOOLEAN), - 'path' => $path, - ], - 'page' => [ - 'add' => $this->getInput('profilEditPageAdd', helper::FILTER_BOOLEAN), - 'edit' => $this->getInput('profilEditPageEdit', helper::FILTER_BOOLEAN), - 'delete' => $this->getInput('profilEditPageDelete', helper::FILTER_BOOLEAN), - 'duplicate' => $this->getInput('profilEditPageDuplicate', helper::FILTER_BOOLEAN), - 'module' => $this->getInput('profilEditPageModule', helper::FILTER_BOOLEAN), - 'cssEditor' => $this->getInput('profilEditPagecssEditor', helper::FILTER_BOOLEAN), - 'jsEditor' => $this->getInput('profilEditPagejsEditor', helper::FILTER_BOOLEAN), - ], - 'user' => [ - 'edit' => $this->getInput('profilEditUserEdit', helper::FILTER_BOOLEAN), - ] - ]; - - // Données des modules - $dataModules = helper::getModules(); - if (is_array($dataModules)) { - foreach ($dataModules as $moduleId => $moduleValue) { - if (file_exists('module/' . $moduleId . '/profil/main/edit.inc.php')) { - include('module/' . $moduleId . '/profil/main/edit.inc.php'); - if (is_array($moduleData[$moduleId])) { - $data = array_merge($data, [$moduleId => $moduleData[$moduleId]]); - } + // Effacer les données du numéro de profil ancien + $group = $this->getInput('profilEditGroup', helper::FILTER_STRING_SHORT, true); + // Les profils 1 sont désactivés dans le formulaire + $profil = empty($this->getInput('profilEditProfil')) ? '1' : $this->getInput('profilEditProfil'); + $oldProfil = $this->getInput('profilEditOldProfil', helper::FILTER_STRING_SHORT); + // Gère le chemin + $fileManager = $this->getInput('profilEditFileManager', helper::FILTER_BOOLEAN); + $path = $this->getInput('profilEditPath'); + if ( + $group <= self::GROUP_ADMIN + && $fileManager + && empty($path) + ) { + $fileManager = false; + } + if ($profil !== $profil) { + $this->deleteData(['profil', $group, $oldProfil]); + } + // Données du formulaire + $data = [ + 'name' => $this->getInput('profilEditName', helper::FILTER_STRING_SHORT, true), + 'readonly' => false, + 'permanent' => $group === '1' ? true : false, + 'comment' => $this->getInput('profilEditComment', helper::FILTER_STRING_SHORT, true), + 'filemanager' => $fileManager, + 'file' => [ + 'download' => $this->getInput('profilEditDownload', helper::FILTER_BOOLEAN), + 'edit' => $this->getInput('profilEditEdit', helper::FILTER_BOOLEAN), + 'create' => $this->getInput('profilEditCreate', helper::FILTER_BOOLEAN), + 'rename' => $this->getInput('profilEditRename', helper::FILTER_BOOLEAN), + 'upload' => $this->getInput('profilEditUpload', helper::FILTER_BOOLEAN), + 'delete' => $this->getInput('profilEditDelete', helper::FILTER_BOOLEAN), + 'preview' => $this->getInput('profilEditPreview', helper::FILTER_BOOLEAN), + 'duplicate' => $this->getInput('profilEditDuplicate', helper::FILTER_BOOLEAN), + 'extract' => $this->getInput('profilEditExtract', helper::FILTER_BOOLEAN), + 'copycut' => $this->getInput('profilEditCopycut', helper::FILTER_BOOLEAN), + 'chmod' => $this->getInput('profilEditChmod', helper::FILTER_BOOLEAN), + ], + 'folder' => [ + 'create' => $this->getInput('profilEditFolderCreate', helper::FILTER_BOOLEAN), + 'delete' => $this->getInput('profilEditFolderDelete', helper::FILTER_BOOLEAN), + 'rename' => $this->getInput('profilEditFolderRename', helper::FILTER_BOOLEAN), + 'copycut' => $this->getInput('profilEditFolderCopycut', helper::FILTER_BOOLEAN), + 'chmod' => $this->getInput('profilEditFolderChmod', helper::FILTER_BOOLEAN), + 'path' => $path, + ], + 'page' => [ + 'add' => $this->getInput('profilEditPageAdd', helper::FILTER_BOOLEAN), + 'edit' => $this->getInput('profilEditPageEdit', helper::FILTER_BOOLEAN), + 'delete' => $this->getInput('profilEditPageDelete', helper::FILTER_BOOLEAN), + 'duplicate' => $this->getInput('profilEditPageDuplicate', helper::FILTER_BOOLEAN), + 'module' => $this->getInput('profilEditPageModule', helper::FILTER_BOOLEAN), + 'cssEditor' => $this->getInput('profilEditPagecssEditor', helper::FILTER_BOOLEAN), + 'jsEditor' => $this->getInput('profilEditPagejsEditor', helper::FILTER_BOOLEAN), + ], + 'user' => [ + 'edit' => $this->getInput('profilEditUserEdit', helper::FILTER_BOOLEAN), + ] + ]; + + // Données des modules + $dataModules = helper::getModules(); + if (is_array($dataModules)) { + foreach ($dataModules as $moduleId => $moduleValue) { + if (file_exists('module/' . $moduleId . '/profil/main/edit.inc.php')) { + include('module/' . $moduleId . '/profil/main/edit.inc.php'); + if (is_array($moduleData[$moduleId])) { + $data = array_merge($data, [$moduleId => $moduleData[$moduleId]]); } } } - - //Sauvegarder le données - $this->setData([ - 'profil', - $group, - $profil, - $data - ]); - - // Valeurs en sortie - $this->addOutput([ - 'redirect' => helper::baseUrl() . 'user/profil', - 'notification' => helper::translate('Modifications enregistrées'), - 'state' => true - ]); } + //Sauvegarder le données + $this->setData([ + 'profil', + $group, + $profil, + $data + ]); + + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . 'user/profil', + 'notification' => helper::translate('Modifications enregistrées'), + 'state' => true + ]); + } + // Chemin vers les dossiers du gestionnaire de fichier self::$sharePath = $this->getSubdirectories('./site/file/source'); self::$sharePath = array_flip(self::$sharePath); @@ -681,11 +737,12 @@ class user extends common // Gère le chemin $fileManager = $this->getInput('profilAddFileManager', helper::FILTER_BOOLEAN); $path = $this->getInput('profilAddPath'); - if ($group <= self::GROUP_ADMIN - && $fileManager + if ( + $group <= self::GROUP_ADMIN + && $fileManager && empty($path) - ) { - $fileManager = false; + ) { + $fileManager = false; } if ($profil < self::MAX_PROFILS) { @@ -1116,7 +1173,7 @@ class user extends common 'pseudo' => $item['prenom'], 'signature' => 1, // Pseudo - 'password' => helper::filter($item['passe'],helper::FILTER_PASSWORD), + 'password' => helper::filter($item['passe'], helper::FILTER_PASSWORD), // A modifier à la première connexion "connectFail" => null, "connectTimeout" => null, diff --git a/core/module/user/view/index/index.php b/core/module/user/view/index/index.php index 5a3f67c..4d8984c 100644 --- a/core/module/user/view/index/index.php +++ b/core/module/user/view/index/index.php @@ -38,4 +38,41 @@ ]); ?>
+ +
+
+
+

+ +

+
+
+ 'Groupes / Profils', + 'selected' => isset($_POST['userFilterGroup']) ? $_POST['userFilterGroup'] : 'all', + ]); ?> +
+
+ 'Prénom commence par', + 'selected' => isset($_POST['userFilterFirstName']) ? $_POST['userFilterFirstName'] : 'all', + ]); ?> +
+
+ 'Nom commence par', + 'selected' => isset($_POST['userFilterLastName']) ? $_POST['userFilterLastName'] : 'all', + ]); ?> +
+
+ 'Filtrer', + 'uniqueSubmission' => true + ]); ?> +
+
+
+
+
+ \ No newline at end of file