From d364b11012f76fa5f742aef05ff63346d3a06815 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Fri, 31 Mar 2023 17:02:56 +0200 Subject: [PATCH] Edit group Profil TEST --- core/core.php | 10 +- core/module/install/ressource/defaultdata.php | 18 +-- core/module/user/user.php | 108 +++++++++----- core/module/user/view/index/index.php | 4 +- .../permission.css => profil/profil.css} | 0 .../permission.php => profil/profil.php} | 10 +- .../profilAdd.css} | 0 core/module/user/view/profilAdd/profilAdd.php | 139 ++++++++++++++++++ .../user/view/profilEdit/profilEdit.css | 18 +++ .../profilEdit.php} | 104 +++++++------ 10 files changed, 308 insertions(+), 103 deletions(-) rename core/module/user/view/{permission/permission.css => profil/profil.css} (100%) rename core/module/user/view/{permission/permission.php => profil/profil.php} (52%) rename core/module/user/view/{permissionEdit/permissionEdit.css => profilAdd/profilAdd.css} (100%) create mode 100644 core/module/user/view/profilAdd/profilAdd.php create mode 100644 core/module/user/view/profilEdit/profilEdit.css rename core/module/user/view/{permissionEdit/permissionEdit.php => profilEdit/profilEdit.php} (63%) diff --git a/core/core.php b/core/core.php index fd60aa98..8bbe4ae1 100644 --- a/core/core.php +++ b/core/core.php @@ -234,7 +234,7 @@ class common 'theme' => '', 'user' => '', 'language' => '', - 'permission'=> '', + 'profil'=> '', ]; public static $fontsWebSafe = [ @@ -918,10 +918,10 @@ class common public function getPermission($key1, $key2 = null) { if (is_array($this->user) === false) { return false; - } elseif ($key2 === null && array_key_exists($key1, $this->getData(['permission', $this->user['group']]))) { - return $this->getData(['permission', $this->user['group'], $key1]); - } elseif ($key2 && array_key_exists($key2, $this->getData(['permission', $this->user['group'], $key1]))) { - return $this->getData(['permission', $this->user['group'], $key1, $key2]); + } elseif ($key2 === null && array_key_exists($key1, $this->getData(['profil', $this->user['group']]))) { + return $this->getData(['profil', $this->user['group'], $key1]); + } elseif ($key2 && array_key_exists($key2, $this->getData(['profil', $this->user['group'], $key1]))) { + return $this->getData(['profil', $this->user['group'], $key1, $key2]); } else { return false; } diff --git a/core/module/install/ressource/defaultdata.php b/core/module/install/ressource/defaultdata.php index c72e5b62..f4b55339 100644 --- a/core/module/install/ressource/defaultdata.php +++ b/core/module/install/ressource/defaultdata.php @@ -334,7 +334,7 @@ class init extends common ], 'blacklist' => [], 'language'=> [], - 'permission' => [ + 'profil' => [ '-1' => [ 'name' => 'Banni', 'readonly' => true, @@ -361,14 +361,14 @@ class init extends common 'duplicate' => false, 'extract' => false, 'copycut' => false, - 'permission' => false + 'chmod' => false ], 'folder' => [ 'create' => false, 'delete' => false, 'rename' => false, 'copycut' => false, - 'permission' => false, + 'chmod' => false, 'share' => false, 'path' => './site/file/source/partage/', ] @@ -388,14 +388,14 @@ class init extends common 'duplicate' => false, 'extract' => false, 'copycut' => false, - 'permission' => false + 'chmod' => false ], 'folder' => [ 'create' => false, 'delete' => false, 'rename' => false, 'copycut' => false, - 'permission' => false, + 'chmod' => false, 'share' => true, 'path' => './site/file/source/partage/', ] @@ -417,14 +417,14 @@ class init extends common 'duplicate' => false, 'extract' => false, 'copycut' => false, - 'permission' => false + 'chmod' => false ], 'folder' => [ 'create' => true, 'delete' => true, 'rename' => true, 'copycut' => false, - 'permission' => false, + 'chmod' => false, 'share' => true, 'path' => './site/file/source/partage/', ] @@ -444,14 +444,14 @@ class init extends common 'duplicate' => false, 'extract' => false, 'copycut' => false, - 'permission' => false + 'chmod' => false ], 'folder' => [ 'create' => true, 'delete' => true, 'rename' => true, 'copycut' => false, - 'permission' => false, + 'chmod' => false, 'share' => true, 'path' => './site/file/source/', ] diff --git a/core/module/user/user.php b/core/module/user/user.php index dbf7910e..5e1ba591 100644 --- a/core/module/user/user.php +++ b/core/module/user/user.php @@ -27,9 +27,9 @@ class user extends common 'forgot' => self::GROUP_VISITOR, 'login' => self::GROUP_VISITOR, 'reset' => self::GROUP_VISITOR, - 'permission' => self::GROUP_ADMIN, - 'permissionEdit' => self::GROUP_ADMIN, - 'permissionAdd' => self::GROUP_ADMIN, + 'profil' => self::GROUP_ADMIN, + 'profilEdit' => self::GROUP_ADMIN, + 'profilAdd' => self::GROUP_ADMIN, ]; public static $users = []; @@ -60,6 +60,11 @@ class user extends common '/site/file/source/' ]; + public static $groupProfils = [ + self::GROUP_MEMBER => 'Membre', + self::GROUP_MODERATOR => 'Editeur' + ]; + /** * Ajout */ @@ -411,9 +416,9 @@ class user extends common /** * Table des groupes */ - public function permission() + public function profil() { - foreach ($this->getData(['permission']) as $groupId => $groupData) { + foreach ($this->getData(['profil']) as $groupId => $groupData) { // Membres sans permissions spécifiques if ( @@ -425,8 +430,8 @@ class user extends common $groupId, $groupData['name'], nl2br($groupData['comment']), - template::button('permissionEdit' . $groupId, [ - 'href' => helper::baseUrl() . 'user/permissionEdit/' . $groupId . '/' . $_SESSION['csrf'], + template::button('profilEdit' . $groupId, [ + 'href' => helper::baseUrl() . 'user/profilEdit/' . $groupId . '/' . $_SESSION['csrf'], 'value' => template::ico('pencil'), 'help' => 'Éditer', 'disabled' => $groupData['readonly'], @@ -449,15 +454,15 @@ class user extends common $groupId . '-' . $subGroupId, self::$groups[$groupId] .'
Profil : '. $subGroupData['name'], nl2br($subGroupData['comment']), - template::button('permissionEdit' . $groupId.$subGroupId, [ - 'href' => helper::baseUrl() . 'user/permissionEdit/' . $groupId . '/' . $subGroupId . '/' . $_SESSION['csrf'], + template::button('profilEdit' . $groupId.$subGroupId, [ + 'href' => helper::baseUrl() . 'user/profilEdit/' . $groupId . '/' . $subGroupId . '/' . $_SESSION['csrf'], 'value' => template::ico('pencil'), 'help' => 'Éditer', 'disabled' => $subGroupData['readonly'], ]), - template::button('permissionDelete' . $groupId.$subGroupId, [ + template::button('profilDelete' . $groupId.$subGroupId, [ 'class' => 'userDelete buttonRed', - 'href' => helper::baseUrl() . 'user/permissionDelete/' . $groupId . '/' . $subGroupId . '/' . $_SESSION['csrf'], + 'href' => helper::baseUrl() . 'user/profilDelete/' . $groupId . '/' . $subGroupId . '/' . $_SESSION['csrf'], 'value' => template::ico('trash'), 'help' => 'Supprimer', 'disabled' => $subGroupData['readonly'], @@ -468,15 +473,15 @@ class user extends common } // Valeurs en sortie $this->addOutput([ - 'title' => helper::translate('Permissions'), - 'view' => 'permission' + 'title' => helper::translate('Profils des groupes'), + 'view' => 'profil' ]); } /** * Edition d'un groupe */ - public function permissionEdit() + public function profilEdit() { if ( $this->getUrl(4) !== $_SESSION['csrf'] @@ -491,43 +496,56 @@ class user extends common // Soumission du formulaire if ($this->isPost()) { - $group = $this->getUrl(2); + $oldGroup = $this->getUrl(2); + $group = $this->getInput('profilEditGroup'); $profil = $this->getUrl(3); + // Changement de groupe, effacer le profil de l'ancien groupe et incrément le profil + if ($oldGroup !== $group) { + $this->deleteData(['profil', $oldGroup, $profil]); + $profil = helper::increment($profil, $this->getData(['profil', $group])); + } + + echo "groupe " . $group; + echo "profil " . $profil; + exit(); $this->setData([ - 'permission', + 'profil', $group, $profil, [ - 'name' => $this->getInput('permissionEditName', null, true), + 'name' => $this->getInput('profilEditName', helper::FILTER_STRING_SHORT, true), 'readonly' => false, - 'comment' => $this->getInput('permissionEditComment', helper::FILTER_STRING_SHORT, true), + 'comment' => $this->getInput('profilEditComment', helper::FILTER_STRING_SHORT, true), 'file' => [ - 'download' => $this->getInput('permissionEditDownload', helper::FILTER_BOOLEAN), - 'edit' => $this->getInput('permissionEditEdit', helper::FILTER_BOOLEAN), - 'create' => $this->getInput('permissionEditCreate', helper::FILTER_BOOLEAN), - 'rename' => $this->getInput('permissionEditRename', helper::FILTER_BOOLEAN), - 'upload' => $this->getInput('permissionEditUpload', helper::FILTER_BOOLEAN), - 'delete' => $this->getInput('permissionEditDelete', helper::FILTER_BOOLEAN), - 'preview' => $this->getInput('permissionEditPreview', helper::FILTER_BOOLEAN), - 'duplicate' => $this->getInput('permissionEditDuplicate', helper::FILTER_BOOLEAN), - 'extract' => $this->getInput('permissionEditExtract', helper::FILTER_BOOLEAN), - 'copycut' => $this->getInput('permissionEditCopycut', helper::FILTER_BOOLEAN), - 'permission' => $this->getInput('permissionEditPermission', helper::FILTER_BOOLEAN), + '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('permissionEditFolderCreate', helper::FILTER_BOOLEAN), - 'delete' => $this->getInput('permissionEditFolderDelete', helper::FILTER_BOOLEAN), - 'rename' => $this->getInput('permissionEditFolderRename', helper::FILTER_BOOLEAN), - 'copycut' => $this->getInput('permissionEditFolderCopycut', helper::FILTER_BOOLEAN), - 'permission' => $this->getInput('permissionEditFolderPermission', helper::FILTER_BOOLEAN), - 'share' => $this->getInput('permissionEditShare', helper::FILTER_BOOLEAN), - 'path' => $this->getInput('permissionEditPath'), + '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), + 'share' => $this->getInput('profilEditShare', helper::FILTER_BOOLEAN), + 'path' => $this->getInput('profilEditPath'), ] ] ]); + + + // Valeurs en sortie $this->addOutput([ - 'redirect' => helper::baseUrl() . 'user/permission', + 'redirect' => helper::baseUrl() . 'user/profil', 'notification' => helper::translate('Modifications enregistrées'), 'state' => true ]); @@ -539,11 +557,23 @@ class user extends common // Valeurs en sortie; $this->addOutput([ - 'title' => sprintf(helper::translate('Groupe : %s - Profil : %s'), $this->getData(['permission', $this->getUrl(2), 'name']), $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'name'])), - 'view' => 'permissionEdit' + 'title' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'name']), + 'view' => 'profilEdit' ]); } + /** + * Ajouter un profil de permission + */ + + public function profilAdd() { + + // Valeurs en sortie; + $this->addOutput([ + 'title' => "Ajouter un profil", + 'view' => 'profilAdd' + ]); + } /** * Connexion diff --git a/core/module/user/view/index/index.php b/core/module/user/view/index/index.php index 80db7777..cd0e3d31 100644 --- a/core/module/user/view/index/index.php +++ b/core/module/user/view/index/index.php @@ -24,9 +24,9 @@
helper::baseUrl() . 'user/permission', + 'href' => helper::baseUrl() . 'user/profil', 'value' => template::ico('lock'), - 'help' => 'Gestion des permissions' + 'help' => 'Gestion des profils' ]); ?>
diff --git a/core/module/user/view/permission/permission.css b/core/module/user/view/profil/profil.css similarity index 100% rename from core/module/user/view/permission/permission.css rename to core/module/user/view/profil/profil.css diff --git a/core/module/user/view/permission/permission.php b/core/module/user/view/profil/profil.php similarity index 52% rename from core/module/user/view/permission/permission.php rename to core/module/user/view/profil/profil.php index a29d5e2d..fc84e6c7 100644 --- a/core/module/user/view/permission/permission.php +++ b/core/module/user/view/profil/profil.php @@ -6,5 +6,13 @@ 'value' => template::ico('left') ]); ?>
+
+ helper::baseUrl() . 'user/profilAdd', + 'value' => template::ico('plus'), + 'class' => 'buttonGreen', + 'help' => 'Ajouter un profil' + ]); ?> +
- \ No newline at end of file + \ No newline at end of file diff --git a/core/module/user/view/permissionEdit/permissionEdit.css b/core/module/user/view/profilAdd/profilAdd.css similarity index 100% rename from core/module/user/view/permissionEdit/permissionEdit.css rename to core/module/user/view/profilAdd/profilAdd.css diff --git a/core/module/user/view/profilAdd/profilAdd.php b/core/module/user/view/profilAdd/profilAdd.php new file mode 100644 index 00000000..7ca99fe3 --- /dev/null +++ b/core/module/user/view/profilAdd/profilAdd.php @@ -0,0 +1,139 @@ + +
+
+ 'buttonGrey', + 'href' => helper::baseUrl() . 'user/profil', + 'value' => template::ico('left') + ]); ?> +
+
+ +
+
+
+
+
+

