diff --git a/module/suscribe/changes.md b/module/suscribe/changes.md index e69de29..c947222 100644 --- a/module/suscribe/changes.md +++ b/module/suscribe/changes.md @@ -0,0 +1,7 @@ +# Version 2.2 +- Ajoute la gestion des profils +# Version 2.1 +- N'envoie pas d'email lorsque le domaine est invalide. +- Corrige la validation de domaines multiples séparés par des points virgules. +# Version 2.0 +- trop de corrections. \ No newline at end of file diff --git a/module/suscribe/enum.json b/module/suscribe/enum.json index 16d5527..4499848 100644 --- a/module/suscribe/enum.json +++ b/module/suscribe/enum.json @@ -1 +1 @@ -{"name":"suscribe","realName":"Auto inscription","version":"2.00","update":"0.0","delete":true,"dataDirectory":""} \ No newline at end of file +{"name":"suscribe","realName":"Auto Inscription","version":"2.1","update":"0.0","delete":true,"dataDirectory":""} \ No newline at end of file diff --git a/module/suscribe/profil/main/add.inc.php b/module/suscribe/profil/main/add.inc.php index 0b11c96..5cb3714 100644 --- a/module/suscribe/profil/main/add.inc.php +++ b/module/suscribe/profil/main/add.inc.php @@ -1,9 +1,9 @@ - $this->getInput('profilAddSuscribeEdit', helper::FILTER_BOOLEAN), - 'delete' => $this->getInput('profilAddSuscribeDelete', helper::FILTER_BOOLEAN), - 'user' => $this->getInput('profilAddSuscribeUser', helper::FILTER_BOOLEAN), - 'config' => $this->getInput('profilAddSuscribeAdd', helper::FILTER_BOOLEAN) || - $this->getInput('profilAddSuscribeEdit', helper::FILTER_BOOLEAN) || - $this->getInput('profilAddSuscribeDelete', helper::FILTER_BOOLEAN) || - $this->getInput('profilAddSuscribeUser', helper::FILTER_BOOLEAN) + $this->getInput('profilAddSuscribeEdit', helper::FILTER_BOOLEAN), + 'delete' => $this->getInput('profilAddSuscribeDelete', helper::FILTER_BOOLEAN), + 'user' => $this->getInput('profilAddSuscribeUser', helper::FILTER_BOOLEAN), + 'config' => $this->getInput('profilAddSuscribeAdd', helper::FILTER_BOOLEAN) || + $this->getInput('profilAddSuscribeEdit', helper::FILTER_BOOLEAN) || + $this->getInput('profilAddSuscribeDelete', helper::FILTER_BOOLEAN) || + $this->getInput('profilAddSuscribeUser', helper::FILTER_BOOLEAN) ]; \ No newline at end of file diff --git a/module/suscribe/profil/main/edit.inc.php b/module/suscribe/profil/main/edit.inc.php index f2d138c..2cf314a 100644 --- a/module/suscribe/profil/main/edit.inc.php +++ b/module/suscribe/profil/main/edit.inc.php @@ -1,9 +1,9 @@ - $this->getInput('profilEditSuscribeEdit', helper::FILTER_BOOLEAN), - 'delete' => $this->getInput('profilEditSuscribeDelete', helper::FILTER_BOOLEAN), - 'user' => $this->getInput('profilEditSuscribeUser', helper::FILTER_BOOLEAN), - 'config' => $this->getInput('profilEditSuscribeAdd', helper::FILTER_BOOLEAN) || - $this->getInput('profilEditSuscribeEdit', helper::FILTER_BOOLEAN) || - $this->getInput('profilEditSuscribeDelete', helper::FILTER_BOOLEAN) || - $this->getInput('profilEditSuscribeUser', helper::FILTER_BOOLEAN) + $this->getInput('profilEditSuscribeEdit', helper::FILTER_BOOLEAN), + 'delete' => $this->getInput('profilEditSuscribeDelete', helper::FILTER_BOOLEAN), + 'user' => $this->getInput('profilEditSuscribeUser', helper::FILTER_BOOLEAN), + 'config' => $this->getInput('profilEditSuscribeAdd', helper::FILTER_BOOLEAN) || + $this->getInput('profilEditSuscribeEdit', helper::FILTER_BOOLEAN) || + $this->getInput('profilEditSuscribeDelete', helper::FILTER_BOOLEAN) || + $this->getInput('profilEditSuscribeUser', helper::FILTER_BOOLEAN) ]; \ No newline at end of file diff --git a/module/suscribe/profil/view/add.inc.php b/module/suscribe/profil/view/add.inc.php index 38f39ed..c8d40b5 100644 --- a/module/suscribe/profil/view/add.inc.php +++ b/module/suscribe/profil/view/add.inc.php @@ -1,20 +1,20 @@ -
-
-
-

- -

-
-
- -
-
- -
-
- -
-
-
-
+
+
+
+

+ +

+
+
+ +
+
+ +
+
+ +
+
+
+
\ No newline at end of file diff --git a/module/suscribe/profil/view/edit.inc.php b/module/suscribe/profil/view/edit.inc.php index db36b39..68415aa 100644 --- a/module/suscribe/profil/view/edit.inc.php +++ b/module/suscribe/profil/view/edit.inc.php @@ -1,26 +1,26 @@ -
-
-
-

- · -

-
-
- $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'suscribe', 'edit']) - ]); ?> -
-
- $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'suscribe', 'delete']) - ]); ?> -
-
- $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'suscribe', 'user']) - ]); ?> -
-
-
-
+
+
+
+

+ · +

