Gestion des permissions

This commit is contained in:
Fred Tempez 2023-03-29 19:28:03 +02:00
parent a65e8dcd63
commit 70b500443f
6 changed files with 303 additions and 204 deletions

View File

@ -343,7 +343,7 @@ class layout extends common
$items .= $this->getData(['theme', 'footer', 'displaymemberAccount']) === false ? ' class="displayNone">' : '>'; $items .= $this->getData(['theme', 'footer', 'displaymemberAccount']) === false ? ' class="displayNone">' : '>';
$items .= '<wbr>&nbsp;|&nbsp;'; $items .= '<wbr>&nbsp;|&nbsp;';
if ( if (
$this->getPermission('folder', 'share') === true $this->getUser('group') >= self::GROUP_MEMBER && $this->getPermission('folder', 'share') === true
) { ) {
$items .= '<wbr>' . template::ico('folder', [ $items .= '<wbr>' . 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']), '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 && $this->getData(['theme', 'menu', 'memberBar']) === true
) { ) {
if ( if (
$this->getPermission('folder', 'share') === true $this->getUser('group') >= self::GROUP_MEMBER && $this->getPermission('folder', 'share') === true
) { ) {
$itemsRight .= '<li>' . template::ico('folder', [ $itemsRight .= '<li>' . 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']), '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']),

View File

@ -964,6 +964,10 @@ if ($this->getData(['core', 'dataVersion']) < 12400) {
if (file_exists('core/module/install/ressource/i18n/gr_GR.json')) if (file_exists('core/module/install/ressource/i18n/gr_GR.json'))
unlink('core/module/install/ressource/i18n/gr_GR.json'); unlink('core/module/install/ressource/i18n/gr_GR.json');
// Création du dossier partga pour les nouveaux droits
if (!is_dir(self::FILE_DIR . 'source/partage')) {
mkdir(self::FILE_DIR . 'source/partage');
}
// Mise à jour // Mise à jour
$this->setData(['core', 'dataVersion', 12400]); $this->setData(['core', 'dataVersion', 12400]);

View File

@ -335,23 +335,21 @@ class init extends common
'blacklist' => [], 'blacklist' => [],
'language'=> [], 'language'=> [],
'permission' => [ 'permission' => [
"banned" => [ '-1' => [
'name' => 'Banni', 'name' => 'Banni',
'readonly' => true, 'readonly' => true,
'comment' => 'Accès désactivé', 'comment' => 'Accès désactivé',
'group' => -1,
], ],
"visitor" => [ '0' => [
'name' => 'Visiteur', 'name' => 'Visiteur',
'readonly' => true, 'readonly' => true,
'comment' => 'Accède au site', 'comment' => 'Accède au site',
'group' => 0,
], ],
'member' => [ '1' => [
'name' => 'Membre', '0' => [
'name' => 'Membre simple',
'readonly' => false, 'readonly' => false,
'comment' => 'Accède aux pages réservées et à un dossier partagé', 'comment' => 'Accède aux pages réservées',
'group' => 0,
'file' => [ 'file' => [
'download' => false, 'download' => false,
'edit' => false, 'edit' => false,
@ -375,11 +373,39 @@ class init extends common
'path' => './site/file/source/partage/', 'path' => './site/file/source/partage/',
] ]
], ],
"moderator" => [ '1' => [
'name' => 'Moderateur', 'name' => 'Membre',
'readonly' => false,
'comment' => 'Accède aux pages réservées et à un dossier partagé',
'file' => [
'download' => false,
'edit' => false,
'create' => false,
'rename' => false,
'upload' => false,
'delete' => false,
'preview' => false,
'duplicate' => false,
'extract' => false,
'copycut' => false,
'permission' => false
],
'folder' => [
'create' => false,
'delete' => false,
'rename' => false,
'copycut' => false,
'permission' => false,
'share' => true,
'path' => './site/file/source/partage/',
]
],
],
'2' => [
'0' => [
'name' => 'Modérateur',
'readonly' => false, 'readonly' => false,
'comment' => 'Edition des pages', 'comment' => 'Edition des pages',
'group' => 2,
'file' => [ 'file' => [
'download' => true, 'download' => true,
'edit' => true, 'edit' => true,
@ -399,17 +425,44 @@ class init extends common
'rename' => true, 'rename' => true,
'copycut' => false, 'copycut' => false,
'permission' => false, 'permission' => false,
'share' => false, 'share' => true,
'path' => './site/file/source/partage/', 'path' => './site/file/source/partage/',
] ]
], ],
"admin" => [ '1' => [
'name' => 'Editeur avec gestion des fichiers',
'readonly' => false,
'comment' => 'Edition des pages',
'file' => [
'download' => true,
'edit' => true,
'create' => true,
'rename' => true,
'upload' => true,
'delete' => false,
'preview' => true,
'duplicate' => false,
'extract' => false,
'copycut' => false,
'permission' => false
],
'folder' => [
'create' => true,
'delete' => true,
'rename' => true,
'copycut' => false,
'permission' => false,
'share' => true,
'path' => './site/file/source/',
]
],
],
'3' => [
'name' => 'Administrateur', 'name' => 'Administrateur',
'readonly' => true, 'readonly' => true,
'comment' => 'Contrôle total', 'comment' => 'Contrôle total',
'group' => 3,
] ]
], ]
]; ];
public static $defaultDataI18n = [ public static $defaultDataI18n = [
'en_EN' => [ 'en_EN' => [

View File

@ -413,9 +413,16 @@ class user extends common
*/ */
public function permission() public function permission()
{ {
$g = $this->getData(['permission']); foreach ($this->getData(['permission']) as $groupId => $groupData) {
foreach ($g as $groupId => $groupData) {
// Membres sans permissions spécifiques
if (
$groupId == -1 ||
$groupId == 0 ||
$groupId == 3
) {
self::$userGroups[$groupId] = [ self::$userGroups[$groupId] = [
$groupId,
$groupData['name'], $groupData['name'],
$groupData['comment'], $groupData['comment'],
template::button('permissionEdit' . $groupId, [ template::button('permissionEdit' . $groupId, [
@ -432,6 +439,30 @@ class user extends common
'disabled' => $groupData['readonly'], 'disabled' => $groupData['readonly'],
]) ])
]; ];
} else {
// Enumérer les sous groupes MEMBER et MODERATOR
foreach ($groupData as $subGroupId => $subGroupData) {
echo $subGroupId;
self::$userGroups[$groupId.'.'.$subGroupId] = [
$groupId . '-' . $subGroupId,
$subGroupData['name'],
$subGroupData['comment'],
template::button('permissionEdit' . $groupId.$subGroupId, [
'href' => helper::baseUrl() . 'user/permissionEdit/' . $groupId . '-' . $subGroupId . '/' . $_SESSION['csrf'],
'value' => template::ico('pencil'),
'help' => 'Éditer',
'disabled' => $subGroupData['readonly'],
]),
template::button('permissionDelete' . $groupId.$subGroupId, [
'class' => 'userDelete buttonRed',
'href' => helper::baseUrl() . 'user/permissionDelete/' . $groupId . '-' . $subGroupId . '/' . $_SESSION['csrf'],
'value' => template::ico('trash'),
'help' => 'Supprimer',
'disabled' => $subGroupData['readonly'],
])
];
}
}
} }
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
@ -889,7 +920,8 @@ class user extends common
/** /**
* Liste les dossier contenus dans RFM * Liste les dossier contenus dans RFM
*/ */
function getSubdirectories($dir, $basePath = '') { function getSubdirectories($dir, $basePath = '')
{
$subdirs = array(); $subdirs = array();
// Ouvrez le répertoire spécifié // Ouvrez le répertoire spécifié
$dh = opendir($dir); $dh = opendir($dir);

View File

@ -7,4 +7,4 @@
]); ?> ]); ?>
</div> </div>
</div> </div>
<?php echo template::table([3, 7, 1, 1], $module::$userGroups, ['Nom', 'Commentaire', '', '']); ?> <?php echo template::table([1, 3, 7, 1, 1], $module::$userGroups, ['#', 'Nom', 'Commentaire', '', '']); ?>

View File

@ -15,7 +15,62 @@
<div class="col12"> <div class="col12">
<div class="block"> <div class="block">
<h4> <h4>
<?php echo helper::translate('Opérations sur les fichiers'); ?> <?php echo helper::translate('Gestionnaire de fichiers'); ?>
</h4>
<div class="row">
<div class="col3">
<?php echo template::checkbox('permissionEditShare', true, 'Activé', [
'checked' => $this->getData(['permission', $this->getUrl(2), 'folder', 'share'])
]); ?>
</div>
<div class="col6">
<?php echo template::select('permissionEditPath', $module::$sharePath, [
'label' => 'Racine du dossier',
'selected' => $this->getData(['permission', $this->getUrl(2), 'folder', 'path'])
]); ?>
</div>
</div>
<div class="row">
<div class="col12">
<div class="block">
<h4>
<?php echo helper::translate('Permissions sur les dossiers'); ?>
</h4>
<div class="row">
<div class="col2">
<?php echo template::checkbox('permissionEditFolderCreate', true, 'Création', [
'checked' => $this->getData(['permission', $this->getUrl(2), 'folder', 'create'])
]); ?>
</div>
<div class="col2">
<?php echo template::checkbox('permissionEditFolderDelete', true, 'Effacement', [
'checked' => $this->getData(['permission', $this->getUrl(2), 'folder', 'delete'])
]); ?>
</div>
<div class="col2">
<?php echo template::checkbox('permissionEditFolderRename', true, 'Nommage', [
'checked' => $this->getData(['permission', $this->getUrl(2), 'folder', 'rename'])
]); ?>
</div>
<div class="col2">
<?php echo template::checkbox('permissionEditFolderCopycut', true, 'Coupé collé', [
'checked' => $this->getData(['permission', $this->getUrl(2), 'folder', 'copycut'])
]); ?>
</div>
<div class="col2">
<?php echo template::checkbox('permissionEditFolderPermission', true, 'Permissions', [
'checked' => $this->getData(['permission', $this->getUrl(2), 'folder', 'permission'])
]); ?>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col12">
<div class="block">
<h4>
<?php echo helper::translate('Permissions sur les fichiers'); ?>
</h4> </h4>
<div class="row"> <div class="row">
<div class="col2"> <div class="col2">
@ -79,53 +134,8 @@
</div> </div>
</div> </div>
</div> </div>
<div class="row">
<div class="col12">
<div class="block">
<h4>
<?php echo helper::translate('Opérations sur les dossiers'); ?>
</h4>
<div class="row">
<div class="col2">
<?php echo template::checkbox('permissionEditFolderCreate', true, 'Création', [
'checked' => $this->getData(['permission', $this->getUrl(2), 'folder', 'create'])
]); ?>
</div>
<div class="col2">
<?php echo template::checkbox('permissionEditFolderDelete', true, 'Effacement', [
'checked' => $this->getData(['permission', $this->getUrl(2), 'folder', 'delete'])
]); ?>
</div>
<div class="col2">
<?php echo template::checkbox('permissionEditFolderRename', true, 'Nommage', [
'checked' => $this->getData(['permission', $this->getUrl(2), 'folder', 'rename'])
]); ?>
</div>
<div class="col2">
<?php echo template::checkbox('permissionEditFolderCopycut', true, 'Coupé collé', [
'checked' => $this->getData(['permission', $this->getUrl(2), 'folder', 'copycut'])
]); ?>
</div>
<div class="col2">
<?php echo template::checkbox('permissionEditFolderPermission', true, 'Permissions', [
'checked' => $this->getData(['permission', $this->getUrl(2), 'folder', 'permission'])
]); ?>
</div>
</div>
<div class="row">
<div class="col2">
<?php echo template::checkbox('permissionEditShare', true, 'Partage', [
'checked' => $this->getData(['permission', $this->getUrl(2), 'folder', 'share'])
]); ?>
</div>
<div class="col6">
<?php echo template::select('permissionEditPath', $module::$sharePath, [
'label' => 'Racine du partage',
'selected' => $this->getData(['permission', $this->getUrl(2), 'folder', 'path'])
]); ?>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
<?php echo template::formClose(); ?> <?php echo template::formClose(); ?>