From de84e3471b1eee0a4ea04deb07f19b2ef157a9bf Mon Sep 17 00:00:00 2001 From: fredtempez Date: Mon, 29 May 2023 18:43:30 +0200 Subject: [PATCH] Edit and Add to test profil --- core/module/user/user.php | 12 +++-- core/module/user/view/add/add.js.php | 72 +++++++++++++------------- core/module/user/view/add/add.php | 38 +++++++------- core/module/user/view/edit/edit.js.php | 2 + core/module/user/view/edit/edit.php | 20 +++++++ 5 files changed, 86 insertions(+), 58 deletions(-) diff --git a/core/module/user/user.php b/core/module/user/user.php index 42f66f75..c1c4fbb2 100644 --- a/core/module/user/user.php +++ b/core/module/user/user.php @@ -154,7 +154,7 @@ class user extends common // Profils disponibles foreach ($this->getData(['profil']) as $profilId => $profilData) { - if ($profilId < self::GROUP_MEMBER ) { + if ($profilId < self::GROUP_MEMBER) { continue; } if ($profilId === self::GROUP_ADMIN) { @@ -354,11 +354,17 @@ class user extends common // Profils disponibles foreach ($this->getData(['profil']) as $profilId => $profilData) { - if ($profilId < 1 || $profilId > 2) { + if ($profilId < self::GROUP_MEMBER) { + continue; + } + if ($profilId === self::GROUP_ADMIN) { + self::$userProfils[$profilId][self::GROUP_ADMIN] = $profilData['name']; + self::$userProfilsComments[$profilId][self::GROUP_ADMIN] = $profilData['comment']; continue; } foreach ($profilData as $key => $value) { self::$userProfils[$profilId][$key] = $profilData[$key]['name']; + self::$userProfilsComments[$profilId][$key] = $profilData[$key]['name'] . ' : ' . $profilData[$key]['comment']; } } @@ -592,7 +598,7 @@ class user extends common // Valeurs en sortie; $this->addOutput([ - 'title' => sprintf(helper::translate('Éditer le profil : %s'),$this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'name'])), + 'title' => sprintf(helper::translate('Éditer le profil : %s'), $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'name'])), 'view' => 'profilEdit' ]); } diff --git a/core/module/user/view/add/add.js.php b/core/module/user/view/add/add.js.php index 371d0825..6173f03f 100644 --- a/core/module/user/view/add/add.js.php +++ b/core/module/user/view/add/add.js.php @@ -11,40 +11,40 @@ * @link http://zwiicms.fr/ */ -/** - * Affichage de l'id en simulant FILTER_ID - */ -$("#userAddId").on("change keydown keyup", function(event) { - var userId = $(this).val(); - if( - event.keyCode !== 8 // BACKSPACE - && event.keyCode !== 37 // LEFT - && event.keyCode !== 39 // RIGHT - && event.keyCode !== 46 // DELETE - && window.getSelection().toString() !== userId // Texte sélectionné - ) { - var searchReplace = { - "á": "a", "à": "a", "â": "a", "ä": "a", "ã": "a", "å": "a", "ç": "c", "é": "e", "è": "e", "ê": "e", "ë": "e", "í": "i", "ì": "i", "î": "i", "ï": "i", "ñ": "n", "ó": "o", "ò": "o", "ô": "o", "ö": "o", "õ": "o", "ú": "u", "ù": "u", "û": "u", "ü": "u", "ý": "y", "ÿ": "y", - "Á": "A", "À": "A", "Â": "A", "Ä": "A", "Ã": "A", "Å": "A", "Ç": "C", "É": "E", "È": "E", "Ê": "E", "Ë": "E", "Í": "I", "Ì": "I", "Î": "I", "Ï": "I", "Ñ": "N", "Ó": "O", "Ò": "O", "Ô": "O", "Ö": "O", "Õ": "O", "Ú": "U", "Ù": "U", "Û": "U", "Ü": "U", "Ý": "Y", "Ÿ": "Y", - "'": "-", "\"": "-", " ": "-" - }; - userId = userId.replace(/[áàâäãåçéèêëíìîïñóòôöõúùûüýÿ'" ]/ig, function(match) { - return searchReplace[match]; - }); - userId = userId.replace(/[^a-z0-9-]/ig, ""); - $(this).val(userId); - } +$(document).ready(function () { + /** + * Affichage de l'id en simulant FILTER_ID + */ + $("#userAddId").on("change keydown keyup", function (event) { + var userId = $(this).val(); + if ( + event.keyCode !== 8 // BACKSPACE + && event.keyCode !== 37 // LEFT + && event.keyCode !== 39 // RIGHT + && event.keyCode !== 46 // DELETE + && window.getSelection().toString() !== userId // Texte sélectionné + ) { + var searchReplace = { + "á": "a", "à": "a", "â": "a", "ä": "a", "ã": "a", "å": "a", "ç": "c", "é": "e", "è": "e", "ê": "e", "ë": "e", "í": "i", "ì": "i", "î": "i", "ï": "i", "ñ": "n", "ó": "o", "ò": "o", "ô": "o", "ö": "o", "õ": "o", "ú": "u", "ù": "u", "û": "u", "ü": "u", "ý": "y", "ÿ": "y", + "Á": "A", "À": "A", "Â": "A", "Ä": "A", "Ã": "A", "Å": "A", "Ç": "C", "É": "E", "È": "E", "Ê": "E", "Ë": "E", "Í": "I", "Ì": "I", "Î": "I", "Ï": "I", "Ñ": "N", "Ó": "O", "Ò": "O", "Ô": "O", "Ö": "O", "Õ": "O", "Ú": "U", "Ù": "U", "Û": "U", "Ü": "U", "Ý": "Y", "Ÿ": "Y", + "'": "-", "\"": "-", " ": "-" + }; + userId = userId.replace(/[áàâäãåçéèêëíìîïñóòôöõúùûüýÿ'" ]/ig, function (match) { + return searchReplace[match]; + }); + userId = userId.replace(/[^a-z0-9-]/ig, ""); + $(this).val(userId); + } + }); + + /** + * Droits des groupes + */ + $("#userAddGroup").on("change", function () { + $(".userAddGroupProfil").hide(); + $(".userCommentProfil").hide(); + $("#userAddGroupProfil" + $(this).val()).show(); + $("#userCommentProfil" + $(this).val()).show(); + }).trigger("change"); + }); - -/** - * Droits des groupes - */ -$("#userAddGroup").on("change", function() { - $(".userAddGroupProfil").hide(); - $(".userCommentProfil").hide(); - $("#userAddGroupProfil" + $(this).val()).show(); - $("#userCommentProfil" + $(this).val()).show(); -}).trigger("change"); - - - diff --git a/core/module/user/view/add/add.php b/core/module/user/view/add/add.php index a5e1887b..a59e793d 100644 --- a/core/module/user/view/add/add.php +++ b/core/module/user/view/add/add.php @@ -108,25 +108,25 @@ ]); ?> -
-
- implode("\n",$module::$userProfilsComments[self::GROUP_MEMBER]) - ]); - ?> -
-
- implode("\n",$module::$userProfilsComments[self::GROUP_MODERATOR]) - ]); - ?> -
-
- implode("\n",$module::$userProfilsComments[self::GROUP_ADMIN]) - ]); - ?> -
+
+
+
+ implode("\n",$module::$userProfilsComments[self::GROUP_MEMBER]) + ]); + ?> +
+
+ implode("\n",$module::$userProfilsComments[self::GROUP_MODERATOR]) + ]); + ?> +
+
+ implode("\n",$module::$userProfilsComments[self::GROUP_ADMIN]) + ]); + ?>
diff --git a/core/module/user/view/edit/edit.js.php b/core/module/user/view/edit/edit.js.php index c270687e..b96d9d49 100644 --- a/core/module/user/view/edit/edit.js.php +++ b/core/module/user/view/edit/edit.js.php @@ -18,7 +18,9 @@ $(document).ready(function () { $("#userEditGroup").on("change", function () { $(".userEditGroupProfil").hide(); + $(".userCommentProfil").hide(); $("#userEditGroupProfil" + $(this).val()).show(); + $("#userCommentProfil" + $(this).val()).show(); }); }); \ No newline at end of file diff --git a/core/module/user/view/edit/edit.php b/core/module/user/view/edit/edit.php index 7d5a3523..2d9ca643 100644 --- a/core/module/user/view/edit/edit.php +++ b/core/module/user/view/edit/edit.php @@ -131,6 +131,26 @@ +
+
+ implode("\n",$module::$userProfilsComments[self::GROUP_MEMBER]) + ]); + ?> +
+
+ implode("\n",$module::$userProfilsComments[self::GROUP_MODERATOR]) + ]); + ?> +
+
+ implode("\n",$module::$userProfilsComments[self::GROUP_ADMIN]) + ]); + ?> +
+