+
+
+ $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'suscribe', 'edit']) + ]); ?> +
+
+ $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'suscribe', 'delete']) + ]); ?> +
+
+ $this->getData(['profil', $this->getUrl(2), $this->getUrl(3), 'suscribe', 'user']) + ]); ?> +
+
+
+
\ No newline at end of file diff --git a/module/suscribe/suscribe.php b/module/suscribe/suscribe.php index eba5348..97c23ba 100755 --- a/module/suscribe/suscribe.php +++ b/module/suscribe/suscribe.php @@ -1,487 +1,501 @@ - - * @copyright Copyright (C) 2018-2020, Frédéric Tempez - * @license CC Attribution-NonCommercial-NoDerivatives 4.0 International - * @link http://zwiicms.com/ - */ - -class suscribe extends common -{ - - const VERSION = '2.0'; - const REALNAME = 'Auto Inscription'; - const DELETE = true; - const UPDATE = '0.0'; - const DATADIRECTORY = ''; // Contenu localisé inclus par défaut (page.json et module.json) - - const STATUS_EMAIL_AWAITING = 0; - const STATUS_EMAIL_VALID = 1; - const STATUS_ACCOUNT_AWAITING = 2; - const STATUS_ACCOUNT_VALID = 3; - public static $statusGroups = [ - self::STATUS_EMAIL_AWAITING => 'Email non confirmé', - self::STATUS_EMAIL_VALID => 'Email valide', - self::STATUS_ACCOUNT_AWAITING => 'Email valide, en attente de confirmation', - self::STATUS_ACCOUNT_VALID => 'Email valide, compte activé', - ]; - - public static $actions = [ - 'index' => self::GROUP_VISITOR, - 'validate' => self::GROUP_VISITOR, - 'config' => self::GROUP_EDITOR, - 'users' => self::GROUP_EDITOR, - 'delete' => self::GROUP_EDITOR, - 'edit' => self::GROUP_EDITOR - ]; - - public static $layout = [ - 'inputRowContainer1' => 'Un élément par ligne', - 'inputRowContainer2' => 'Deux éléments par ligne', - 'inputRowContainer4' => 'Quatre éléments par ligne', - ]; - - public static $timeLimit = [ - 2 => '2 minutes', - 5 => '5 minutes', - 10 => '10 minutes' - ]; - - public static $users = []; - - public static $groups = []; - public static $userProfils = []; - public static $userProfilsComments = []; - - /** - * Liste des utilisateurs en attente - */ - public function users() - { - $userIdsFirstnames = helper::arraycollumn($this->getData(['module', $this->getUrl(0), 'users']), 'firstname'); - ksort($userIdsFirstnames); - foreach ($userIdsFirstnames as $userId => $userFirstname) { - self::$users[] = [ - $userId, - $userFirstname . ' ' . $this->getData(['module', $this->getUrl(0), 'users', $userId, 'lastname']), - self::$statusGroups[$this->getData(['module', $this->getUrl(0), 'users', $userId, 'status'])], - helper::dateUTF8(date('Y-m-d G:i'), $this->getData(['module', $this->getUrl(0), 'users', $userId, 'timer'])), - template::button('registrationUserEdit' . $userId, [ - 'href' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $userId, - 'value' => template::ico('pencil') - ]), - template::button('registrationUserDelete' . $userId, [ - 'class' => 'userDelete red', - 'href' => helper::baseUrl() . $this->getUrl(0) . '/delete/' . $userId, - 'value' => template::ico('cancel') - ]) - ]; - } - // Valeurs en sortie - $this->addOutput([ - 'title' => 'Inscription en attente', - 'view' => 'users' - ]); - } - - - /** - * Édition - */ - public function edit() - { - if ( - $this->getUser('permission', __CLASS__, __FUNCTION__) !== true - ) { - // Valeurs en sortie - $this->addOutput([ - 'access' => false - ]); - } - // Accès refusé - if ( - // L'utilisateur n'existe pas - $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2)]) === null - // Droit d'édition - and ( - // Impossible de s'auto-éditer - ( - $this->getUser('id') === 'user' - and $this->getUrl('group') <= self::GROUP_VISITOR - ) - // Impossible d'éditer un autre utilisateur - or ($this->getUrl('group') < self::GROUP_EDITOR) - ) - ) { - // Valeurs en sortie - $this->addOutput([ - 'access' => false - ]); - } - // Accès autorisé - else { - // Soumission du formulaire - if ( - $this->getUser('permission', __CLASS__, __FUNCTION__) === true - && $this->isPost() - ) { - // Créer le user dans la base - $this->setData([ - 'user', - $this->getUrl(2), - [ - 'firstname' => $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'firstname']), - 'forgot' => 0, - 'group' => $this->getInput('registrationUserEditGroup', helper::FILTER_INT), - // Le profil vaut 0 pour les amdins et 1 pour les autres membres, profil par défaut. - 'profil' => $this->getInput('registrationUserEditGroup', helper::FILTER_INT) === self::GROUP_ADMIN - ? 0 : 1, - 'lastname' => $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'lastname']), - 'mail' => $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'mail']), - 'password' => $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'password']), - 'tags' => $this->getInput('registrationUserLabel', helper::FILTER_STRING_SHORT), - 'connectFail' => $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'connectFail']), - 'connectTimeout' => $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'connectTimeout']), - 'accessUrl' => $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'accessUrl']), - 'accessTimer' => $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'accessTimer']), - 'accessCsrf' => $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'accessCsrf']) - ] - ]); - // Notifier le user uniquement si le groupe est membre au moins membre - if ($this->getInput('registrationUserEditGroup') >= 1) { - $this->sendMail( - $this->getData(['module', $this->getUrl(0), 'users', 'mail']), - 'Approbation de l\'inscription', - '

' . $this->getdata(['module', $this->getUrl(0), 'config', 'mailValidateContent']) . '

', - null, - $this->getData(['config', 'smtp', 'from']) - ); - } - // Supprimer le user de la base temporaire, - $this->deleteData(['module', $this->getUrl(0), 'users', $this->getUrl(2)]); - // Valeurs en sortie - $this->addOutput([ - 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/users', - 'notification' => 'Modifications enregistrées', - 'state' => true - ]); - } - // Changement temporaire de libellé du groupe 0 - self::$groups = self::$groupEdits; - self::$groups[self::GROUP_BANNED] = 'En attente d\'approbation'; - - // Profils disponibles - foreach ($this->getData(['profil']) as $profilId => $profilData) { - if ($profilId < self::GROUP_MEMBER) { - continue; - } - if ($profilId === self::GROUP_ADMIN) { - self::$userProfils[$profilId][self::GROUP_ADMIN] = $profilData['name']; - self::$userProfilsComments[$profilId][self::GROUP_ADMIN] = $profilData['comment']; - continue; - } - foreach ($profilData as $key => $value) { - self::$userProfils[$profilId][$key] = $profilData[$key]['name']; - self::$userProfilsComments[$profilId][$key] = $profilData[$key]['name'] . ' : ' . $profilData[$key]['comment']; - } - } - - // Valeurs en sortie - $this->addOutput([ - 'title' => $this->getData(['module', $this->getUrl(0), 'users', 'firstname']) . ' ' . $this->getData(['user', $this->getUrl(0), 'lastname']), - 'view' => 'edit' - ]); - } - } - - - /** - * Suppression - */ - public function delete() - { - // Accès refusé - if ( - // L'utilisateur n'existe pas - $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2)]) === null - // Groupe insuffisant - && $this->getUser('permission', __CLASS__, __FUNCTION__) !== true - ) { - // Valeurs en sortie - $this->addOutput([ - 'access' => false - ]); - } - // Suppression - else { - $this->deleteData(['module', $this->getUrl(0), 'users', $this->getUrl(2)]); - // Valeurs en sortie - $this->addOutput([ - 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/users', - 'notification' => 'Utilisateur supprimé', - 'state' => true - ]); - } - } - - - /** - * Ajout - */ - public function index() - { - /** - * Traitement du formulaire - * Stocke les données du formulaire dans le module - * Envoie le mail de vérification de l'email - */ - // Soumission du formulaire - if ($this->isPost()) { - // Le domaine saisi est invalide si un filtre existe - if ( - !empty($this->getData(['module', $this->getUrl(0), 'config', 'filter'])) - ) { - // Contrôler la validité du domaine saisi parmi les domaines valides - $email_to_check = $this->getInput('registrationAddMail', helper::FILTER_MAIL, true); - $valid_domains[] = strpos($this->getData(['module', $this->getUrl(0), 'config', 'filter']), ';') === false - ? $this->getData(['module', $this->getUrl(0), 'config', 'filter']) - : explode(';', $this->getData(['module', $this->getUrl(0), 'config', 'filter'])); - if (in_array(explode('@', $email_to_check)[1], $valid_domains) === false) { - self::$inputNotices['registrationAddMail'] = 'Ce domaine n\'est pas autorisé'; - } - } - // Drapeau de contrôle des données saisies. - $check = true; - $sentMailtoUser = false; - // L'identifiant d'utilisateur est indisponible - $userId = $this->getInput('registrationAddId', helper::FILTER_ID, true); - if (is_array($this->getData(['user', $userId]))) { - self::$inputNotices['registrationAddId'] = 'Identifiant invalide'; - $check = false; - } - // Le compte existe déjà - foreach ($this->getData(['user']) as $usersId => $user) { - if ($user['mail'] === $this->getInput('registrationAddMail', helper::FILTER_MAIL, true)) { - self::$inputNotices['registrationAddMail'] = 'Vous ne pouvez pas utilisez cette boite mail'; - $check = false; - break; - } - } - // Données de l'utilisateur - $userFirstname = $this->getInput('registrationAddFirstname', helper::FILTER_STRING_SHORT, true); - $userLastname = $this->getInput('registrationAddLastname', helper::FILTER_STRING_SHORT, true); - $userMail = $this->getInput('registrationAddMail', helper::FILTER_MAIL, true); - // Pas de nom saisi - if ( - empty($userFirstname) || - empty($userLastname) - ) { - $check = false; - } - // Si tout est ok - if ($check === true) { - // Enregistrement du compte dans les données du module - $auth = uniqid('', true); - $this->setData([ - 'module', - $this->getUrl(0), - 'users', - $userId, - [ - 'firstname' => $userFirstname, - 'lastname' => $userLastname, - 'mail' => $userMail, - 'password' => '', - // pas de groupe afin de le différencier dans la liste des users - 'timer' => time(), - 'auth' => $auth, - 'status' => self::STATUS_EMAIL_AWAITING - ] - ]); - // Mail d'avertissement aux administrateurs - // Utilisateurs dans le groupe admin - $to = []; - foreach ($this->getData(['user']) as $key => $user) { - if ($user['group'] == self::GROUP_ADMIN) { - $to[] = $user['mail']; - } - } - // Envoi du mail à l'administrateur - if ($check && is_array($to)) { - $this->sendMail( - $to, - 'Auto-inscription sur le site ' . $this->getData(['config', 'title']), - '

Un nouveau membre s\'est inscrit, son email est en attente de validation

' . - '

