diff --git a/core/core.php b/core/core.php index eb2f3ac6..94a7a14b 100644 --- a/core/core.php +++ b/core/core.php @@ -32,7 +32,7 @@ class common const GROUP_VISITOR = 0; const GROUP_MEMBER = 1; const GROUP_MODERATOR = 2; - const GROUP_ADMIN = 3; + const GROUP_ADMIN = 99; const SIGNATURE_ID = 1; const SIGNATURE_PSEUDO = 2; const SIGNATURE_FIRSTLASTNAME = 3; @@ -55,7 +55,7 @@ class common // Numéro de version et branche pour l'auto-update const ZWII_VERSION = '12.4.00'; - const ZWII_DATAVERSION = 12300; + const ZWII_DATAVERSION = 12400; // URL autoupdate const ZWII_UPDATE_URL = 'https://forge.chapril.org/ZwiiCMS-Team/update/raw/branch/master/'; diff --git a/core/include/update.inc.php b/core/include/update.inc.php index 4e794cc0..118f36c5 100644 --- a/core/include/update.inc.php +++ b/core/include/update.inc.php @@ -956,4 +956,23 @@ if ($this->getData(['core', 'dataVersion']) < 12300) { // Mise à jour $this->setData(['core', 'dataVersion', 12300]); +} + +// Version 12.4.00 +if ($this->getData(['core', 'dataVersion']) < 12400) { + + // Affecter le groupe 99 aux admins + $users = $this->getData(['user']); + foreach ($users as $key => $value) { + if ($value['group'] === 3) { + $this->setData(['user', $key, 'group', 99]); + } + } + + // Création des modèles de groupe + + + // Mise à jour + $this->setData(['core', 'dataVersion', 12400]); + } \ No newline at end of file diff --git a/core/module/install/ressource/defaultdata.php b/core/module/install/ressource/defaultdata.php index 0d446969..6c4f5e17 100644 --- a/core/module/install/ressource/defaultdata.php +++ b/core/module/install/ressource/defaultdata.php @@ -334,7 +334,33 @@ class init extends common ], 'blacklist' => [], 'language'=> [], - 'group' => [], + 'group' => [ + -1 => [ + 'name' => 'Banni', + 'readonly' => true, + 'comment' => 'Inscription désactivée' + ], + 0 => [ + 'name' => 'Visiteur', + 'readonly' => true, + 'comment' => 'Accès aux pages privées' + ], + 1 => [ + 'name' => 'Membre', + 'readonly' => true, + 'comment' => 'Accède aux pages réservées' + ], + 2 => [ + 'name' => 'Editeur', + 'readonly' => false, + 'comment' => 'Edition des pages' + ], + 99 => [ + 'name' => 'Administrateur', + 'readonly' => true, + 'comment' => 'Contrôle total' + ] + ], ]; public static $defaultDataI18n = [ 'en_EN' => [ diff --git a/core/module/user/user.php b/core/module/user/user.php index 6e50c3a9..bf714d8c 100644 --- a/core/module/user/user.php +++ b/core/module/user/user.php @@ -106,9 +106,9 @@ class user extends common $userMail, 'Compte créé sur ' . $this->getData(['locale', 'title']), 'Bonjour ' . $userFirstname . ' ' . $userLastname . ',

' . - 'Un administrateur vous a créé un compte sur le site ' . $this->getData(['locale', 'title']) . '. Vous trouverez ci-dessous les détails de votre compte.

' . - 'Identifiant du compte : ' . $this->getInput('userAddId') . '
' . - 'Nous ne conservons pas les mots de passe, en conséquence nous vous conseillons de conserver ce message tant que vous ne vous êtes pas connecté. Vous pourrez modifier votre mot de passe après votre première connexion.', + 'Un administrateur vous a créé un compte sur le site ' . $this->getData(['locale', 'title']) . '. Vous trouverez ci-dessous les détails de votre compte.

