From 8ac66696cb9f8031d257a38dd4110c269f4bc860 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Wed, 29 Mar 2023 14:48:09 +0200 Subject: [PATCH] =?UTF-8?q?La=20gestion=20des=20groupes=20devient=20permis?= =?UTF-8?q?sions.=20Les=20groupes=20=C3=A9tant=20immuables.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/class/layout.class.php | 4 +- core/core.php | 17 ++- core/module/install/ressource/defaultdata.php | 48 ++----- core/module/user/user.php | 78 +++++------ core/module/user/view/groupEdit/groupEdit.php | 131 ------------------ core/module/user/view/index/index.php | 6 +- .../permission.css} | 0 .../group.php => permission/permission.php} | 20 +-- .../permissionEdit.css} | 34 ++--- .../view/permissionEdit/permissionEdit.php | 131 ++++++++++++++++++ 10 files changed, 223 insertions(+), 246 deletions(-) delete mode 100644 core/module/user/view/groupEdit/groupEdit.php rename core/module/user/view/{groupEdit/groupEdit.css => permission/permission.css} (100%) rename core/module/user/view/{group/group.php => permission/permission.php} (68%) rename core/module/user/view/{group/group.css => permissionEdit/permissionEdit.css} (96%) create mode 100644 core/module/user/view/permissionEdit/permissionEdit.php diff --git a/core/class/layout.class.php b/core/class/layout.class.php index a7ef3865..bb007d6e 100644 --- a/core/class/layout.class.php +++ b/core/class/layout.class.php @@ -343,7 +343,7 @@ class layout extends common $items .= $this->getData(['theme', 'footer', 'displaymemberAccount']) === false ? ' class="displayNone">' : '>'; $items .= ' | '; if ( - $this->getgroup('folder', 'share') === true + $this->getPermission('folder', 'share') === true ) { $items .= '' . template::ico('folder', [ 'href' => helper::baseUrl(false) . 'core/vendor/filemanager/dialog.php?type=0&akey=' . md5_file(self::DATA_DIR . 'core.json') . '&lang=' . $this->getData(['user', $this->getUser('id'), 'language']), @@ -497,7 +497,7 @@ class layout extends common && $this->getData(['theme', 'menu', 'memberBar']) === true ) { if ( - $this->getGroup('folder', 'share') === true + $this->getPermission('folder', 'share') === true ) { $itemsRight .= '
  • ' . template::ico('folder', [ 'href' => helper::baseUrl(false) . 'core/vendor/filemanager/dialog.php?type=0&akey=' . md5_file(self::DATA_DIR . 'core.json') . '&lang=' . $this->getData(['user', $this->getUser('id'), 'language']), diff --git a/core/core.php b/core/core.php index dc235e33..7b04464d 100644 --- a/core/core.php +++ b/core/core.php @@ -234,7 +234,7 @@ class common 'theme' => '', 'user' => '', 'language' => '', - 'group'=> '', + 'permission'=> '', ]; public static $fontsWebSafe = [ @@ -534,7 +534,6 @@ class common */ public function getData($keys = []) { - // Eviter une requete vide if (count($keys) >= 1) { // descripteur de la base @@ -912,17 +911,17 @@ class common } /** - * Accède aux données du groupe de l'utilisateur connecté - * @param int $key Clé de la valeur + * Retourne les permission de l'utilisateur connecté + * @param int $key Clé de la valeur du groupe * @return string|null */ - public function getGroup($key1, $key2 = null) { + public function getPermission($key1, $key2 = null) { if (is_array($this->user) === false) { return false; - } elseif ($key2 === null && array_key_exists($key1, $this->getData(['group', $this->user['group']]))) { - return $this->getData(['group', $this->user['group'], $key1]); - } elseif ($key2 && array_key_exists($key2, $this->getData(['group', $this->user['group'], $key1]))) { - return $this->getData(['group', $this->user['group'], $key1, $key2]); + } 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]); } else { return false; } diff --git a/core/module/install/ressource/defaultdata.php b/core/module/install/ressource/defaultdata.php index d83875f0..01aeb252 100644 --- a/core/module/install/ressource/defaultdata.php +++ b/core/module/install/ressource/defaultdata.php @@ -334,22 +334,24 @@ class init extends common ], 'blacklist' => [], 'language'=> [], - 'group' => [ - '-1' => [ + 'permission' => [ + "banned" => [ 'name' => 'Banni', 'readonly' => true, - 'comment' => 'Accès désactivé' + 'comment' => 'Accès désactivé', + 'group' => -1, ], - '0' => [ + "visitor" => [ 'name' => 'Visiteur', 'readonly' => true, - 'comment' => 'Accède au site' + 'comment' => 'Accède au site', + 'group' => 0, ], - '1' => [ + 'member' => [ 'name' => 'Membre', 'readonly' => false, 'comment' => 'Accède aux pages réservées et à un dossier partagé', - 'path' => '/site/file/source/partage/', + 'group' => 0, 'file' => [ 'download' => false, 'edit' => false, @@ -373,11 +375,11 @@ class init extends common 'path' => '.\/site\/file\/source\/partage\/', ] ], - '2' => [ - 'name' => 'Editeur', + "moderator" => [ + 'name' => 'Moderateur', 'readonly' => false, 'comment' => 'Edition des pages', - 'path' => '/site/file/source/', + 'group' => 2, 'file' => [ 'download' => true, 'edit' => true, @@ -401,33 +403,11 @@ class init extends common 'path' => '.\/site\/file\/source\/partage\/', ] ], - '3' => [ + "admin" => [ 'name' => 'Administrateur', 'readonly' => true, 'comment' => 'Contrôle total', - 'path' => '/site/file/source/', - 'file' => [ - 'download' => true, - 'edit' => true, - 'create' => true, - 'rename' => true, - 'upload' => true, - 'delete' => true, - 'preview' => true, - 'duplicate' => true, - 'extract' => true, - 'copycut' => true, - 'permission' => true, - 'share' => false, - 'path' => '.\/site\/file\/source\/', - ], - 'folder' => [ - 'create' => true, - 'delete' => true, - 'rename' => true, - 'copycut' => true, - 'permission' => false - ] + 'group' => 3, ] ], ]; diff --git a/core/module/user/user.php b/core/module/user/user.php index 54d71741..eaa088b9 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, - 'group' => self::GROUP_ADMIN, - 'groupAdd' => self::GROUP_ADMIN, - 'groupEdit' => self::GROUP_ADMIN, + 'permission' => self::GROUP_ADMIN, + 'permissionEdit' => self::GROUP_ADMIN, + 'permissionAdd' => self::GROUP_ADMIN, ]; public static $users = []; @@ -386,7 +386,7 @@ class user extends common self::$users[] = [ $userId, $userFirstname . ' ' . $this->getData(['user', $userId, 'lastname']), - helper::translate(self::$groups[$this->getData(['user', $userId, 'group'])]), + helper::translate(self::$groups[(int)$this->getData(['user', $userId, 'group'])]), template::button('userEdit' . $userId, [ 'href' => helper::baseUrl() . 'user/edit/' . $userId . '/' . $_SESSION['csrf'], 'value' => template::ico('pencil'), @@ -411,24 +411,22 @@ class user extends common /** * Table des groupes */ - public function group() + public function permission() { - $g = $this->getData(['group']); + $g = $this->getData(['permission']); foreach ($g as $groupId => $groupData) { - self::$userGroups[$groupId] = [ - $groupId, $groupData['name'], $groupData['comment'], - template::button('groupEdit' . $groupId, [ - 'href' => helper::baseUrl() . 'user/groupEdit/' . $groupId . '/' . $_SESSION['csrf'], + template::button('permissionEdit' . $groupId, [ + 'href' => helper::baseUrl() . 'user/permissionEdit/' . $groupId . '/' . $_SESSION['csrf'], 'value' => template::ico('pencil'), 'help' => 'Éditer', 'disabled' => $groupData['readonly'], ]), - template::button('userDelete' . $groupId, [ + template::button('permissionDelete' . $groupId, [ 'class' => 'userDelete buttonRed', - 'href' => helper::baseUrl() . 'user/groupDelete/' . $groupId . '/' . $_SESSION['csrf'], + 'href' => helper::baseUrl() . 'user/permissionDelete/' . $groupId . '/' . $_SESSION['csrf'], 'value' => template::ico('trash'), 'help' => 'Supprimer', 'disabled' => $groupData['readonly'], @@ -437,15 +435,15 @@ class user extends common } // Valeurs en sortie $this->addOutput([ - 'title' => helper::translate('Groupes'), - 'view' => 'group' + 'title' => helper::translate('Permissions'), + 'view' => 'permission' ]); } /** * Edition d'un groupe */ - public function groupEdit() + public function permissionEdit() { if ( $this->getUrl(3) !== $_SESSION['csrf'] @@ -462,39 +460,39 @@ class user extends common if ($this->isPost()) { $group = $this->getUrl(2); $this->setData([ - 'group', + 'permission', $group, [ - 'name' => $this->getData(['group', $group, 'name']), - 'readonly' => $this->getData(['group', $group, 'readonly']), - 'comment' => $this->getData(['group', $group, 'comment']), + 'name' => $this->getData(['permission', $group, 'name']), + 'readonly' => $this->getData(['permission', $group, 'readonly']), + 'comment' => $this->getData(['permission', $group, 'comment']), 'file' => [ - 'download' => $this->getInput('groupEditDownload', helper::FILTER_BOOLEAN), - 'edit' => $this->getInput('groupEditEdit', helper::FILTER_BOOLEAN), - 'create' => $this->getInput('groupEditCreate', helper::FILTER_BOOLEAN), - 'rename' => $this->getInput('groupEditRename', helper::FILTER_BOOLEAN), - 'upload' => $this->getInput('groupEditUpload', helper::FILTER_BOOLEAN), - 'delete' => $this->getInput('groupEditDelete', helper::FILTER_BOOLEAN), - 'preview' => $this->getInput('groupEditPreview', helper::FILTER_BOOLEAN), - 'duplicate' => $this->getInput('groupEditDuplicate', helper::FILTER_BOOLEAN), - 'extract' => $this->getInput('groupEditExtract', helper::FILTER_BOOLEAN), - 'copycut' => $this->getInput('groupEditCopycut', helper::FILTER_BOOLEAN), - 'permission' => $this->getInput('groupEditPermission', helper::FILTER_BOOLEAN), + '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), ], 'folder' => [ - 'create' => $this->getInput('groupEditFolderCreate', helper::FILTER_BOOLEAN), - 'delete' => $this->getInput('groupEditFolderDelete', helper::FILTER_BOOLEAN), - 'rename' => $this->getInput('groupEditFolderRename', helper::FILTER_BOOLEAN), - 'copycut' => $this->getInput('groupEditFolderCopycut', helper::FILTER_BOOLEAN), - 'permission' => $this->getInput('groupEditFolderPermission', helper::FILTER_BOOLEAN), - 'share' => $this->getInput('groupEditShare', helper::FILTER_BOOLEAN), - 'path' => $this->getInput('groupEditPath'), + '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'), ] ] ]); // Valeurs en sortie $this->addOutput([ - 'redirect' => helper::baseUrl() . 'user/group', + 'redirect' => helper::baseUrl() . 'user/permission', 'notification' => helper::translate('Modifications enregistrées'), 'state' => true ]); @@ -506,8 +504,8 @@ class user extends common // Valeurs en sortie; $this->addOutput([ - 'title' => sprintf(helper::translate('Groupe %s'), $this->getData(['group', $this->getUrl(2), 'name'])), - 'view' => 'groupEdit' + 'title' => sprintf(helper::translate('Groupe %s'), $this->getData(['permission', $this->getUrl(2), 'name'])), + 'view' => 'permissionEdit' ]); } diff --git a/core/module/user/view/groupEdit/groupEdit.php b/core/module/user/view/groupEdit/groupEdit.php deleted file mode 100644 index 7d624de1..00000000 --- a/core/module/user/view/groupEdit/groupEdit.php +++ /dev/null @@ -1,131 +0,0 @@ - -
    -
    - 'buttonGrey', - 'href' => helper::baseUrl() . 'user/group', - 'value' => template::ico('left') - ]); ?> -
    -
    - -
    -
    -
    -
    -
    -

    - -

    -
    -
    - $this->getData(['group', $this->getUrl(2), 'file', 'download']) - ]); ?> -
    -
    - $this->getData(['group', $this->getUrl(2), 'file', 'edit']) - ]); ?> -
    -
    - $this->getData(['group', $this->getUrl(2), 'file', 'create']) - ]); ?> -
    -
    - $this->getData(['group', $this->getUrl(2), 'file', 'rename']) - ]); ?> -
    -
    - $this->getData(['group', $this->getUrl(2), 'file', 'upload']) - ]); ?> -
    -
    - $this->getData(['group', $this->getUrl(2), 'file', 'delete']) - ]); ?> -
    -
    -
    -
    - $this->getData(['group', $this->getUrl(2), 'file', 'preview']) - ]); ?> -
    -
    - $this->getData(['group', $this->getUrl(2), 'file', 'duplicate']) - ]); ?> -
    -
    - $this->getData(['group', $this->getUrl(2), 'file', 'extract']) - ]); ?> -
    -
    - $this->getData(['group', $this->getUrl(2), 'file', 'copycut']) - ]); ?> -
    -
    - $this->getData(['group', $this->getUrl(2), 'file', 'permission']) - ]); ?> -
    -
    -
    -
    -
    -
    -
    -
    -

    - -

    -
    -
    - $this->getData(['group', $this->getUrl(2), 'folder', 'create']) - ]); ?> -
    -
    - $this->getData(['group', $this->getUrl(2), 'folder', 'delete']) - ]); ?> -
    -
    - $this->getData(['group', $this->getUrl(2), 'folder', 'rename']) - ]); ?> -
    -
    - $this->getData(['group', $this->getUrl(2), 'folder', 'copycut']) - ]); ?> -
    -
    - $this->getData(['group', $this->getUrl(2), 'folder', 'permission']) - ]); ?> -
    -
    -
    -
    - $this->getData(['group', $this->getUrl(2), 'folder', 'share']) - ]); ?> -
    -
    - 'Racine du partage', - 'selected' => $this->getData(['group', $this->getUrl(2), 'folder', 'path']) - ]); ?> -
    -
    -
    -
    -
    - \ 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 4c73c28d..80db7777 100644 --- a/core/module/user/view/index/index.php +++ b/core/module/user/view/index/index.php @@ -24,9 +24,9 @@
    helper::baseUrl() . 'user/group', - 'value' => template::ico('users'), - 'help' => 'Gestion des groupes' + 'href' => helper::baseUrl() . 'user/permission', + 'value' => template::ico('lock'), + 'help' => 'Gestion des permissions' ]); ?>
    diff --git a/core/module/user/view/groupEdit/groupEdit.css b/core/module/user/view/permission/permission.css similarity index 100% rename from core/module/user/view/groupEdit/groupEdit.css rename to core/module/user/view/permission/permission.css diff --git a/core/module/user/view/group/group.php b/core/module/user/view/permission/permission.php similarity index 68% rename from core/module/user/view/group/group.php rename to core/module/user/view/permission/permission.php index 19a51bca..eac88fef 100644 --- a/core/module/user/view/group/group.php +++ b/core/module/user/view/permission/permission.php @@ -1,10 +1,10 @@ -
    -
    - 'buttonGrey', - 'href' => helper::baseUrl() . 'user', - 'value' => template::ico('left') - ]); ?> -
    -
    - \ No newline at end of file +
    +
    + 'buttonGrey', + 'href' => helper::baseUrl() . 'user', + 'value' => template::ico('left') + ]); ?> +
    +
    + \ No newline at end of file diff --git a/core/module/user/view/group/group.css b/core/module/user/view/permissionEdit/permissionEdit.css similarity index 96% rename from core/module/user/view/group/group.css rename to core/module/user/view/permissionEdit/permissionEdit.css index 9e5c6da2..ec846297 100644 --- a/core/module/user/view/group/group.css +++ b/core/module/user/view/permissionEdit/permissionEdit.css @@ -1,18 +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 +/** + * 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/permissionEdit/permissionEdit.php new file mode 100644 index 00000000..ee428229 --- /dev/null +++ b/core/module/user/view/permissionEdit/permissionEdit.php @@ -0,0 +1,131 @@ + +
    +
    + 'buttonGrey', + 'href' => helper::baseUrl() . 'user/permission', + 'value' => template::ico('left') + ]); ?> +
    +
    + +
    +
    +
    +
    +
    +

    + +

    +
    +
    + $this->getData(['permission', $this->getUrl(2), 'file', 'download']) + ]); ?> +
    +
    + $this->getData(['permission', $this->getUrl(2), 'file', 'edit']) + ]); ?> +
    +
    + $this->getData(['permission', $this->getUrl(2), 'file', 'create']) + ]); ?> +
    +
    + $this->getData(['permission', $this->getUrl(2), 'file', 'rename']) + ]); ?> +
    +
    + $this->getData(['permission', $this->getUrl(2), 'file', 'upload']) + ]); ?> +
    +
    + $this->getData(['permission', $this->getUrl(2), 'file', 'delete']) + ]); ?> +
    +
    +
    +
    + $this->getData(['permission', $this->getUrl(2), 'file', 'preview']) + ]); ?> +
    +
    + $this->getData(['permission', $this->getUrl(2), 'file', 'duplicate']) + ]); ?> +
    +
    + $this->getData(['permission', $this->getUrl(2), 'file', 'extract']) + ]); ?> +
    +
    + $this->getData(['permission', $this->getUrl(2), 'file', 'copycut']) + ]); ?> +
    +
    + $this->getData(['permission', $this->getUrl(2), 'file', 'permission']) + ]); ?> +
    +
    +
    +
    +
    +
    +
    +
    +

    + +

    +
    +
    + $this->getData(['permission', $this->getUrl(2), 'folder', 'create']) + ]); ?> +
    +
    + $this->getData(['permission', $this->getUrl(2), 'folder', 'delete']) + ]); ?> +
    +
    + $this->getData(['permission', $this->getUrl(2), 'folder', 'rename']) + ]); ?> +
    +
    + $this->getData(['permission', $this->getUrl(2), 'folder', 'copycut']) + ]); ?> +
    +
    + $this->getData(['permission', $this->getUrl(2), 'folder', 'permission']) + ]); ?> +
    +
    +
    +
    + $this->getData(['permission', $this->getUrl(2), 'folder', 'share']) + ]); ?> +
    +
    + 'Racine du partage', + 'selected' => $this->getData(['permission', $this->getUrl(2), 'folder', 'path']) + ]); ?> +
    +
    +
    +
    +
    + \ No newline at end of file