Identifiant du compte : ' . $userId . ' (' . $userFirstname . ' ' . $userLastname . ')
' . - 'Email : ' . $userMail . '

' . - 'Validation de l\'inscription', - null, - $this->getData(['config', 'smtp', 'from']) - ); - } - - // Mail de confirmation à l'utilisateur - // forger le lien de vérification - $validateLink = helper::baseUrl(true) . $this->getUrl() . '/validate/' . $userId . '/' . $auth; - // Envoi - if ($check) { - $sentMailtoUser = $this->sendMail( - $userMail, - 'Confirmation de votre inscription', - '

' . $this->getdata(['module', $this->getUrl(0), 'config', 'mailRegisterContent']) . '

' . - '

Activer votre compte' . '

' . - '

ou copiez collez le lien suivant dans un navigateur : ' . $validateLink . '

' - , - null, - $this->getData(['config', 'smtp', 'from']) - ); - } - } - // Valeurs en sortie - $this->addOutput([ - 'redirect' => helper::baseUrl(), - //'redirect' => $validateLink, - 'notification' => $sentMailtoUser ? "Un mail vous a été envoyé." : 'Quelque chose n\'a pas fonctionné !', - 'state' => $sentMailtoUser ? true : false - ]); - } - // Valeurs en sortie - $this->addOutput([ - 'title' => 'Inscription', - 'view' => 'index', - 'showBarEditButton' => true, - 'showPageContent' => true - ]); - } - - /** - * Vérification de l'email - */ - public function validate() - { - // Soumission du formulaire - if ($this->isPost()) { - // Vérifie la session + l'id + le timer - $check = true; - $notification = 'Bienvenue sur le site ' . $this->getData(['config', 'title']); - $userId = $this->getUrl(2); - $auth = $this->getUrl(3); - // la validité du lien est dépassé - if ( - (time() - $this->getData(['module', $this->getUrl(0), 'users', $userId, 'timer'])) - >= $this->getdata(['module', $this->getUrl(0), 'config', 'timeOut']) - ) { - $check = false; - $notification = 'La validité du lien est dépassée'; - } - // La clé est incorrecte ou le compte n'est pas en attente de validation - if ( - $check - && $auth !== $this->getData(['module', $this->getUrl(0), 'users', $userId, 'auth']) - && $this->getData(['module', $this->getUrl(0), 'users', $userId, 'status']) !== self::STATUS_EMAIL_AWAITING - ) { - $check = false; - $notification = 'Données incorrectes !'; - } - // Double vérification pour le mot de passe - if ( - $check - && $this->getInput('registrationValidPassword', helper::FILTER_STRING_SHORT, true) !== $this->getInput('registrationValidConfirmPassword', helper::FILTER_STRING_SHORT, true) - ) { - self::$inputNotices['registrationAddConfirmPassword'] = 'Les mots de passe ne sont pas identiques'; - $check = false; - } - - if ($check) { - if ( - // Pas d'approbation par un administrateur - $this->getData(['module', $this->getUrl(0), 'config', 'approval']) === false - ) { - // Créer le compte - $this->setData([ - 'user', - $userId, - [ - 'firstname' => $this->getData(['module', $this->getUrl(0), 'users', $userId, 'firstname']), - 'lastname' => $this->getData(['module', $this->getUrl(0), 'users', $userId, 'lastname']), - 'mail' => $this->getData(['module', $this->getUrl(0), 'users', $userId, 'mail']), - 'password' => $this->getInput('registrationValidPassword', helper::FILTER_PASSWORD, true), - 'group' => self::GROUP_MEMBER, - 'profil' => 1, - 'forgot' => 0, - 'pseudo' => $userId, - 'signature' => 1, - 'language' => self::$siteContent, - ] - ]); - // Modifier le statut dans le module - $this->deleteData(['module', $this->getUrl(0), 'users', $userId]); - $notification = 'Votre inscription est confirmée'; - } else { - // Approbation nécessaire - $this->setData(['module', $this->getUrl(0), 'users', $userId, 'status', self::STATUS_ACCOUNT_AWAITING]); - $notification = 'L\'inscription doit être approuvée par un administrateur'; - } - } - // Valeurs en sortie - $this->addOutput([ - 'redirect' => $check ? helper::baseUrl() . $this->getdata(['module', $this->getUrl(0), 'config', 'pageSuccess']) : helper::baseUrl() . $this->getdata(['module', $this->getUrl(0), 'config', 'pageError']), - 'notification' => $notification, - 'state' => $check - ]); - } - // Valeurs en sortie - $this->addOutput([ - 'title' => 'Saisie du mot de passe', - 'view' => 'validate' - ]); - } - - /** - * Module de configuration - */ - public function config() - { - // Soumission du formulaire - if ( - $this->getUser('permission', __CLASS__, __FUNCTION__) === true - && $this->isPost() - ) { - - // Lire les options et les enregistrer - $this->setData([ - 'module', - $this->getUrl(0), - 'config', - [ - 'timeOut' => $this->getInput('registrationConfigTimeOut', helper::FILTER_INT) * 60, - 'pageSuccess' => $this->getInput('registrationConfigSuccess'), - 'pageError' => $this->getInput('registrationConfigError'), - 'approval' => $this->getInput('registrationConfigState', helper::FILTER_BOOLEAN), - 'mailRegisterContent' => $this->getInput('registrationconfigMailRegisterContent', null, true), - 'mailValidateContent' => $this->getInput('registrationconfigMailValidateContent', null, true), - 'layout' => $this->getInput('registrationConfigLayout'), - 'filter' => $this->getInput('registrationConfigFilter', helper::FILTER_STRING_SHORT) - ] - ]); - $this->addOutput([ - 'redirect' => helper::baseUrl() . $this->getUrl(), - 'notification' => 'Modifications enregistrées', - 'state' => true - ]); - } - // Valeurs en sortie - $this->addOutput([ - 'title' => 'Configuration', - 'view' => 'config', - 'vendor' => ['tinymce'] - ]); - } -} - + + * @copyright Copyright (C) 2018-2020, Frédéric Tempez + * @license CC Attribution-NonCommercial-NoDerivatives 4.0 International + * @link http://zwiicms.com/ + */ + +class suscribe extends common +{ + + const VERSION = '2.2'; + const REALNAME = 'Auto Inscription'; + const DELETE = true; + const UPDATE = '0.0'; + const DATADIRECTORY = ''; // Contenu localisé inclus par défaut (page.json et module.json) + + const STATUS_EMAIL_AWAITING = 0; + const STATUS_EMAIL_VALID = 1; + const STATUS_ACCOUNT_AWAITING = 2; + const STATUS_ACCOUNT_VALID = 3; + public static $statusGroups = [ + self::STATUS_EMAIL_AWAITING => 'Email non confirmé', + self::STATUS_EMAIL_VALID => 'Email valide', + self::STATUS_ACCOUNT_AWAITING => 'Email valide, en attente de confirmation', + self::STATUS_ACCOUNT_VALID => 'Email valide, compte activé', + ]; + + public static $actions = [ + 'index' => self::GROUP_VISITOR, + 'validate' => self::GROUP_VISITOR, + 'config' => self::GROUP_EDITOR, + 'users' => self::GROUP_EDITOR, + 'delete' => self::GROUP_EDITOR, + 'edit' => self::GROUP_EDITOR + ]; + + public static $layout = [ + 'inputRowContainer1' => 'Un élément par ligne', + 'inputRowContainer2' => 'Deux éléments par ligne', + 'inputRowContainer4' => 'Quatre éléments par ligne', + ]; + + public static $timeLimit = [ + 2 => '2 minutes', + 5 => '5 minutes', + 10 => '10 minutes' + ]; + + public static $users = []; + + public static $groups = []; + public static $userProfils = []; + public static $userProfilsComments = []; + + /** + * Liste des utilisateurs en attente + */ + public function users() + { + $userIdsFirstnames = helper::arraycollumn($this->getData(['module', $this->getUrl(0), 'users']), 'firstname'); + ksort($userIdsFirstnames); + foreach ($userIdsFirstnames as $userId => $userFirstname) { + self::$users[] = [ + $userId, + $userFirstname . ' ' . $this->getData(['module', $this->getUrl(0), 'users', $userId, 'lastname']), + self::$statusGroups[$this->getData(['module', $this->getUrl(0), 'users', $userId, 'status'])], + helper::dateUTF8(date('Y-m-d G:i'), $this->getData(['module', $this->getUrl(0), 'users', $userId, 'timer'])), + template::button('registrationUserEdit' . $userId, [ + 'href' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $userId, + 'value' => template::ico('pencil') + ]), + template::button('registrationUserDelete' . $userId, [ + 'class' => 'userDelete red', + 'href' => helper::baseUrl() . $this->getUrl(0) . '/delete/' . $userId, + 'value' => template::ico('cancel') + ]) + ]; + } + // Valeurs en sortie + $this->addOutput([ + 'title' => 'Inscription en attente', + 'view' => 'users' + ]); + } + + + /** + * Édition + */ + public function edit() + { + if ( + $this->getUser('permission', __CLASS__, __FUNCTION__) !== true + ) { + // Valeurs en sortie + $this->addOutput([ + 'access' => false + ]); + } + // Accès refusé + if ( + // L'utilisateur n'existe pas + $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2)]) === null + // Droit d'édition + and ( + // Impossible de s'auto-éditer + ( + $this->getUser('id') === 'user' + and $this->getUrl('group') <= self::GROUP_VISITOR + ) + // Impossible d'éditer un autre utilisateur + or ($this->getUrl('group') < self::GROUP_EDITOR) + ) + ) { + // Valeurs en sortie + $this->addOutput([ + 'access' => false + ]); + } + // Accès autorisé + else { + // Soumission du formulaire + if ( + $this->getUser('permission', __CLASS__, __FUNCTION__) === true + && $this->isPost() + ) { + // Créer le user dans la base + $this->setData([ + 'user', + $this->getUrl(2), + [ + 'firstname' => $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'firstname']), + 'forgot' => 0, + 'group' => $this->getInput('registrationUserEditGroup', helper::FILTER_INT), + // Le profil vaut 0 pour les amdins et 1 pour les autres membres, profil par défaut. + 'profil' => $this->getInput('registrationUserEditGroup', helper::FILTER_INT) === self::GROUP_ADMIN + ? 0 : 1, + 'lastname' => $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'lastname']), + 'mail' => $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'mail']), + 'password' => $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'password']), + 'tags' => $this->getInput('registrationUserLabel', helper::FILTER_STRING_SHORT), + 'connectFail' => $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'connectFail']), + 'connectTimeout' => $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'connectTimeout']), + 'accessUrl' => $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'accessUrl']), + 'accessTimer' => $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'accessTimer']), + 'accessCsrf' => $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'accessCsrf']) + ] + ]); + // Notifier le user uniquement si le groupe est membre au moins membre + if ($this->getInput('registrationUserEditGroup') >= 1) { + $this->sendMail( + $this->getData(['module', $this->getUrl(0), 'users', 'mail']), + 'Approbation de l\'inscription', + '

