Edition d'un profil

This commit is contained in:
Fred Tempez 2023-03-31 14:36:19 +02:00
parent a87431fc9c
commit a5743ca323
4 changed files with 63 additions and 36 deletions

View File

@ -32,7 +32,7 @@ class common
const GROUP_VISITOR = 0; const GROUP_VISITOR = 0;
const GROUP_MEMBER = 1; const GROUP_MEMBER = 1;
const GROUP_MODERATOR = 2; const GROUP_MODERATOR = 2;
const GROUP_ADMIN = 99; const GROUP_ADMIN = 3;
const SIGNATURE_ID = 1; const SIGNATURE_ID = 1;
const SIGNATURE_PSEUDO = 2; const SIGNATURE_PSEUDO = 2;
const SIGNATURE_FIRSTLASTNAME = 3; const SIGNATURE_FIRSTLASTNAME = 3;

View File

@ -417,14 +417,14 @@ class user extends common
// Membres sans permissions spécifiques // Membres sans permissions spécifiques
if ( if (
$groupId == -1 || $groupId == self::GROUP_BANNED ||
$groupId == 0 || $groupId == self::GROUP_VISITOR ||
$groupId == 3 $groupId == self::GROUP_ADMIN
) { ) {
self::$userGroups[$groupId] = [ self::$userGroups[$groupId] = [
$groupId, $groupId,
$groupData['name'], $groupData['name'],
$groupData['comment'], nl2br($groupData['comment']),
template::button('permissionEdit' . $groupId, [ template::button('permissionEdit' . $groupId, [
'href' => helper::baseUrl() . 'user/permissionEdit/' . $groupId . '/' . $_SESSION['csrf'], 'href' => helper::baseUrl() . 'user/permissionEdit/' . $groupId . '/' . $_SESSION['csrf'],
'value' => template::ico('pencil'), 'value' => template::ico('pencil'),
@ -439,23 +439,25 @@ class user extends common
'disabled' => $groupData['readonly'], 'disabled' => $groupData['readonly'],
]) ])
]; ];
} else { } elseif (
$groupId == self::GROUP_MEMBER ||
$groupId == self::GROUP_MODERATOR
) {
// Enumérer les sous groupes MEMBER et MODERATOR // Enumérer les sous groupes MEMBER et MODERATOR
foreach ($groupData as $subGroupId => $subGroupData) { foreach ($groupData as $subGroupId => $subGroupData) {
echo $subGroupId;
self::$userGroups[$groupId.'.'.$subGroupId] = [ self::$userGroups[$groupId.'.'.$subGroupId] = [
$groupId . '-' . $subGroupId, $groupId . '-' . $subGroupId,
$subGroupData['name'], self::$groups[$groupId] .'<br />Profil : '. $subGroupData['name'],
$subGroupData['comment'], nl2br($subGroupData['comment']),
template::button('permissionEdit' . $groupId.$subGroupId, [ template::button('permissionEdit' . $groupId.$subGroupId, [
'href' => helper::baseUrl() . 'user/permissionEdit/' . $groupId . '-' . $subGroupId . '/' . $_SESSION['csrf'], 'href' => helper::baseUrl() . 'user/permissionEdit/' . $groupId . '/' . $subGroupId . '/' . $_SESSION['csrf'],
'value' => template::ico('pencil'), 'value' => template::ico('pencil'),
'help' => 'Éditer', 'help' => 'Éditer',
'disabled' => $subGroupData['readonly'], 'disabled' => $subGroupData['readonly'],
]), ]),
template::button('permissionDelete' . $groupId.$subGroupId, [ template::button('permissionDelete' . $groupId.$subGroupId, [
'class' => 'userDelete buttonRed', 'class' => 'userDelete buttonRed',
'href' => helper::baseUrl() . 'user/permissionDelete/' . $groupId . '-' . $subGroupId . '/' . $_SESSION['csrf'], 'href' => helper::baseUrl() . 'user/permissionDelete/' . $groupId . '/' . $subGroupId . '/' . $_SESSION['csrf'],
'value' => template::ico('trash'), 'value' => template::ico('trash'),
'help' => 'Supprimer', 'help' => 'Supprimer',
'disabled' => $subGroupData['readonly'], 'disabled' => $subGroupData['readonly'],
@ -477,7 +479,7 @@ class user extends common
public function permissionEdit() public function permissionEdit()
{ {
if ( if (
$this->getUrl(3) !== $_SESSION['csrf'] $this->getUrl(4) !== $_SESSION['csrf']
) { ) {
// Valeurs en sortie // Valeurs en sortie
@ -490,13 +492,15 @@ class user extends common
// Soumission du formulaire // Soumission du formulaire
if ($this->isPost()) { if ($this->isPost()) {
$group = $this->getUrl(2); $group = $this->getUrl(2);
$profil = $this->getUrl(3);
$this->setData([ $this->setData([
'permission', 'permission',
$group, $group,
$profil,
[ [
'name' => $this->getData(['permission', $group, 'name']), 'name' => $this->getInput('permissionEditName', null, true),
'readonly' => $this->getData(['permission', $group, 'readonly']), 'readonly' => false,
'comment' => $this->getData(['permission', $group, 'comment']), 'comment' => $this->getInput('permissionEditComment', helper::FILTER_STRING_SHORT, true),
'file' => [ 'file' => [
'download' => $this->getInput('permissionEditDownload', helper::FILTER_BOOLEAN), 'download' => $this->getInput('permissionEditDownload', helper::FILTER_BOOLEAN),
'edit' => $this->getInput('permissionEditEdit', helper::FILTER_BOOLEAN), 'edit' => $this->getInput('permissionEditEdit', helper::FILTER_BOOLEAN),
@ -535,7 +539,7 @@ class user extends common
// Valeurs en sortie; // Valeurs en sortie;
$this->addOutput([ $this->addOutput([
'title' => sprintf(helper::translate('Groupe %s'), $this->getData(['permission', $this->getUrl(2), 'name'])), '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' 'view' => 'permissionEdit'
]); ]);
} }

View File

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

View File

@ -11,6 +11,29 @@
<?php echo template::submit('permissionEditSubmit'); ?> <?php echo template::submit('permissionEditSubmit'); ?>
</div> </div>
</div> </div>
<div class="row">
<div class="col12">
<div class="block">
<h4>
<?php echo helper::translate('Identité'); ?>
</h4>
<div class="row">
<div class="col6">
<?php echo template::text('permissionEditName', [
'label' => 'Profil',
'value' => $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'name'])
]); ?>
</div>
<div class="col6">
<?php echo template::textarea('permissionEditComment', [
'label' => 'Commentaire',
'value' => $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'comment'])
]); ?>
</div>
</div>
</div>
</div>
</div>
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<div class="block"> <div class="block">
@ -20,13 +43,13 @@
<div class="row"> <div class="row">
<div class="col3"> <div class="col3">
<?php echo template::checkbox('permissionEditShare', true, 'Activé', [ <?php echo template::checkbox('permissionEditShare', true, 'Activé', [
'checked' => $this->getData(['permission', $this->getUrl(2), 'folder', 'share']) 'checked' => $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'folder', 'share'])
]); ?> ]); ?>
</div> </div>
<div class="col6"> <div class="col6">
<?php echo template::select('permissionEditPath', $module::$sharePath, [ <?php echo template::select('permissionEditPath', $module::$sharePath, [
'label' => 'Racine du dossier', 'label' => 'Racine du dossier',
'selected' => $this->getData(['permission', $this->getUrl(2), 'folder', 'path']) 'selected' => $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'folder', 'path'])
]); ?> ]); ?>
</div> </div>
</div> </div>
@ -39,27 +62,27 @@
<div class="row"> <div class="row">
<div class="col2"> <div class="col2">
<?php echo template::checkbox('permissionEditFolderCreate', true, 'Création', [ <?php echo template::checkbox('permissionEditFolderCreate', true, 'Création', [
'checked' => $this->getData(['permission', $this->getUrl(2), 'folder', 'create']) 'checked' => $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'folder', 'create'])
]); ?> ]); ?>
</div> </div>
<div class="col2"> <div class="col2">
<?php echo template::checkbox('permissionEditFolderDelete', true, 'Effacement', [ <?php echo template::checkbox('permissionEditFolderDelete', true, 'Effacement', [
'checked' => $this->getData(['permission', $this->getUrl(2), 'folder', 'delete']) 'checked' => $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'folder', 'delete'])
]); ?> ]); ?>
</div> </div>
<div class="col2"> <div class="col2">
<?php echo template::checkbox('permissionEditFolderRename', true, 'Nommage', [ <?php echo template::checkbox('permissionEditFolderRename', true, 'Nommage', [
'checked' => $this->getData(['permission', $this->getUrl(2), 'folder', 'rename']) 'checked' => $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'folder', 'rename'])
]); ?> ]); ?>
</div> </div>
<div class="col2"> <div class="col2">
<?php echo template::checkbox('permissionEditFolderCopycut', true, 'Coupé collé', [ <?php echo template::checkbox('permissionEditFolderCopycut', true, 'Coupé collé', [
'checked' => $this->getData(['permission', $this->getUrl(2), 'folder', 'copycut']) 'checked' => $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'folder', 'copycut'])
]); ?> ]); ?>
</div> </div>
<div class="col2"> <div class="col2">
<?php echo template::checkbox('permissionEditFolderPermission', true, 'Permissions', [ <?php echo template::checkbox('permissionEditFolderPermission', true, 'Permissions', [
'checked' => $this->getData(['permission', $this->getUrl(2), 'folder', 'permission']) 'checked' => $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'folder', 'permission'])
]); ?> ]); ?>
</div> </div>
</div> </div>
@ -75,59 +98,59 @@
<div class="row"> <div class="row">
<div class="col2"> <div class="col2">
<?php echo template::checkbox('permissionEditDownload', true, 'Téléchargement', [ <?php echo template::checkbox('permissionEditDownload', true, 'Téléchargement', [
'checked' => $this->getData(['permission', $this->getUrl(2), 'file', 'download']) 'checked' => $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'file', 'download'])
]); ?> ]); ?>
</div> </div>
<div class="col2"> <div class="col2">
<?php echo template::checkbox('permissionEditEdit', true, 'Edition', [ <?php echo template::checkbox('permissionEditEdit', true, 'Edition', [
'checked' => $this->getData(['permission', $this->getUrl(2), 'file', 'edit']) 'checked' => $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'file', 'edit'])
]); ?> ]); ?>
</div> </div>
<div class="col2"> <div class="col2">
<?php echo template::checkbox('permissionEditCreate', true, 'Création', [ <?php echo template::checkbox('permissionEditCreate', true, 'Création', [
'checked' => $this->getData(['permission', $this->getUrl(2), 'file', 'create']) 'checked' => $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'file', 'create'])
]); ?> ]); ?>
</div> </div>
<div class="col2"> <div class="col2">
<?php echo template::checkbox('permissionEditRename', true, 'Nommage', [ <?php echo template::checkbox('permissionEditRename', true, 'Nommage', [
'checked' => $this->getData(['permission', $this->getUrl(2), 'file', 'rename']) 'checked' => $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'file', 'rename'])
]); ?> ]); ?>
</div> </div>
<div class="col2"> <div class="col2">
<?php echo template::checkbox('permissionEditUpload', true, 'Téléversement', [ <?php echo template::checkbox('permissionEditUpload', true, 'Téléversement', [
'checked' => $this->getData(['permission', $this->getUrl(2), 'file', 'upload']) 'checked' => $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'file', 'upload'])
]); ?> ]); ?>
</div> </div>
<div class="col2"> <div class="col2">
<?php echo template::checkbox('permissionEditDelete', true, 'Effacement', [ <?php echo template::checkbox('permissionEditDelete', true, 'Effacement', [
'checked' => $this->getData(['permission', $this->getUrl(2), 'file', 'delete']) 'checked' => $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'file', 'delete'])
]); ?> ]); ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col2"> <div class="col2">
<?php echo template::checkbox('permissionEditPreview', true, 'Prévisualisation', [ <?php echo template::checkbox('permissionEditPreview', true, 'Prévisualisation', [
'checked' => $this->getData(['permission', $this->getUrl(2), 'file', 'preview']) 'checked' => $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'file', 'preview'])
]); ?> ]); ?>
</div> </div>
<div class="col2"> <div class="col2">
<?php echo template::checkbox('permissionEditDuplicate', true, 'Duplication', [ <?php echo template::checkbox('permissionEditDuplicate', true, 'Duplication', [
'checked' => $this->getData(['permission', $this->getUrl(2), 'file', 'duplicate']) 'checked' => $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'file', 'duplicate'])
]); ?> ]); ?>
</div> </div>
<div class="col2"> <div class="col2">
<?php echo template::checkbox('permissionEditExtract', true, 'Extraction', [ <?php echo template::checkbox('permissionEditExtract', true, 'Extraction', [
'checked' => $this->getData(['permission', $this->getUrl(2), 'file', 'extract']) 'checked' => $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'file', 'extract'])
]); ?> ]); ?>
</div> </div>
<div class="col2"> <div class="col2">
<?php echo template::checkbox('permissionEditCopycut', true, 'Coupé collé', [ <?php echo template::checkbox('permissionEditCopycut', true, 'Coupé collé', [
'checked' => $this->getData(['permission', $this->getUrl(2), 'file', 'copycut']) 'checked' => $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'file', 'copycut'])
]); ?> ]); ?>
</div> </div>
<div class="col2"> <div class="col2">
<?php echo template::checkbox('permissionEditPermission', true, 'Permissions', [ <?php echo template::checkbox('permissionEditPermission', true, 'Permissions', [
'checked' => $this->getData(['permission', $this->getUrl(2), 'file', 'permission']) 'checked' => $this->getData(['permission', $this->getUrl(2), $this->getUrl(3), 'file', 'permission'])
]); ?> ]); ?>
</div> </div>
</div> </div>