+ +

+
+
+
+
+ 'Nom du profil', + 'value' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'name']) + ]); ?> +
+
+ 'Groupe', + 'selected' => $this->getUrl(2) + ]); ?> +
+
+
+
+ 'Commentaire', + 'value' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'comment']) + ]); ?> +
+
+
+
+
+
+
+
+

+ +

+
+
+ +
+
+ 'Racine du dossier' + ]); ?> +
+
+
+
+
+

+ +

+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+
+

+ +

+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+
+ + \ No newline at end of file diff --git a/core/module/user/view/profilEdit/profilEdit.css b/core/module/user/view/profilEdit/profilEdit.css new file mode 100644 index 00000000..ec846297 --- /dev/null +++ b/core/module/user/view/profilEdit/profilEdit.css @@ -0,0 +1,18 @@ +/** + * This file is part of Zwii. + * + * For full copyright and license information, please see the LICENSE + * file that was distributed with this source code. + * + * @author Rémi Jean + * @copyright Copyright (C) 2008-2018, Rémi Jean + * @author Frédéric Tempez + * @copyright Copyright (C) 2018-2023, Frédéric Tempez + * @license CC Attribution-NonCommercial-NoDerivatives 4.0 International + * @link http://zwiicms.fr/ + */ + + +/** NE PAS EFFACER +* admin.css +*/ \ No newline at end of file diff --git a/core/module/user/view/permissionEdit/permissionEdit.php b/core/module/user/view/profilEdit/profilEdit.php similarity index 63% rename from core/module/user/view/permissionEdit/permissionEdit.php rename to core/module/user/view/profilEdit/profilEdit.php index df3fa359..ded12a3b 100644 --- a/core/module/user/view/permissionEdit/permissionEdit.php +++ b/core/module/user/view/profilEdit/profilEdit.php @@ -1,33 +1,43 @@ - +
- 'buttonGrey', - 'href' => helper::baseUrl() . 'user/permission', + 'href' => helper::baseUrl() . 'user/profil', 'value' => template::ico('left') ]); ?>
- +

