From eeb96186c1b29c592c535753846ababcfbce56d7 Mon Sep 17 00:00:00 2001 From: F TEMPEZ Date: Thu, 30 Nov 2023 13:30:10 +0100 Subject: [PATCH] users : Filtre et import --- core/module/user/ressource/template.csv | 10 ++-- core/module/user/user.php | 76 +++++++++++++++++++----- core/module/user/view/add/add.php | 41 +++++++++---- core/module/user/view/edit/edit.php | 33 +++++++--- core/module/user/view/import/import.php | 31 +++++----- core/module/user/view/index/index.js.php | 12 +++- core/module/user/view/index/index.php | 59 ++++++++---------- core/module/user/view/login/login.css | 3 + core/module/user/view/login/login.php | 1 + core/module/user/view/reset/reset.php | 8 ++- 10 files changed, 181 insertions(+), 93 deletions(-) diff --git a/core/module/user/ressource/template.csv b/core/module/user/ressource/template.csv index 3c528550..aaecffe8 100755 --- a/core/module/user/ressource/template.csv +++ b/core/module/user/ressource/template.csv @@ -1,5 +1,5 @@ -id;nom;prenom;email;groupe -jm1;Membre1;Jean;jean.membre1@email.fr;1 -am2;Membre2;Albert;albert.membre2@email.fr;1 -jrediteur;Editeur;Robert;robert.editeur@email.fr;2 -padmin;Dupuis;Admin;paul.admin@email.fr;3 +id;nom;prenom;email;groupe;profil;passe;tags +jm1;Membre1;Jean;jean.membre1@email.fr;1;1;jEan05;"adhérent" +am2;Membre2;Albert;albert.membre2@email.fr;1;1;alBertAG;"adhérent" +jrediteur;Editeur;Robert;robert.editeur@email.fr;2;1;roBert54;"trésorier" +padmin;Dupuis;Admin;paul.admin@email.fr;3;0;paul32Mirabel32;"président" \ No newline at end of file diff --git a/core/module/user/user.php b/core/module/user/user.php index ca4cafb3..f213e5f6 100644 --- a/core/module/user/user.php +++ b/core/module/user/user.php @@ -75,8 +75,8 @@ class user extends common public static $alphabet = []; - public static $courseGroups = [ - 'all' => 'Tout' + public static $usersGroups = [ + 'all' => 'Tous' ]; /** @@ -133,6 +133,7 @@ class user extends common 'accessTimer' => null, 'accessCsrf' => null, 'language' => $this->getInput('userEditLanguage', helper::FILTER_STRING_SHORT), + 'tags' => '' ] ]); @@ -343,6 +344,7 @@ class user extends common 'accessCsrf' => $this->getData(['user', $this->getUrl(2), 'accessCsrf']), 'files' => $this->getInput('userEditFiles', helper::FILTER_BOOLEAN), 'language' => $this->getInput('userEditLanguage', helper::FILTER_STRING_SHORT), + 'tags' => $this->getInput('userEditTags', helper::FILTER_STRING_SHORT), ] ]); // Redirection spécifique si l'utilisateur change son mot de passe @@ -447,20 +449,22 @@ class user extends common public function index() { // Liste des groupes et des profils - $courseGroups = $this->getData(['profil']); - foreach ($courseGroups as $groupId => $groupValue) { + $usersGroups = $this->getData(['profil']); + foreach ($usersGroups as $groupId => $groupValue) { switch ($groupId) { case "-1": case "0": break; case "3": - self::$courseGroups['30'] = 'Administrateur'; + self::$usersGroups['30'] = 'Administrateur'; + $profils['30'] = 0; 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']); + self::$usersGroups[$groupId . $profilId] = sprintf(helper::translate('Groupe %s - Profil %s'), self::$groupPublics[$groupId], $profilValue['name']); + $profils[$groupId . $profilId] = 0; } } } @@ -470,13 +474,17 @@ class user extends common self::$alphabet = range('A', 'Z'); $alphabet = range('A', 'Z'); self::$alphabet = array_combine($alphabet, self::$alphabet); - self::$alphabet = array_merge(['all' => 'Tout'], self::$alphabet); + self::$alphabet = array_merge(['all' => 'Toute'], self::$alphabet); // Liste des membres $userIdsLastNames = helper::arrayColumn($this->getData(['user']), 'lastname'); ksort($userIdsLastNames); foreach ($userIdsLastNames as $userId => $userLastNames) { if ($this->getData(['user', $userId, 'group'])) { + + // Compte les rôles + $profils[$this->getData(['user', $userId, 'group']) . $this->getData(['user', $userId, 'profil'])]++; + // Filtres if ($this->isPost()) { // Groupe et profils @@ -503,6 +511,8 @@ class user extends common continue; } + + // Formatage de la liste self::$users[] = [ $userId, @@ -511,6 +521,7 @@ class user extends common empty($this->getData(['profil', $this->getData(['user', $userId, 'group']), $this->getData(['user', $userId, 'profil']), 'name'])) ? helper::translate(self::$groups[(int) $this->getData(['user', $userId, 'group'])]) : $this->getData(['profil', $this->getData(['user', $userId, 'group']), $this->getData(['user', $userId, 'profil']), 'name']), + $this->getData(['user', $userId, 'tags']), template::button('userEdit' . $userId, [ 'href' => helper::baseUrl() . 'user/edit/' . $userId, 'value' => template::ico('pencil'), @@ -523,6 +534,16 @@ class user extends common 'help' => 'Supprimer' ]) ]; + + } + } + + // Ajoute les effectifs aux profils du sélecteur + foreach (self::$usersGroups as $groupId => $groupValue) { + if ($groupId === 'all') { + self::$usersGroups['all'] = self::$usersGroups['all'] . ' (' . array_sum($profils) . ')'; + } else { + self::$usersGroups[$groupId] = self::$usersGroups[$groupId] . ' (' . $profils[$groupId] . ')'; } } @@ -702,10 +723,16 @@ class user extends common self::$sharePath = array_merge(['./site/file/source/' => 'Tous les dossiers'], self::$sharePath); self::$sharePath = array_merge([null => 'Aucun dossier'], self::$sharePath); + // Chemin vers les dossiers du gestionnaire de fichier + self::$sharePath = $this->getSubdirectories('./site/file/source'); + self::$sharePath = array_flip(self::$sharePath); + self::$sharePath = array_merge(['./site/file/source/' => 'Tous les dossiers'], self::$sharePath); + self::$sharePath = array_merge([null => 'Aucun dossier'], self::$sharePath); + // Liste des modules installés self::$listModules = helper::getModules(); self::$listModules = array_keys(self::$listModules); - + // Charge les dialogues du module pour afficher les traductions foreach (self::$listModules as $moduleId) { if ( @@ -868,7 +895,7 @@ class user extends common // Liste des modules installés self::$listModules = helper::getModules(); self::$listModules = array_keys(self::$listModules); - + // Charge les dialogues du module pour afficher les traductions foreach (self::$listModules as $moduleId) { if ( @@ -1177,17 +1204,22 @@ class user extends common and array_key_exists('prenom', $item) and array_key_exists('nom', $item) and array_key_exists('groupe', $item) + and array_key_exists('profil', $item) and array_key_exists('email', $item) and array_key_exists('passe', $item) - and $item['nom'] - and $item['prenom'] - and $item['id'] - and $item['email'] - and $item['groupe'] - and $item['passe'] + and array_key_exists('tags', $item) + and isset($item['id']) + and isset($item['nom']) + and isset($item['prenom']) + and isset($item['email']) + and isset($item['groupe']) + and isset($item['profil']) + and isset($item['passe']) + and isset($item['tags']) ) { // Validation du groupe $item['groupe'] = (int) $item['groupe']; + $item['profil'] = (int) $item['profil']; $item['groupe'] = ($item['groupe'] >= self::GROUP_BANNED and $item['groupe'] <= self::GROUP_ADMIN) ? $item['groupe'] : 1; // L'utilisateur existe @@ -1200,8 +1232,12 @@ class user extends common $item['nom'], $item['prenom'], self::$groups[$item['groupe']], + ($this->getData(['profil', $item['groupe'], $item['profil'], 'name']) !== null ) + ? $this->getData(['profil', $item['groupe'], $item['profil'], 'name']) + : $item['profil'], $item['prenom'], helper::filter($item['email'], helper::FILTER_MAIL), + $item['tags'], $item['notification'] ]; // L'utilisateur n'existe pas @@ -1216,6 +1252,7 @@ class user extends common 'firstname' => $item['prenom'], 'forgot' => 0, 'group' => $item['groupe'], + 'profil' => $item['profil'], 'lastname' => $item['nom'], 'mail' => $item['email'], 'pseudo' => $item['prenom'], @@ -1227,7 +1264,8 @@ class user extends common "connectTimeout" => null, "accessUrl" => null, "accessTimer" => null, - "accessCsrf" => null + "accessCsrf" => null, + 'tags' => $item['tags'] ] ]); // Icône de notification @@ -1253,17 +1291,23 @@ class user extends common } } // Création du tableau de confirmation + var_dump( $item['profil']); self::$users[] = [ $userId, $item['nom'], $item['prenom'], self::$groups[$item['groupe']], + ($this->getData(['profil', $item['groupe'], $item['profil'], 'name']) !== null ) + ? $this->getData(['profil', $item['groupe'], $item['profil'], 'name']) + : $item['profil'], $item['prenom'], $item['email'], + $item['tags'], $item['notification'] ]; } } + } if (empty(self::$users)) { $notification = helper::translate('Rien à importer, erreur de format ou fichier incorrect'); diff --git a/core/module/user/view/add/add.php b/core/module/user/view/add/add.php index 24245783..797946f8 100644 --- a/core/module/user/view/add/add.php +++ b/core/module/user/view/add/add.php @@ -46,13 +46,28 @@ ]); ?> - 'off', - 'label' => 'Adresse électronique' - ]); ?> - 'Langues' - ]); ?> +
+
+ 'off', + 'label' => 'Adresse électronique' + ]); ?> +
+
+ 'Langues' + ]); ?> +
+
+
+
+ 'Etiquettes', + 'value' => $this->getData(['user', $this->getUrl(2), 'tags']), + 'help' => 'Le séparateur d\'étiquettes est l\'espace' + ]); ?> +
+
@@ -110,21 +125,23 @@
-
+
implode("\n",$module::$userProfilsComments[self::GROUP_MEMBER]) + "value" => implode("\n", $module::$userProfilsComments[self::GROUP_MEMBER]) ]); ?>
-
+
implode("\n",$module::$userProfilsComments[self::GROUP_EDITOR]) + "value" => implode("\n", $module::$userProfilsComments[self::GROUP_EDITOR]) ]); ?>
implode("\n",$module::$userProfilsComments[self::GROUP_ADMIN]) + "value" => implode("\n", $module::$userProfilsComments[self::GROUP_ADMIN]) ]); ?>
diff --git a/core/module/user/view/edit/edit.php b/core/module/user/view/edit/edit.php index 7e84097e..ed885296 100644 --- a/core/module/user/view/edit/edit.php +++ b/core/module/user/view/edit/edit.php @@ -58,15 +58,30 @@ ]); ?>
- 'off', - 'label' => 'Adresse électronique', - 'value' => $this->getData(['user', $this->getUrl(2), 'mail']) - ]); ?> - 'Langue', - 'selected' => $this->getData(['user', $this->getUrl(2), 'language']) - ]); ?> +
+
+ 'off', + 'label' => 'Adresse électronique', + 'value' => $this->getData(['user', $this->getUrl(2), 'mail']) + ]); ?> +
+
+ 'Langue', + 'selected' => $this->getData(['user', $this->getUrl(2), 'language']) + ]); ?> +
+
+
+
+ 'Etiquettes', + 'value' => $this->getData(['user', $this->getUrl(2), 'tags']), + 'help' => 'Le séparateur d\'étiquettes est l\'espace' + ]); ?> +
+
diff --git a/core/module/user/view/import/import.php b/core/module/user/view/import/import.php index 50dbf723..8d8514db 100644 --- a/core/module/user/view/import/import.php +++ b/core/module/user/view/import/import.php @@ -7,20 +7,20 @@ 'value' => template::ico('left') ]); ?>
- - 'https://doc.zwiicms.fr/importation-d-une-liste-d-utilisateurs', - 'target' => '_blank', - 'value' => template::ico('help'), - 'class' => 'buttonHelp', - 'help' => 'Consulter l\'aide en ligne' - ]);*/ ?> + + 'https://doc.zwiicms.fr/importation-d-une-liste-d-utilisateurs', + 'target' => '_blank', + 'value' => template::ico('help'), + 'class' => 'buttonHelp', + 'help' => 'Consulter l\'aide en ligne' + ]);*/?>
- helper::baseUrl() . 'user/template', 'value' => template::ico('table'), 'help' => 'Télécharger un modèle' - ]); ?> + ]); ?>
-

