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_MEMBER = 1;
const GROUP_MODERATOR = 2;
const GROUP_ADMIN = 99;
const GROUP_ADMIN = 3;
const SIGNATURE_ID = 1;
const SIGNATURE_PSEUDO = 2;
const SIGNATURE_FIRSTLASTNAME = 3;

View File

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

@ -7,4 +7,4 @@
]); ?>
</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'); ?>
</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="col12">
<div class="block">
@ -20,13 +43,13 @@
<div class="row">
<div class="col3">
<?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 class="col6">
<?php echo template::select('permissionEditPath', $module::$sharePath, [
'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>
@ -39,27 +62,27 @@
<div class="row">
<div class="col2">
<?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 class="col2">
<?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 class="col2">
<?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 class="col2">
<?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 class="col2">
<?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>
@ -75,59 +98,59 @@
<div class="row">
<div class="col2">
<?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 class="col2">
<?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 class="col2">
<?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 class="col2">
<?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 class="col2">
<?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 class="col2">
<?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 class="row">
<div class="col2">
<?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 class="col2">
<?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 class="col2">
<?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 class="col2">
<?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 class="col2">
<?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>