' . $this->getdata(['module', $this->getUrl(0), 'config', 'mailValidateContent']) . '

', + null, + $this->getData(['config', 'smtp', 'from']) + ); + } + // Supprimer le user de la base temporaire, + $this->deleteData(['module', $this->getUrl(0), 'users', $this->getUrl(2)]); + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/users', + 'notification' => 'Modifications enregistrées', + 'state' => true + ]); + } + // Changement temporaire de libellé du groupe 0 + self::$groups = self::$groupEdits; + self::$groups[self::GROUP_BANNED] = 'En attente d\'approbation'; + + // Profils disponibles + foreach ($this->getData(['profil']) as $profilId => $profilData) { + if ($profilId < self::GROUP_MEMBER) { + continue; + } + if ($profilId === self::GROUP_ADMIN) { + self::$userProfils[$profilId][self::GROUP_ADMIN] = $profilData['name']; + self::$userProfilsComments[$profilId][self::GROUP_ADMIN] = $profilData['comment']; + continue; + } + foreach ($profilData as $key => $value) { + self::$userProfils[$profilId][$key] = $profilData[$key]['name']; + self::$userProfilsComments[$profilId][$key] = $profilData[$key]['name'] . ' : ' . $profilData[$key]['comment']; + } + } + + // Valeurs en sortie + $this->addOutput([ + 'title' => $this->getData(['module', $this->getUrl(0), 'users', 'firstname']) . ' ' . $this->getData(['user', $this->getUrl(0), 'lastname']), + 'view' => 'edit' + ]); + } + } + + + /** + * Suppression + */ + public function delete() + { + // Accès refusé + if ( + // L'utilisateur n'existe pas + $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2)]) === null + // Groupe insuffisant + && $this->getUser('permission', __CLASS__, __FUNCTION__) !== true + ) { + // Valeurs en sortie + $this->addOutput([ + 'access' => false + ]); + } + // Suppression + else { + $this->deleteData(['module', $this->getUrl(0), 'users', $this->getUrl(2)]); + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/users', + 'notification' => 'Utilisateur supprimé', + 'state' => true + ]); + } + } + + + /** + * Ajout + */ + public function index() + { + /** + * Traitement du formulaire + * Stocke les données du formulaire dans le module + * Envoie le mail de vérification de l'email + */ + // Soumission du formulaire + if ($this->isPost()) { + // Le domaine saisi est invalide si un filtre existe + if ( + !empty($this->getData(['module', $this->getUrl(0), 'config', 'filter'])) + ) { + // Contrôler la validité du domaine saisi parmi les domaines valides + $email_to_check = $this->getInput('registrationAddMail', helper::FILTER_MAIL, true); + + // Récupérer la liste des domaines valides depuis la configuration et supprimer les espaces autour + $filter = trim($this->getData(['module', $this->getUrl(0), 'config', 'filter'])); + + // Vérifier si la liste contient plusieurs domaines ou un seul, puis supprimer les espaces pour chaque domaine + $valid_domains = strpos($filter, ';') === false + ? [trim($filter)] // Si un seul domaine, on supprime les espaces et on le met dans un tableau + : array_map('trim', explode(';', $filter)); // Si plusieurs domaines, on les explose en tableau et supprime les espaces + + // Extraire le domaine de l'adresse email à vérifier + $email_domain = explode('@', $email_to_check)[1]; + + // Vérifier si le domaine de l'email est dans la liste des domaines valides + if (!in_array($email_domain, $valid_domains)) { + self::$inputNotices['registrationAddMail'] = 'Ce domaine n\'est pas autorisé'; + } + + } + // Email valide, on continue le traitement + if (self::$inputNotices === []) { + // Drapeau de contrôle des données saisies. + $check = true; + $sentMailtoUser = false; + // L'identifiant d'utilisateur est indisponible + $userId = $this->getInput('registrationAddId', helper::FILTER_ID, true); + if (is_array($this->getData(['user', $userId]))) { + self::$inputNotices['registrationAddId'] = 'Identifiant invalide'; + $check = false; + } + // Le compte existe déjà + foreach ($this->getData(['user']) as $usersId => $user) { + if ($user['mail'] === $this->getInput('registrationAddMail', helper::FILTER_MAIL, true)) { + self::$inputNotices['registrationAddMail'] = 'Vous ne pouvez pas utilisez cette boite mail'; + $check = false; + break; + } + } + // Données de l'utilisateur + $userFirstname = $this->getInput('registrationAddFirstname', helper::FILTER_STRING_SHORT, true); + $userLastname = $this->getInput('registrationAddLastname', helper::FILTER_STRING_SHORT, true); + $userMail = $this->getInput('registrationAddMail', helper::FILTER_MAIL, true); + // Pas de nom saisi + if ( + empty($userFirstname) || + empty($userLastname) + ) { + $check = false; + } + // Si tout est ok + if ($check === true) { + // Enregistrement du compte dans les données du module + $auth = uniqid('', true); + $this->setData([ + 'module', + $this->getUrl(0), + 'users', + $userId, + [ + 'firstname' => $userFirstname, + 'lastname' => $userLastname, + 'mail' => $userMail, + 'password' => '', + // pas de groupe afin de le différencier dans la liste des users + 'timer' => time(), + 'auth' => $auth, + 'status' => self::STATUS_EMAIL_AWAITING + ] + ]); + // Mail d'avertissement aux administrateurs + // Utilisateurs dans le groupe admin + $to = []; + foreach ($this->getData(['user']) as $key => $user) { + if ($user['group'] == self::GROUP_ADMIN) { + $to[] = $user['mail']; + } + } + // Envoi du mail à l'administrateur + if ($check && is_array($to)) { + $this->sendMail( + $to, + 'Auto-inscription sur le site ' . $this->getData(['config', 'title']), + '