+

+

@@ -57,11 +58,13 @@
- +
- - Compte créé | Compte créé et notifié | Erreur dans le fichier, compte non créé. + + Compte créé | + Compte créé et notifié | + Erreur dans le fichier ou le compte existe.
\ No newline at end of file diff --git a/core/module/user/view/index/index.js.php b/core/module/user/view/index/index.js.php index 3b173792..366219f0 100644 --- a/core/module/user/view/index/index.js.php +++ b/core/module/user/view/index/index.js.php @@ -10,6 +10,7 @@ * @license CC Attribution-NonCommercial-NoDerivatives 4.0 International * @link http://zwiicms.fr/ */ + $(document).ready((function () { $(".userDelete").on("click", (function () { var _this = $(this); @@ -17,7 +18,14 @@ $(document).ready((function () { $(location).attr("href", _this.attr("href")) })) })); - $("#userFilterGroup, #userFilterFirstName, #userFilterLastName").change(function() { + + $("#userFilterGroup, #userFilterFirstName, #userFilterLastName").change(function () { $("#userFilterUserForm").submit(); - }); + }); + + $('#dataTables').DataTable({ + language: { + url: "core/vendor/datatables/french.json" + } + }); })); \ No newline at end of file diff --git a/core/module/user/view/index/index.php b/core/module/user/view/index/index.php index 582bc6d2..06f59a6a 100644 --- a/core/module/user/view/index/index.php +++ b/core/module/user/view/index/index.php @@ -8,12 +8,12 @@
'https://doc.zwiicms.fr/gestion-des-utilisateurs', - 'target' => '_blank', - 'value' => template::ico('help'), - 'class' => 'buttonHelp', - 'help' => 'Consulter l\'aide en ligne' - ]);*/ ?> + 'href' => 'https://doc.zwiicms.fr/gestion-des-utilisateurs', + 'target' => '_blank', + 'value' => template::ico('help'), + 'class' => 'buttonHelp', + 'help' => 'Consulter l\'aide en ligne' + ]);*/?>
-
-
-