- +

- 'Profil', - 'value' => $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'name']) - ]); ?> +
+
+ 'Nom du profil', + 'value' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'name']) + ]); ?> +
+
+ 'Groupe', + 'selected' => $this->getUrl(2) + ]); ?> +
+
- 'Commentaire', - 'value' => $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'comment']) + 'value' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'comment']) ]); ?>
@@ -42,14 +52,14 @@
- $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'folder', 'share']) + $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'folder', 'share']) ]); ?>
- 'Racine du dossier', - 'selected' => $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'folder', 'path']) + 'selected' => $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'folder', 'path']) ]); ?>
@@ -61,28 +71,28 @@
- $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'folder', 'create']) + $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'folder', 'create']) ]); ?>
- $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'folder', 'delete']) + $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'folder', 'delete']) ]); ?>
- $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'folder', 'rename']) + $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'folder', 'rename']) ]); ?>
- $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'folder', 'copycut']) + $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'folder', 'copycut']) ]); ?>
- $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'folder', 'permission']) + $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'folder', 'chmod']) ]); ?>
@@ -97,60 +107,60 @@
- $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'file', 'download']) + $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'file', 'download']) ]); ?>
- $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'file', 'edit']) + $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'file', 'edit']) ]); ?>
- $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'file', 'create']) + $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'file', 'create']) ]); ?>
- $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'file', 'rename']) + $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'file', 'rename']) ]); ?>
- $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'file', 'upload']) + $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'file', 'upload']) ]); ?>
- $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'file', 'delete']) + $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'file', 'delete']) ]); ?>
- $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'file', 'preview']) + $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'file', 'preview']) ]); ?>
- $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'file', 'duplicate']) + $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'file', 'duplicate']) ]); ?>
- $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'file', 'extract']) + $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'file', 'extract']) ]); ?>
- $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'file', 'copycut']) + $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'file', 'copycut']) ]); ?>
- $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'file', 'permission']) + $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'file', 'chmod']) ]); ?>