Un nouveau membre s\'est inscrit, son email est en attente de validation

' . + '

Identifiant du compte : ' . $userId . ' (' . $userFirstname . ' ' . $userLastname . ')
' . + 'Email : ' . $userMail . '

' . + '
Validation de l\'inscription', + null, + $this->getData(['config', 'smtp', 'from']) + ); + } + + // Mail de confirmation à l'utilisateur + // forger le lien de vérification + $validateLink = helper::baseUrl(true) . $this->getUrl() . '/validate/' . $userId . '/' . $auth; + // Envoi + if ($check) { + $sentMailtoUser = $this->sendMail( + $userMail, + 'Confirmation de votre inscription', + '

' . $this->getdata(['module', $this->getUrl(0), 'config', 'mailRegisterContent']) . '

' . + '

Activer votre compte' . '

' . + '

ou copiez collez le lien suivant dans un navigateur : ' . $validateLink . '

' + , + null, + $this->getData(['config', 'smtp', 'from']) + ); + } + } + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl(), + //'redirect' => $validateLink, + 'notification' => $sentMailtoUser ? "Un mail vous a été envoyé." : 'Quelque chose n\'a pas fonctionné !', + 'state' => $sentMailtoUser ? true : false + ]); + } + } + // Valeurs en sortie + $this->addOutput([ + 'title' => 'Inscription', + 'view' => 'index', + 'showBarEditButton' => true, + 'showPageContent' => true + ]); + } + + /** + * Vérification de l'email + */ + public function validate() + { + // Soumission du formulaire + if ($this->isPost()) { + // Vérifie la session + l'id + le timer + $check = true; + $notification = 'Bienvenue sur le site ' . $this->getData(['config', 'title']); + $userId = $this->getUrl(2); + $auth = $this->getUrl(3); + // la validité du lien est dépassé + if ( + (time() - $this->getData(['module', $this->getUrl(0), 'users', $userId, 'timer'])) + >= $this->getdata(['module', $this->getUrl(0), 'config', 'timeOut']) + ) { + $check = false; + $notification = 'La validité du lien est dépassée'; + } + // La clé est incorrecte ou le compte n'est pas en attente de validation + if ( + $check + && $auth !== $this->getData(['module', $this->getUrl(0), 'users', $userId, 'auth']) + && $this->getData(['module', $this->getUrl(0), 'users', $userId, 'status']) !== self::STATUS_EMAIL_AWAITING + ) { + $check = false; + $notification = 'Données incorrectes !'; + } + // Double vérification pour le mot de passe + if ( + $check + && $this->getInput('registrationValidPassword', helper::FILTER_STRING_SHORT, true) !== $this->getInput('registrationValidConfirmPassword', helper::FILTER_STRING_SHORT, true) + ) { + self::$inputNotices['registrationAddConfirmPassword'] = 'Les mots de passe ne sont pas identiques'; + $check = false; + } + + if ($check) { + if ( + // Pas d'approbation par un administrateur + $this->getData(['module', $this->getUrl(0), 'config', 'approval']) === false + ) { + // Créer le compte + $this->setData([ + 'user', + $userId, + [ + 'firstname' => $this->getData(['module', $this->getUrl(0), 'users', $userId, 'firstname']), + 'lastname' => $this->getData(['module', $this->getUrl(0), 'users', $userId, 'lastname']), + 'mail' => $this->getData(['module', $this->getUrl(0), 'users', $userId, 'mail']), + 'password' => $this->getInput('registrationValidPassword', helper::FILTER_PASSWORD, true), + 'group' => self::GROUP_MEMBER, + 'profil' => 1, + 'forgot' => 0, + 'pseudo' => $userId, + 'signature' => 1, + 'language' => self::$siteContent, + ] + ]); + // Modifier le statut dans le module + $this->deleteData(['module', $this->getUrl(0), 'users', $userId]); + $notification = 'Votre inscription est confirmée'; + } else { + // Approbation nécessaire + $this->setData(['module', $this->getUrl(0), 'users', $userId, 'status', self::STATUS_ACCOUNT_AWAITING]); + $notification = 'L\'inscription doit être approuvée par un administrateur'; + } + } + // Valeurs en sortie + $this->addOutput([ + 'redirect' => $check ? helper::baseUrl() . $this->getdata(['module', $this->getUrl(0), 'config', 'pageSuccess']) : helper::baseUrl() . $this->getdata(['module', $this->getUrl(0), 'config', 'pageError']), + 'notification' => $notification, + 'state' => $check + ]); + } + // Valeurs en sortie + $this->addOutput([ + 'title' => 'Saisie du mot de passe', + 'view' => 'validate' + ]); + } + + /** + * Module de configuration + */ + public function config() + { + // Soumission du formulaire + if ( + $this->getUser('permission', __CLASS__, __FUNCTION__) === true + && $this->isPost() + ) { + + // Lire les options et les enregistrer + $this->setData([ + 'module', + $this->getUrl(0), + 'config', + [ + 'timeOut' => $this->getInput('registrationConfigTimeOut', helper::FILTER_INT) * 60, + 'pageSuccess' => $this->getInput('registrationConfigSuccess'), + 'pageError' => $this->getInput('registrationConfigError'), + 'approval' => $this->getInput('registrationConfigState', helper::FILTER_BOOLEAN), + 'mailRegisterContent' => $this->getInput('registrationconfigMailRegisterContent', null, true), + 'mailValidateContent' => $this->getInput('registrationconfigMailValidateContent', null, true), + 'layout' => $this->getInput('registrationConfigLayout'), + 'filter' => $this->getInput('registrationConfigFilter', helper::FILTER_STRING_SHORT) + ] + ]); + $this->addOutput([ + 'redirect' => helper::baseUrl() . $this->getUrl(), + 'notification' => 'Modifications enregistrées', + 'state' => true + ]); + } + // Valeurs en sortie + $this->addOutput([ + 'title' => 'Configuration', + 'view' => 'config', + 'vendor' => ['tinymce'] + ]); + } +} + diff --git a/module/suscribe/view/config/config.css b/module/suscribe/view/config/config.css index 66f9d77..adc81bd 100755 --- a/module/suscribe/view/config/config.css +++ b/module/suscribe/view/config/config.css @@ -1,21 +1,21 @@ -/** - * 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-2020, Frédéric Tempez - * @license CC Attribution-NonCommercial-NoDerivatives 4.0 International - * @link http://zwiicms.com/ - */ - -/** NE PAS EFFACER -* admin.css -*/ - -textarea .editorWysiwyg { - height : 100px; +/** + * 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-2020, Frédéric Tempez + * @license CC Attribution-NonCommercial-NoDerivatives 4.0 International + * @link http://zwiicms.com/ + */ + +/** NE PAS EFFACER +* admin.css +*/ + +textarea .editorWysiwyg { + height : 100px; } \ No newline at end of file diff --git a/module/suscribe/view/config/config.php b/module/suscribe/view/config/config.php index 061e7cc..363ada1 100755 --- a/module/suscribe/view/config/config.php +++ b/module/suscribe/view/config/config.php @@ -1,103 +1,103 @@ - -
-
- 'buttonGrey', - 'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(0) . '/' . self::$siteContent, - 'value' => template::ico('left') - ]); ?> -
-
- helper::baseUrl() . $this->getUrl(0) . '/users', - 'value' => 'Inscriptions' - ]); ?> -
-
- 'green' - ]); ?> -
-
-
-
-
-

Paramètres

-
-
- 'Disposition', - 'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'layout']) - ]); ?> -
-
- getData(['page']), 'title', 'SORT_ASC'), [ - 'label' => 'Redirection après confirmation', - 'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'pageSuccess']) - ]); ?> -
-
- getData(['page']), 'title', 'SORT_ASC'), [ - 'label' => 'Redirection après erreur', - 'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'pageError']) - ]); ?> -
-
-
-
-
-
-
-
-

Communication

-
-
- 'Validité du lien', - 'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'timeOut']) / 60 - ]); ?> -
-
- 'Domaines acceptés', - 'value' => $this->getData(['module', $this->getUrl(0), 'config', 'filter']), - 'help' => 'Champ vide sinon limitation à des domaines spécifiques, le séparateur est ;' - ]); ?> -
-
-
-
- Confirmez votre inscription en cliquant sur ce lien dans les ... minutes.