- -

-
-
- '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', - ]); ?> -
-
-
-
+
+ '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', + ]); ?> +
- \ No newline at end of file + 'dataTables']); ?> \ No newline at end of file diff --git a/core/module/user/view/login/login.css b/core/module/user/view/login/login.css index b16cf89a..770f367c 100755 --- a/core/module/user/view/login/login.css +++ b/core/module/user/view/login/login.css @@ -9,6 +9,8 @@ * @link http://zwiicms.fr/ */ + /** @import url("site/data/admin.css"); */ + /** NE PAS EFFACER * admin.css */ @@ -19,6 +21,7 @@ #passwordIcon { float: right; } + @media screen and (max-width: 768px) { #buttonsContainer { display: grid; diff --git a/core/module/user/view/login/login.php b/core/module/user/view/login/login.php index 789cca3c..6131a8fc 100644 --- a/core/module/user/view/login/login.php +++ b/core/module/user/view/login/login.php @@ -51,4 +51,5 @@ 'ico' => '' ]); ?>
+
\ No newline at end of file diff --git a/core/module/user/view/reset/reset.php b/core/module/user/view/reset/reset.php index 926d600e..547ba614 100644 --- a/core/module/user/view/reset/reset.php +++ b/core/module/user/view/reset/reset.php @@ -12,7 +12,13 @@
-
+
+ helper::baseUrl(), + 'value' => template::ico('left') + ]); ?> +
+
'Valider' ]); ?>