Edit group WIP

This commit is contained in:
Fred Tempez 2023-03-10 15:02:49 +01:00
parent bb932110dc
commit ead284fff7
6 changed files with 83 additions and 18 deletions

View File

@ -969,9 +969,6 @@ if ($this->getData(['core', 'dataVersion']) < 12400) {
}
}
// Création des modèles de groupe
// Mise à jour
$this->setData(['core', 'dataVersion', 12400]);

View File

@ -335,27 +335,27 @@ class init extends common
'blacklist' => [],
'language'=> [],
'group' => [
-1 => [
"-1" => [
'name' => 'Banni',
'readonly' => true,
'comment' => 'Inscription désactivée'
'comment' => 'Accès désactivé'
],
0 => [
"0" => [
'name' => 'Visiteur',
'readonly' => true,
'comment' => 'Accès aux pages privées'
'comment' => 'Accède au site'
],
1 => [
"1" => [
'name' => 'Membre',
'readonly' => true,
'comment' => 'Accède aux pages réservées'
],
2 => [
"2" => [
'name' => 'Editeur',
'readonly' => false,
'comment' => 'Edition des pages'
],
99 => [
"99" => [
'name' => 'Administrateur',
'readonly' => true,
'comment' => 'Contrôle total'

View File

@ -28,6 +28,8 @@ class user extends common
'login' => self::GROUP_VISITOR,
'reset' => self::GROUP_VISITOR,
'group' => self::GROUP_ADMIN,
'groupAdd' => self::GROUP_ADMIN,
'groupEdit' => self::GROUP_ADMIN,
];
public static $users = [];
@ -42,6 +44,8 @@ class user extends common
public static $userId = '';
public static $userGroups = [];
public static $userLongtime = false;
public static $separators = [
@ -303,11 +307,15 @@ class user extends common
}
// Langues disponibles pour l'interface de l'utilisateur
self::$languagesInstalled = $this->getData(['language']);
foreach (self::$languagesInstalled as $lang => $datas) {
self::$languagesInstalled[$lang] = self::$languages[$lang];
if (self::$languagesInstalled) {
foreach (self::$languagesInstalled as $lang => $datas) {
self::$languagesInstalled[$lang] = self::$languages[$lang];
}
}
// Valeurs en sortie
$this->addOutput([
'title' => $this->getData(['user', $this->getUrl(2), 'firstname']) . ' ' . $this->getData(['user', $this->getUrl(2), 'lastname']),
@ -401,9 +409,27 @@ class user extends common
*/
public function group()
{
$groups = $this->getData(['group']);
foreach ($groups as $key => $value) {
$g = $this->getData(['group']);
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'],
'value' => template::ico('pencil'),
'help' => 'Éditer',
'disabled' => $groupData['readonly'],
]),
template::button('userDelete' . $groupId, [
'class' => 'userDelete buttonRed',
'href' => helper::baseUrl() . 'user/groupDelete/' . $groupId . '/' . $_SESSION['csrf'],
'value' => template::ico('trash'),
'help' => 'Supprimer',
'disabled' => $groupData['readonly'],
])
];
}
// Valeurs en sortie
$this->addOutput([
@ -412,6 +438,19 @@ class user extends common
]);
}
/**
* Edition d'un groupe
*/
public function groupEdit()
{
// Valeurs en sortie
$this->addOutput([
'title' => helper::translate('Editer groupe'),
'view' => 'groupEdit'
]);
}
/**
* Connexion

View File

@ -6,7 +6,5 @@
'value' => template::ico('left')
]); ?>
</div>
<div class="col2 offset9">
<?php echo template::submit('userGroupSubmit'); ?>
</div>
</div>
</div>
<?php echo template::table([1, 3, 6, 1, 1], $module::$userGroups, ['#', 'Nom', 'Commentaire', '', '']); ?>

View File

@ -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 <remi.jean@outlook.com>
* @copyright Copyright (C) 2008-2018, Rémi Jean
* @author Frédéric Tempez <frederic.tempez@outlook.com>
* @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
*/

View File

@ -0,0 +1,13 @@
<?php echo template::formOpen('groupEditForm'); ?>
<div class="row">
<div class="col1">
<?php echo template::button('userEditBack', [
'class' => 'buttonGrey',
'href' => helper::baseUrl() . 'user',
'value' => template::ico('left')
]); ?>
</div>
<div class="col2 offset9">
<?php echo template::submit('groupEditSubmit'); ?>
</div>
</div>