'; ?> - 'Corps du mail de confirmation', - 'value' => !empty($this->getData(['module', $this->getUrl(0), 'config', 'mailRegisterContent'])) ? $this->getData(['module', $this->getUrl(0), 'config', 'mailRegisterContent']) : $messageDefault, - 'class' => 'editorWysiwyg', - 'help' => 'Précisez la durée de validité. Le lien sera inséré après ces explications.' - ]); ?> -
-
-
-
- $this->getData(['module', $this->getUrl(0), 'config', 'approval']), - 'help' => 'Les comptes sont inactifs tant que les inscriptions ne sont pas approuvées par un administrateur.', - 'check' => true - ]); ?> -
-
-
-
- Votre inscription a été approuvée par un administrateur.

'; ?> - 'Corps du mail d\'approbation', - 'value' => !empty($this->getData(['module', $this->getUrl(0), 'config', 'mailValidateContent'])) ? $this->getData(['module', $this->getUrl(0), 'config', 'mailValidateContent']) : $messageDefault, - 'class' => 'editorWysiwyg' - ]); ?> -
-
-
-
-
- -
Version n° + +
+
+ 'buttonGrey', + 'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(0) . '/' . self::$siteContent, + 'value' => template::ico('left') + ]); ?> +
+
+ helper::baseUrl() . $this->getUrl(0) . '/users', + 'value' => 'Inscriptions' + ]); ?> +
+
+ 'green' + ]); ?> +
+
+
+
+
+

Paramètres

+
+
+ 'Disposition', + 'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'layout']) + ]); ?> +
+
+ getData(['page']), 'title', 'SORT_ASC'), [ + 'label' => 'Redirection après confirmation', + 'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'pageSuccess']) + ]); ?> +
+
+ getData(['page']), 'title', 'SORT_ASC'), [ + 'label' => 'Redirection après erreur', + 'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'pageError']) + ]); ?> +
+
+
+
+
+
+
+
+

Communication

+
+
+ 'Validité du lien', + 'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'timeOut']) / 60 + ]); ?> +
+
+ 'Domaines acceptés', + 'value' => $this->getData(['module', $this->getUrl(0), 'config', 'filter']), + 'help' => 'Champ vide sinon limitation à des domaines spécifiques, le séparateur est ;' + ]); ?> +
+
+
+
+ Confirmez votre inscription en cliquant sur ce lien dans les ... minutes.

'; ?> + 'Corps du mail de confirmation', + 'value' => !empty($this->getData(['module', $this->getUrl(0), 'config', 'mailRegisterContent'])) ? $this->getData(['module', $this->getUrl(0), 'config', 'mailRegisterContent']) : $messageDefault, + 'class' => 'editorWysiwyg', + 'help' => 'Précisez la durée de validité. Le lien sera inséré après ces explications.' + ]); ?> +
+
+
+
+ $this->getData(['module', $this->getUrl(0), 'config', 'approval']), + 'help' => 'Les comptes sont inactifs tant que les inscriptions ne sont pas approuvées par un administrateur.', + 'check' => true + ]); ?> +
+
+
+
+ Votre inscription a été approuvée par un administrateur.

'; ?> + 'Corps du mail d\'approbation', + 'value' => !empty($this->getData(['module', $this->getUrl(0), 'config', 'mailValidateContent'])) ? $this->getData(['module', $this->getUrl(0), 'config', 'mailValidateContent']) : $messageDefault, + 'class' => 'editorWysiwyg' + ]); ?> +
+
+
+
+
+ +
Version n°
\ No newline at end of file diff --git a/module/suscribe/view/edit/edit.css b/module/suscribe/view/edit/edit.css index 0a71300..3c06906 100755 --- a/module/suscribe/view/edit/edit.css +++ b/module/suscribe/view/edit/edit.css @@ -1,21 +1,21 @@ -/** - * 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-2020, Frédéric Tempez - * @license CC Attribution-NonCommercial-NoDerivatives 4.0 International - * @link http://zwiicms.com/ - */ - -/** NE PAS EFFACER -* admin.css -*/ -#registrationUserEditProfil1Wrapper, -#registrationUserEditProfil2Wrapper { - padding: 0; -} +/** + * 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-2020, Frédéric Tempez + * @license CC Attribution-NonCommercial-NoDerivatives 4.0 International + * @link http://zwiicms.com/ + */ + +/** NE PAS EFFACER +* admin.css +*/ +#registrationUserEditProfil1Wrapper, +#registrationUserEditProfil2Wrapper { + padding: 0; +} diff --git a/module/suscribe/view/edit/edit.js.php b/module/suscribe/view/edit/edit.js.php index 20080fb..92416ed 100755 --- a/module/suscribe/view/edit/edit.js.php +++ b/module/suscribe/view/edit/edit.js.php @@ -1,31 +1,31 @@ -/** - * 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 Frédéric Tempez - * @copyright Copyright (C) 2018-2020, Frédéric Tempez - * @license CC Attribution-NonCommercial-NoDerivatives 4.0 International - * @link http://zwiicms.com/ - */ - -/** - * Droits des groupes - */ - - -$(document).ready(function () { - $(".registrationUserEditGroupProfil").hide(); - $(".registrationUserCommentProfil").hide(); - $("#registrationUserEditGroupProfil" + $("#registrationUserEditGroup").val()).show(); - $("#registrationUserCommentProfil" + $("#registrationUserEditGroup").val()).show(); - - $("#registrationUserEditGroup").on("change", function () { - $(".registrationUserEditGroupProfil").hide(); - $(".registrationUserCommentProfil").hide(); - $("#registrationUserEditGroupProfil" + $(this).val()).show(); - $("#registrationUserCommentProfil" + $(this).val()).show(); - }); - +/** + * 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 Frédéric Tempez + * @copyright Copyright (C) 2018-2020, Frédéric Tempez + * @license CC Attribution-NonCommercial-NoDerivatives 4.0 International + * @link http://zwiicms.com/ + */ + +/** + * Droits des groupes + */ + + +$(document).ready(function () { + $(".registrationUserEditGroupProfil").hide(); + $(".registrationUserCommentProfil").hide(); + $("#registrationUserEditGroupProfil" + $("#registrationUserEditGroup").val()).show(); + $("#registrationUserCommentProfil" + $("#registrationUserEditGroup").val()).show(); + + $("#registrationUserEditGroup").on("change", function () { + $(".registrationUserEditGroupProfil").hide(); + $(".registrationUserCommentProfil").hide(); + $("#registrationUserEditGroupProfil" + $(this).val()).show(); + $("#registrationUserCommentProfil" + $(this).val()).show(); + }); + }); \ No newline at end of file diff --git a/module/suscribe/view/edit/edit.php b/module/suscribe/view/edit/edit.php index 15b4ec6..87eb4fb 100755 --- a/module/suscribe/view/edit/edit.php +++ b/module/suscribe/view/edit/edit.php @@ -1,140 +1,140 @@ - -
-
- 'buttonGrey', - 'href' => helper::baseUrl() . $this->geturl(0) . '/users', - 'value' => template::ico('left') - ]); ?> -
-
- 'green' - ]); ?> -
-
-
-
-
-

Confirmation de l'inscription