' . + 'Identifiant du compte : ' . $this->getInput('userAddId') . '
' . + 'Nous ne conservons pas les mots de passe, en conséquence nous vous conseillons de conserver ce message tant que vous ne vous êtes pas connecté. Vous pourrez modifier votre mot de passe après votre première connexion.', null, $this->getData(['config', 'smtp', 'from']), ); @@ -206,7 +206,7 @@ class user extends common $this->getData(['user', $this->getUrl(2)]) === null // Droit d'édition and ( - // Impossible de s'auto-éditer + // Impossible de s'auto-éditer ($this->getUser('id') === $this->getUrl(2) and $this->getUrl('group') <= self::GROUP_VISITOR ) @@ -307,7 +307,7 @@ class user extends common 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']), @@ -334,9 +334,9 @@ class user extends common $this->getData(['user', $userId, 'mail']), 'Réinitialisation de votre mot de passe', 'Bonjour ' . $this->getData(['user', $userId, 'firstname']) . ' ' . $this->getData(['user', $userId, 'lastname']) . ',

' . - 'Vous avez demandé à changer le mot de passe lié à votre compte. Vous trouverez ci-dessous un lien vous permettant de modifier celui-ci.

' . - '' . helper::baseUrl() . 'user/reset/' . $userId . '/' . $uniqId . '

' . - 'Si nous n\'avez pas demandé à réinitialiser votre mot de passe, veuillez ignorer ce mail.', + 'Vous avez demandé à changer le mot de passe lié à votre compte. Vous trouverez ci-dessous un lien vous permettant de modifier celui-ci.

' . + '' . helper::baseUrl() . 'user/reset/' . $userId . '/' . $uniqId . '

' . + 'Si nous n\'avez pas demandé à réinitialiser votre mot de passe, veuillez ignorer ce mail.', null, $this->getData(['config', 'smtp', 'from']), ); @@ -350,7 +350,7 @@ class user extends common else { // Valeurs en sortie $this->addOutput([ - 'notification' => helper::translate('Utilisateur inexistant') + 'notification' => helper::translate('Utilisateur inexistant') ]); } } @@ -396,6 +396,23 @@ class user extends common ]); } + /** + * Table des groupes + */ + public function group() + { + $groups = $this->getData(['group']); + foreach ($groups as $key => $value) { + + } + // Valeurs en sortie + $this->addOutput([ + 'title' => helper::translate('Groupes'), + 'view' => 'group' + ]); + } + + /** * Connexion */ @@ -455,7 +472,7 @@ class user extends common } else { // Cas 4 : le délai de blocage est dépassé et le compte est au max - Réinitialiser if ( - $this->getData(['user', $userId, 'connectTimeout']) + $this->getData(['config', 'connect', 'timeout']) < time() + $this->getData(['user', $userId, 'connectTimeout']) + $this->getData(['config', 'connect', 'timeout']) < time() and $this->getData(['user', $userId, 'connectFail']) === $this->getData(['config', 'connect', 'attempt']) ) { $this->setData(['user', $userId, 'connectFail', 0]); @@ -511,8 +528,8 @@ class user extends common $this->setData(['user', $userId, 'connectTimeout', time()]); } // Cas 3 le délai de bloquage court - if ($this->getData(['user', $userId, 'connectTimeout']) + $this->getData(['config', 'connect', 'timeout']) > time()) { - $notification = sprintf(helper::translate('Accès bloqué %d minutes', ($this->getData(['config', 'connect', 'timeout']) / 60))); + if ($this->getData(['user', $userId, 'connectTimeout']) + $this->getData(['config', 'connect', 'timeout']) > time()) { + $notification = sprintf(helper::translate('Accès bloqué %d minutes', ($this->getData(['config', 'connect', 'timeout']) / 60))); } // Valeurs en sortie @@ -525,7 +542,7 @@ class user extends common // Journalisation $dataLog = helper::dateUTF8('%Y %m %d', time()) . ' - ' . helper::dateUTF8('%H:%M', time()); $dataLog .= helper::getIp($this->getData(['config', 'connect', 'anonymousIp'])) . ';'; - $dataLog .= empty($this->getInput('userLoginId')) ? ';' : $this->getInput('userLoginId', helper::FILTER_ID) . ';'; + $dataLog .= empty($this->getInput('userLoginId')) ? ';' : $this->getInput('userLoginId', helper::FILTER_ID) . ';'; $dataLog .= $this->getUrl() . ';'; $dataLog .= $logStatus; $dataLog .= PHP_EOL; @@ -544,6 +561,7 @@ class user extends common ]); } + /** * Déconnexion */ @@ -613,7 +631,6 @@ class user extends common 'title' => helper::translate('Réinitialisation du mot de passe'), 'view' => 'reset', 'display' => self::DISPLAY_LAYOUT_LIGHT, - ]); } } @@ -632,11 +649,11 @@ class user extends common $filePath = self::FILE_DIR . 'source/' . $file; if ($file and file_exists($filePath)) { // Analyse et extraction du CSV - $rows = array_map(function ($row) { + $rows = array_map(function ($row) { return str_getcsv($row, $this->getInput('userImportSeparator')); }, file($filePath)); $header = array_shift($rows); - $csv = array(); + $csv = array(); foreach ($rows as $row) { $csv[] = array_combine($header, $row); } @@ -657,7 +674,7 @@ class user extends common ) { // Validation du groupe $item['groupe'] = (int) $item['groupe']; - $item['groupe'] = ($item['groupe'] >= self::GROUP_BANNED and $item['groupe'] <= self::GROUP_ADMIN) + $item['groupe'] = ($item['groupe'] >= self::GROUP_BANNED and $item['groupe'] <= self::GROUP_ADMIN) ? $item['groupe'] : 1; // L'utilisateur existe if ($this->getData(['user', helper::filter($item['id'], helper::FILTER_ID)])) { @@ -680,15 +697,18 @@ class user extends common // Enregistre le user $create = $this->setData([ 'user', - $userId, [ + $userId, + [ 'firstname' => $item['prenom'], 'forgot' => 0, 'group' => $item['groupe'], 'lastname' => $item['nom'], 'mail' => $item['email'], 'pseudo' => $item['prenom'], - 'signature' => 1, // Pseudo - 'password' => uniqid(), // A modifier à la première connexion + 'signature' => 1, + // Pseudo + 'password' => uniqid(), + // A modifier à la première connexion "connectFail" => null, "connectTimeout" => null, "accessUrl" => null, @@ -697,7 +717,7 @@ class user extends common ] ]); // Icône de notification - $item['notification'] = $create ? template::ico('check') : template::ico('cancel'); + $item['notification'] = $create ? template::ico('check') : template::ico('cancel'); // Envoi du mail if ( $create @@ -707,11 +727,11 @@ class user extends common $item['email'], 'Compte créé sur ' . $this->getData(['locale', 'title']), 'Bonjour ' . $item['prenom'] . ' ' . $item['nom'] . ',

' . - 'Un administrateur vous a créé un compte sur le site ' . $this->getData(['locale', 'title']) . '. Vous trouverez ci-dessous les détails de votre compte.

' . - 'Identifiant du compte : ' . $userId . '
' . - 'Un mot de passe provisoire vous été attribué, à la première connexion cliquez sur Mot de passe Oublié.', - null, - $this->getData(['config', 'smtp', 'from']), + 'Un administrateur vous a créé un compte sur le site ' . $this->getData(['locale', 'title']) . '. Vous trouverez ci-dessous les détails de votre compte.

' . + 'Identifiant du compte : ' . $userId . '
' . + 'Un mot de passe provisoire vous été attribué, à la première connexion cliquez sur Mot de passe Oublié.', + null, + $this->getData(['config', 'smtp', 'from']), ); if ($sent === true) { // Mail envoyé changement de l'icône @@ -732,10 +752,10 @@ class user extends common } } if (empty(self::$users)) { - $notification = helper::translate('Rien à importer, erreur de format ou fichier incorrect'); + $notification = helper::translate('Rien à importer, erreur de format ou fichier incorrect'); $success = false; } else { - $notification = helper::translate('Importation effectuée'); + $notification = helper::translate('Importation effectuée'); $success = true; } } else { @@ -754,8 +774,9 @@ class user extends common /** * Télécharge un modèle - */ - public function template() { + */ + public function template() + { $file = 'template.csv'; $path = 'core/module/user/ressource/'; // Téléchargement du CSV @@ -768,10 +789,4 @@ class user extends common exit(); } - /** - * Table des groupes - */ - public function group() { - - } -} +} \ No newline at end of file diff --git a/core/module/user/view/group/group.css b/core/module/user/view/group/group.css new file mode 100644 index 00000000..9e5c6da2 --- /dev/null +++ b/core/module/user/view/group/group.css @@ -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 + * @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/group/group.php b/core/module/user/view/group/group.php new file mode 100644 index 00000000..066e0e97 --- /dev/null +++ b/core/module/user/view/group/group.php @@ -0,0 +1,12 @@ +
+
+ 'buttonGrey', + 'href' => helper::baseUrl() . 'user', + 'value' => template::ico('left') + ]); ?> +
+
+ +
+
\ No newline at end of file