-
-
-
-
- 'off', - 'label' => 'Prénom', - 'value' => $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'firstname']), - 'disabled' => true - ]); ?> -
-
- 'off', - 'label' => 'Nom', - 'value' => $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'lastname']), - 'disabled' => true - ]); ?> -
-
-
-
- 'off', - 'label' => 'Adresse électronique', - 'value' => $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'mail']), - 'disabled' => true - ]); ?> -
-
-
-
- 'État de l\'inscription', - 'value' => $module::$statusGroups[$this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'status'])], - 'disabled' => true, - 'help' => 'En attente : le mail n\'a pas encore été validé
Email validé : approbation nécessaire.' - ]); ?> -
-
- 'Date de demande', - 'value' => helper::dateUTF8(date('Y-m-d G:i'), $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'timer'])), - 'disabled' => true - ]); ?> -
-
-
-
-
-
- 'Étiquette' - ]); ?> -
-
- getUser('group') === self::GROUP_ADMIN): ?> - ($this->getUrl(2) === $this->getUser('id')), - 'help' => ($this->getUrl(2) === $this->getUser('id') ? 'Impossible de modifier votre propre groupe.' : ''), - 'label' => 'Groupe', - 'selected' => $this->getData(['module', $this->getUrl(0), 'registrationUsers', $this->getUrl(2), 'status']) - ]); ?> - -
-
-
- 'Profil', - 'selected' => $this->getData(['user', $this->getUrl(2), 'profil']), - 'disabled' => $this->getUser('group') !== self::GROUP_ADMIN, - ]); ?> -
-
- 'Profil', - 'selected' => $this->getData(['user', $this->getUrl(2), 'profil']), - 'disabled' => $this->getUser('group') !== self::GROUP_ADMIN, - ]); ?> -
-
-
-
-
- 'Commentaire', - 'value' => implode("\n", $module::$userProfilsComments[self::GROUP_MEMBER]), - 'readonly' => true, - - ]); - ?> -
-
- 'Commentaire', - 'value' => implode("\n", $module::$userProfilsComments[self::GROUP_EDITOR]), - 'readonly' => true, - - ]); - ?> -
-
- 'Commentaire', - 'value' => implode("\n", $module::$userProfilsComments[self::GROUP_ADMIN]), - 'readonly' => true, - ]); - ?> -
-
-
-
-
-
-
+ +
+
+ 'buttonGrey', + 'href' => helper::baseUrl() . $this->geturl(0) . '/users', + 'value' => template::ico('left') + ]); ?> +
+
+ 'green' + ]); ?> +
+
+
+
+
+

Confirmation de l'inscription

+
+
+
+
+ 'off', + 'label' => 'Prénom', + 'value' => $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'firstname']), + 'disabled' => true + ]); ?> +
+
+ 'off', + 'label' => 'Nom', + 'value' => $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'lastname']), + 'disabled' => true + ]); ?> +
+
+
+
+ 'off', + 'label' => 'Adresse électronique', + 'value' => $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'mail']), + 'disabled' => true + ]); ?> +
+
+
+
+ 'État de l\'inscription', + 'value' => $module::$statusGroups[$this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'status'])], + 'disabled' => true, + 'help' => 'En attente : le mail n\'a pas encore été validé
Email validé : approbation nécessaire.' + ]); ?> +
+
+ 'Date de demande', + 'value' => helper::dateUTF8(date('Y-m-d G:i'), $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'timer'])), + 'disabled' => true + ]); ?> +
+
+
+
+
+
+ 'Étiquette' + ]); ?> +
+
+ getUser('group') === self::GROUP_ADMIN): ?> + ($this->getUrl(2) === $this->getUser('id')), + 'help' => ($this->getUrl(2) === $this->getUser('id') ? 'Impossible de modifier votre propre groupe.' : ''), + 'label' => 'Groupe', + 'selected' => $this->getData(['module', $this->getUrl(0), 'registrationUsers', $this->getUrl(2), 'status']) + ]); ?> + +
+
+
+ 'Profil', + 'selected' => $this->getData(['user', $this->getUrl(2), 'profil']), + 'disabled' => $this->getUser('group') !== self::GROUP_ADMIN, + ]); ?> +
+
+ 'Profil', + 'selected' => $this->getData(['user', $this->getUrl(2), 'profil']), + 'disabled' => $this->getUser('group') !== self::GROUP_ADMIN, + ]); ?> +
+
+
+
+
+ 'Commentaire', + 'value' => implode("\n", $module::$userProfilsComments[self::GROUP_MEMBER]), + 'readonly' => true, + + ]); + ?> +
+
+ 'Commentaire', + 'value' => implode("\n", $module::$userProfilsComments[self::GROUP_EDITOR]), + 'readonly' => true, + + ]); + ?> +
+
+ 'Commentaire', + 'value' => implode("\n", $module::$userProfilsComments[self::GROUP_ADMIN]), + 'readonly' => true, + ]); + ?> +
+
+
+
+
+
+
\ No newline at end of file diff --git a/module/suscribe/view/index/index.css b/module/suscribe/view/index/index.css index 459b7ed..11b0ba2 100644 --- a/module/suscribe/view/index/index.css +++ b/module/suscribe/view/index/index.css @@ -1,37 +1,37 @@ -/** - * 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-2020, Frédéric Tempez - * @license CC Attribution-NonCommercial-NoDerivatives 4.0 International - * @link http://zwiicms.com/ - */ - -.inputRowContainer1, -.inputRowContainer2, -.inputRowContainer4, -.inputColContainer { - display: grid; - gap: 10px; /* Espacement entre les inputs */ -} - -/* En lignes */ -.inputRowContainer1 { - grid-template-columns: repeat(1, 1fr); /* 3 colonnes de largeur égale */ -} -.inputRowContainer2 { - grid-template-columns: repeat(2, 1fr); /* 3 colonnes de largeur égale */ -} -.inputRowContainer4 { - grid-template-columns: repeat(4, 1fr); /* 3 colonnes de largeur égale */ -} - -.inputColContainer { - grid-template-rows: repeat(50px, auto); /* 3 rangées ajustées à la hauteur des contenus */ - +/** + * 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-2020, Frédéric Tempez + * @license CC Attribution-NonCommercial-NoDerivatives 4.0 International + * @link http://zwiicms.com/ + */ + +.inputRowContainer1, +.inputRowContainer2, +.inputRowContainer4, +.inputColContainer { + display: grid; + gap: 10px; /* Espacement entre les inputs */ +} + +/* En lignes */ +.inputRowContainer1 { + grid-template-columns: repeat(1, 1fr); /* 3 colonnes de largeur égale */ +} +.inputRowContainer2 { + grid-template-columns: repeat(2, 1fr); /* 3 colonnes de largeur égale */ +} +.inputRowContainer4 { + grid-template-columns: repeat(4, 1fr); /* 3 colonnes de largeur égale */ +} + +.inputColContainer { + grid-template-rows: repeat(50px, auto); /* 3 rangées ajustées à la hauteur des contenus */ + } \ No newline at end of file diff --git a/module/suscribe/view/index/index.js.php b/module/suscribe/view/index/index.js.php index 3baf44f..ca8495f 100755 --- a/module/suscribe/view/index/index.js.php +++ b/module/suscribe/view/index/index.js.php @@ -1,47 +1,47 @@ -/** - * 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 Frédéric Tempez - * @copyright Copyright (C) 2018-2020, Frédéric Tempez - * @license CC Attribution-NonCommercial-NoDerivatives 4.0 International - * @link http://zwiicms.com/ - */ - - -/** - * Affichage de l'id en simulant FILTER_ID - */ -$("#registrationAddId").on("change keydown keyup", function(event) { - var userId = $(this).val(); - if( - event.keyCode !== 8 // BACKSPACE - && event.keyCode !== 37 // LEFT - && event.keyCode !== 39 // RIGHT - && event.keyCode !== 46 // DELETE - && window.getSelection().toString() !== userId // Texte sélectionné - ) { - var searchReplace = { - "á": "a", "à": "a", "â": "a", "ä": "a", "ã": "a", "å": "a", "ç": "c", "é": "e", "è": "e", "ê": "e", "ë": "e", "í": "i", "ì": "i", "î": "i", "ï": "i", "ñ": "n", "ó": "o", "ò": "o", "ô": "o", "ö": "o", "õ": "o", "ú": "u", "ù": "u", "û": "u", "ü": "u", "ý": "y", "ÿ": "y", - "Á": "A", "À": "A", "Â": "A", "Ä": "A", "Ã": "A", "Å": "A", "Ç": "C", "É": "E", "È": "E", "Ê": "E", "Ë": "E", "Í": "I", "Ì": "I", "Î": "I", "Ï": "I", "Ñ": "N", "Ó": "O", "Ò": "O", "Ô": "O", "Ö": "O", "Õ": "O", "Ú": "U", "Ù": "U", "Û": "U", "Ü": "U", "Ý": "Y", "Ÿ": "Y", - "'": "-", "\"": "-", " ": "-" - }; - userId = userId.replace(/[áàâäãåçéèêëíìîïñóòôöõúùûüýÿ'" ]/ig, function(match) { - return searchReplace[match]; - }); - userId = userId.replace(/[^a-z0-9-]/ig, ""); - $(this).val(userId); - } -}); - -/** - * Droits des groupes - */ -$("#registrationAddGroup").on("change", function() { - $(".registrationAddGroupDescription").hide(); - $("#registrationAddGroupDescription" + $(this).val()).show(); -}).trigger("change"); - - +/** + * 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 Frédéric Tempez + * @copyright Copyright (C) 2018-2020, Frédéric Tempez + * @license CC Attribution-NonCommercial-NoDerivatives 4.0 International + * @link http://zwiicms.com/ + */ + + +/** + * Affichage de l'id en simulant FILTER_ID + */ +$("#registrationAddId").on("change keydown keyup", function(event) { + var userId = $(this).val(); + if( + event.keyCode !== 8 // BACKSPACE + && event.keyCode !== 37 // LEFT + && event.keyCode !== 39 // RIGHT + && event.keyCode !== 46 // DELETE + && window.getSelection().toString() !== userId // Texte sélectionné + ) { + var searchReplace = { + "á": "a", "à": "a", "â": "a", "ä": "a", "ã": "a", "å": "a", "ç": "c", "é": "e", "è": "e", "ê": "e", "ë": "e", "í": "i", "ì": "i", "î": "i", "ï": "i", "ñ": "n", "ó": "o", "ò": "o", "ô": "o", "ö": "o", "õ": "o", "ú": "u", "ù": "u", "û": "u", "ü": "u", "ý": "y", "ÿ": "y", + "Á": "A", "À": "A", "Â": "A", "Ä": "A", "Ã": "A", "Å": "A", "Ç": "C", "É": "E", "È": "E", "Ê": "E", "Ë": "E", "Í": "I", "Ì": "I", "Î": "I", "Ï": "I", "Ñ": "N", "Ó": "O", "Ò": "O", "Ô": "O", "Ö": "O", "Õ": "O", "Ú": "U", "Ù": "U", "Û": "U", "Ü": "U", "Ý": "Y", "Ÿ": "Y", + "'": "-", "\"": "-", " ": "-" + }; + userId = userId.replace(/[áàâäãåçéèêëíìîïñóòôöõúùûüýÿ'" ]/ig, function(match) { + return searchReplace[match]; + }); + userId = userId.replace(/[^a-z0-9-]/ig, ""); + $(this).val(userId); + } +}); + +/** + * Droits des groupes + */ +$("#registrationAddGroup").on("change", function() { + $(".registrationAddGroupDescription").hide(); + $("#registrationAddGroupDescription" + $(this).val()).show(); +}).trigger("change"); + + diff --git a/module/suscribe/view/index/index.php b/module/suscribe/view/index/index.php index fe523b6..d419acc 100755 --- a/module/suscribe/view/index/index.php +++ b/module/suscribe/view/index/index.php @@ -1,29 +1,29 @@ - -
- 'off', - 'label' => 'Prénom' - ]); ?> - 'off', - 'label' => 'Nom' - ]); ?> - 'off', - 'label' => 'Identifiant de connexion' - ]); ?> - 'off', - 'label' => 'Adresse électronique' - ]); ?> -
-
-
-
- 'Envoyer' - ]); ?> -
-
-
+ +
+ 'off', + 'label' => 'Prénom' + ]); ?> + 'off', + 'label' => 'Nom' + ]); ?> + 'off', + 'label' => 'Identifiant de connexion' + ]); ?> + 'off', + 'label' => 'Adresse électronique' + ]); ?> +
+
+
+
+ 'Envoyer' + ]); ?> +
+
+
\ No newline at end of file diff --git a/module/suscribe/view/users/users.css b/module/suscribe/view/users/users.css index 85db3ce..6aeea6c 100644 --- a/module/suscribe/view/users/users.css +++ b/module/suscribe/view/users/users.css @@ -1,17 +1,17 @@ -/** - * 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-2020, Frédéric Tempez - * @license CC Attribution-NonCommercial-NoDerivatives 4.0 International - * @link http://zwiicms.com/ - */ - -/** NE PAS EFFACER -* admin.css +/** + * 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-2020, Frédéric Tempez + * @license CC Attribution-NonCommercial-NoDerivatives 4.0 International + * @link http://zwiicms.com/ + */ + +/** NE PAS EFFACER +* admin.css */ \ No newline at end of file diff --git a/module/suscribe/view/users/users.js.php b/module/suscribe/view/users/users.js.php index 1ed4c16..e7026fe 100644 --- a/module/suscribe/view/users/users.js.php +++ b/module/suscribe/view/users/users.js.php @@ -1,21 +1,21 @@ -/** - * 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 Frédéric Tempez - * @copyright Copyright (C) 2018-2020, Frédéric Tempez - * @license CC Attribution-NonCommercial-NoDerivatives 4.0 International - * @link http://zwiicms.com/ - */ - -/** - * Confirmation de suppression - */ -$(".registrationUserDelete").on("click", function() { - var _this = $(this); - return core.confirm("Êtes-vous sûr de vouloir supprimer cet utilisateur ?", function() { - $(location).attr("href", _this.attr("href")); - }); +/** + * 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 Frédéric Tempez + * @copyright Copyright (C) 2018-2020, Frédéric Tempez + * @license CC Attribution-NonCommercial-NoDerivatives 4.0 International + * @link http://zwiicms.com/ + */ + +/** + * Confirmation de suppression + */ +$(".registrationUserDelete").on("click", function() { + var _this = $(this); + return core.confirm("Êtes-vous sûr de vouloir supprimer cet utilisateur ?", function() { + $(location).attr("href", _this.attr("href")); + }); }); \ No newline at end of file diff --git a/module/suscribe/view/users/users.php b/module/suscribe/view/users/users.php index 3cad998..8262182 100644 --- a/module/suscribe/view/users/users.php +++ b/module/suscribe/view/users/users.php @@ -1,15 +1,15 @@ -
-
- 'buttonGrey', - 'href' => helper::baseUrl() . $this->getUrl(0) . '/config', - 'value' => template::ico('left') - ]); ?> -
-
- - - - - +
+
+ 'buttonGrey', + 'href' => helper::baseUrl() . $this->getUrl(0) . '/config', + 'value' => template::ico('left') + ]); ?> +
+
+ + + + + \ No newline at end of file diff --git a/module/suscribe/view/validate/validate.css b/module/suscribe/view/validate/validate.css index 6fb8540..68fbfb1 100644 --- a/module/suscribe/view/validate/validate.css +++ b/module/suscribe/view/validate/validate.css @@ -1,34 +1,34 @@ -/** - * 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-2020, Frédéric Tempez - * @license CC Attribution-NonCommercial-NoDerivatives 4.0 International - * @link http://zwiicms.com/ - */ - -.inputRowContainer1, -.inputRowContainer2, -.inputRowContainer4, -.inputColContainer { - display: grid; - gap: 10px; -} - -/* En lignes */ -.inputRowContainer1 { - grid-template-columns: repeat(1, 1fr); -} - -.inputRowContainer2 { - grid-template-columns: repeat(2, 1fr); -} - -.inputRowContainer4 { - grid-template-columns: repeat(2, 1fr); +/** + * 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-2020, Frédéric Tempez + * @license CC Attribution-NonCommercial-NoDerivatives 4.0 International + * @link http://zwiicms.com/ + */ + +.inputRowContainer1, +.inputRowContainer2, +.inputRowContainer4, +.inputColContainer { + display: grid; + gap: 10px; +} + +/* En lignes */ +.inputRowContainer1 { + grid-template-columns: repeat(1, 1fr); +} + +.inputRowContainer2 { + grid-template-columns: repeat(2, 1fr); +} + +.inputRowContainer4 { + grid-template-columns: repeat(2, 1fr); } \ No newline at end of file diff --git a/module/suscribe/view/validate/validate.php b/module/suscribe/view/validate/validate.php index b50d659..7add1ff 100755 --- a/module/suscribe/view/validate/validate.php +++ b/module/suscribe/view/validate/validate.php @@ -1,23 +1,23 @@ - -

Email confirmé

-
- 'off', - 'label' => 'Mot de passe' - ]); ?> - 'off', - 'label' => 'Confirmation du mot de passe' - ]); ?> -
-
-
-
- 'Envoyer', - 'class' => 'green' - ]); ?> -
-
-
+ +

Email confirmé

+
+ 'off', + 'label' => 'Mot de passe' + ]); ?> + 'off', + 'label' => 'Confirmation du mot de passe' + ]); ?> +
+
+
+
+ 'Envoyer', + 'class' => 'green' + ]); ?> +
+
+
\ No newline at end of file