update suscribe

This commit is contained in:
Fred Tempez 2024-07-17 20:13:53 +02:00
parent 8131162dae
commit cbffc3f44b
14 changed files with 465 additions and 272 deletions

View File

@ -1,6 +0,0 @@
# Version 1.4
- Masque le code de vérification
# Version 1.3
- Remplacement de flatpick par date
# Version 1.2
- Compatiblité PHP 8.2

View File

@ -1 +1 @@
{"name":"registration","realName":"Auto-Inscription","version":"1.2","update":"0.0","delete":true,"dataDirectory":""} suscribeAuto-Inscription2.0test0.01

View File

@ -15,7 +15,7 @@
class suscribe extends common class suscribe extends common
{ {
const VERSION = '1.4'; const VERSION = '2.0test3';
const REALNAME = 'Auto-Inscription'; const REALNAME = 'Auto-Inscription';
const DELETE = true; const DELETE = true;
const UPDATE = '0.0'; const UPDATE = '0.0';
@ -27,21 +27,25 @@ class suscribe extends common
const STATUS_ACCOUNT_VALID = 3; const STATUS_ACCOUNT_VALID = 3;
public static $statusGroups = [ public static $statusGroups = [
self::STATUS_EMAIL_AWAITING => 'Email non confirmé', self::STATUS_EMAIL_AWAITING => 'Email non confirmé',
self::STATUS_EMAIL_VALID => 'Email confimé', self::STATUS_EMAIL_VALID => 'Email valide',
self::STATUS_ACCOUNT_AWAITING => 'Email validé, en attente de validation', self::STATUS_ACCOUNT_AWAITING => 'Email valide, en attente de confirmation',
self::STATUS_ACCOUNT_VALID => 'Email validé, compte activé', self::STATUS_ACCOUNT_VALID => 'Email valide, compte activé',
]; ];
public static $actions = [ public static $actions = [
'index' => self::GROUP_VISITOR, 'index' => self::GROUP_VISITOR,
'validate' => self::GROUP_VISITOR, 'validate' => self::GROUP_VISITOR,
'config' => self::GROUP_EDITOR, 'config' => self::GROUP_EDITOR,
'user' => self::GROUP_EDITOR, 'users' => self::GROUP_EDITOR,
'delete' => self::GROUP_EDITOR, 'delete' => self::GROUP_EDITOR,
'edit' => 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 = [ public static $timeLimit = [
2 => '2 minutes', 2 => '2 minutes',
@ -51,21 +55,23 @@ class suscribe extends common
public static $users = []; public static $users = [];
public static $groups = [];
public static $userProfils = [];
public static $userProfilsComments = [];
/** /**
* Liste des utilisateurs en attente * Liste des utilisateurs en attente
*/ */
public function user() public function users()
{ {
$userIdsFirstnames = helper::arraycollumn($this->getData(['module', $this->getUrl(0), 'user']), 'firstname'); $userIdsFirstnames = helper::arraycollumn($this->getData(['module', $this->getUrl(0), 'users']), 'firstname');
ksort($userIdsFirstnames); ksort($userIdsFirstnames);
foreach ($userIdsFirstnames as $userId => $userFirstname) { foreach ($userIdsFirstnames as $userId => $userFirstname) {
self::$users[] = [ self::$users[] = [
$userId, $userId,
$userFirstname . ' ' . $this->getData(['module', $this->getUrl(0), 'user', $userId, 'lastname']), $userFirstname . ' ' . $this->getData(['module', $this->getUrl(0), 'users', $userId, 'lastname']),
self::$statusGroups[$this->getData(['module', $this->getUrl(0), 'user', $userId, 'status'])], 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), 'user', $userId, 'timer'])), helper::dateUTF8(date('Y-m-d G:i'), $this->getData(['module', $this->getUrl(0), 'users', $userId, 'timer'])),
template::button('registrationUserEdit' . $userId, [ template::button('registrationUserEdit' . $userId, [
'href' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $userId, 'href' => helper::baseUrl() . $this->getUrl(0) . '/edit/' . $userId,
'value' => template::ico('pencil') 'value' => template::ico('pencil')
@ -79,8 +85,8 @@ class suscribe extends common
} }
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'title' => 'Demandes d\'inscriptions', 'title' => 'Inscription en attente',
'view' => 'user' 'view' => 'users'
]); ]);
} }
@ -101,7 +107,7 @@ class suscribe extends common
// Accès refusé // Accès refusé
if ( if (
// L'utilisateur n'existe pas // L'utilisateur n'existe pas
$this->getData(['module', $this->getUrl(0), 'user']) === null $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2)]) === null
// Droit d'édition // Droit d'édition
and ( and (
// Impossible de s'auto-éditer // Impossible de s'auto-éditer
@ -125,45 +131,69 @@ class suscribe extends common
$this->getUser('permission', __CLASS__, __FUNCTION__) === true $this->getUser('permission', __CLASS__, __FUNCTION__) === true
&& $this->isPost() && $this->isPost()
) { ) {
// Modification du groupe // Créer le user dans la base
$this->setData([ $this->setData([
'module',
$this->getUrl(0),
'user', 'user',
$this->getUrl(2),
[ [
'firstname' => $this->getData(['module', $this->getUrl(0), 'user', 'firstname']), 'firstname' => $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'firstname']),
'forgot' => 0, 'forgot' => 0,
'group' => $this->getInput('registrationUserEditGroup', helper::FILTER_INT), 'group' => $this->getInput('registrationUserEditGroup', helper::FILTER_INT),
'lastname' => $this->getData(['module', $this->getUrl(0), 'user', 'lastname']), // Le profil vaut 0 pour les amdins et 1 pour les autres membres, profil par défaut.
'mail' => $this->getData(['module', $this->getUrl(0), 'user', 'mail']), 'profil' => $this->getInput('registrationUserEditGroup', helper::FILTER_INT) === self::GROUP_ADMIN
'password' => $this->getData(['module', $this->getUrl(0), 'user', 'password']), ? 0 : 1,
'connectFail' => $this->getData(['module', $this->getUrl(0), 'user', 'connectFail']), 'lastname' => $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'lastname']),
'connectTimeout' => $this->getData(['module', $this->getUrl(0), 'user', 'connectTimeout']), 'mail' => $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'mail']),
'accessUrl' => $this->getData(['module', $this->getUrl(0), 'user', 'accessUrl']), 'password' => $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'password']),
'accessTimer' => $this->getData(['module', $this->getUrl(0), 'user', 'accessTimer']), 'connectFail' => $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'connectFail']),
'accessCsrf' => $this->getData(['module', $this->getUrl(0), 'user', 'accessCsrf']) '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 // Notifier le user uniquement si le groupe est membre au moins membre
if ($this->getInput('registrationUserEditGroup') >= 1) { if ($this->getInput('registrationUserEditGroup') >= 1) {
$this->sendMail( $this->sendMail(
$this->getData(['module', $this->getUrl(0), 'user', 'mail']), $this->getData(['module', $this->getUrl(0), 'users', 'mail']),
'Approbation de l\'inscription', 'Approbation de l\'inscription',
'<p>' . $this->getdata(['module', $this->getUrl(0), 'config', 'mailValidateContent']) . '</p>', '<p>' . $this->getdata(['module', $this->getUrl(0), 'config', 'mailValidateContent']) . '</p>',
null, null,
$this->getData(['config', 'smtp', 'from']) $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 // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/user', 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/users',
'notification' => 'Modifications enregistrées', 'notification' => 'Modifications enregistrées',
'state' => true '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 // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'title' => $this->getData(['module', $this->getUrl(0), 'user', 'firstname']) . ' ' . $this->getData(['user', $this->getUrl(0), 'lastname']), 'title' => $this->getData(['module', $this->getUrl(0), 'users', 'firstname']) . ' ' . $this->getData(['user', $this->getUrl(0), 'lastname']),
'view' => 'edit' 'view' => 'edit'
]); ]);
} }
@ -178,7 +208,7 @@ class suscribe extends common
// Accès refusé // Accès refusé
if ( if (
// L'utilisateur n'existe pas // L'utilisateur n'existe pas
$this->getData(['module', $this->getUrl(0), 'user', $this->getUrl(2)]) === null $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2)]) === null
// Groupe insuffisant // Groupe insuffisant
&& $this->getUser('permission', __CLASS__, __FUNCTION__) !== true && $this->getUser('permission', __CLASS__, __FUNCTION__) !== true
) { ) {
@ -189,10 +219,10 @@ class suscribe extends common
} }
// Suppression // Suppression
else { else {
$this->deleteData(['module', $this->getUrl(0), 'user', $this->getUrl(2)]); $this->deleteData(['module', $this->getUrl(0), 'users', $this->getUrl(2)]);
// Valeurs en sortie // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => helper::baseUrl() . $this->getUrl(0) . '/user', 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/users',
'notification' => 'Utilisateur supprimé', 'notification' => 'Utilisateur supprimé',
'state' => true 'state' => true
]); ]);
@ -212,23 +242,32 @@ class suscribe extends common
*/ */
// Soumission du formulaire // Soumission du formulaire
if ($this->isPost()) { 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. // Drapeau de contrôle des données saisies.
$check = true; $check = true;
$sentMailtoUser = false;
// L'identifiant d'utilisateur est indisponible // L'identifiant d'utilisateur est indisponible
$userId = $this->getInput('registrationAddId', helper::FILTER_ID, true); $userId = $this->getInput('registrationAddId', helper::FILTER_ID, true);
if ($this->getData(['module', $userId])) { if (is_array($this->getData(['user', $userId]))) {
self::$inputNotices['registrationAddId'] = 'Identifiant déjà enregistré'; self::$inputNotices['registrationAddId'] = 'Identifiant invalide';
$check = false; $check = false;
} }
// Double vérification pour le mot de passe // Le compte existe déjà
if ($this->getInput('registrationAddPassword', helper::FILTER_STRING_SHORT, true) !== $this->getInput('registrationAddConfirmPassword', helper::FILTER_STRING_SHORT, true)) {
self::$inputNotices['registrationAddConfirmPassword'] = 'Les mots de passe ne sont pas identiques';
$check = false;
}
// Le mail existe déjà
foreach ($this->getData(['user']) as $usersId => $user) { foreach ($this->getData(['user']) as $usersId => $user) {
if ($user['mail'] === $this->getInput('registrationAddMail', helper::FILTER_MAIL, true)) { if ($user['mail'] === $this->getInput('registrationAddMail', helper::FILTER_MAIL, true)) {
self::$inputNotices['registrationAddMail'] = 'Adresse de courriel déjà enregistrée'; self::$inputNotices['registrationAddMail'] = 'Vous ne pouvez pas utilisez cette boite mail';
$check = false; $check = false;
break; break;
} }
@ -240,26 +279,24 @@ class suscribe extends common
// Pas de nom saisi // Pas de nom saisi
if ( if (
empty($userFirstname) || empty($userFirstname) ||
empty($userLastname) || empty($userLastname)
empty($this->getInput('registrationAddPassword', helper::FILTER_STRING_SHORT, true)) ||
empty($this->getInput('registrationAddConfirmPassword', helper::FILTER_STRING_SHORT, true))
) { ) {
$check = false; $check = false;
} }
// Si tout est ok // Si tout est ok
if ($check === true) { if ($check === true) {
// Enregistrement du compte dans les donénes du module // Enregistrement du compte dans les données du module
$auth = uniqid('', true); $auth = uniqid('', true);
$this->setData([ $this->setData([
'module', 'module',
$this->getUrl(0), $this->getUrl(0),
'user', 'users',
$userId, $userId,
[ [
'firstname' => $userFirstname, 'firstname' => $userFirstname,
'lastname' => $userLastname, 'lastname' => $userLastname,
'mail' => $userMail, 'mail' => $userMail,
'password' => $this->getInput('registrationAddPassword', helper::FILTER_PASSWORD, true), 'password' => '',
// pas de groupe afin de le différencier dans la liste des users // pas de groupe afin de le différencier dans la liste des users
'timer' => time(), 'timer' => time(),
'auth' => $auth, 'auth' => $auth,
@ -275,14 +312,14 @@ class suscribe extends common
} }
} }
// Envoi du mail à l'administrateur // Envoi du mail à l'administrateur
if ($to) { if ($check && is_array($to)) {
$this->sendMail( $this->sendMail(
$to, $to,
'Auto-inscription sur le site ' . $this->getData(['config', 'title']), 'Auto-inscription sur le site ' . $this->getData(['config', 'title']),
'<p>Un nouveau membre s\'est inscrit, son email est en attentde validation</p>' . '<p>Un nouveau membre s\'est inscrit, son email est en attente de validation</p>' .
'<p><strong>Identifiant du compte :</strong> ' . $userId . ' (' . $userFirstname . ' ' . $userLastname . ')<br>' . '<p><strong>Identifiant du compte :</strong> ' . $userId . ' (' . $userFirstname . ' ' . $userLastname . ')<br>' .
'<strong>Email :</strong> ' . $userMail . '</p>' . '<strong>Email :</strong> ' . $userMail . '</p>' .
'<a href="' . helper::baseUrl() . 'user/login/' . strip_tags(str_replace('/', '_', $this->getUrl(0) . '/user')) . '">Validation de l\'inscription</a>', '<a href="' . helper::baseUrl() . 'user/login/' . strip_tags(str_replace('/', '_', $this->getUrl(0) . '/users')) . '">Validation de l\'inscription</a>',
null, null,
$this->getData(['config', 'smtp', 'from']) $this->getData(['config', 'smtp', 'from'])
); );
@ -292,8 +329,7 @@ class suscribe extends common
// forger le lien de vérification // forger le lien de vérification
$validateLink = helper::baseUrl(true) . $this->getUrl() . '/validate/' . $userId . '/' . $auth; $validateLink = helper::baseUrl(true) . $this->getUrl() . '/validate/' . $userId . '/' . $auth;
// Envoi // Envoi
$sentMailtoUser = false; if ($check) {
if ($check === true) {
$sentMailtoUser = $this->sendMail( $sentMailtoUser = $this->sendMail(
$userMail, $userMail,
'Confirmation de votre inscription', 'Confirmation de votre inscription',
@ -328,63 +364,81 @@ class suscribe extends common
*/ */
public function validate() public function validate()
{ {
// Vérifie la session + l'id + le timer // Soumission du formulaire
$check = true; if ($this->isPost()) {
$notification = 'Bienvenue sur le site' . $this->getData(['config', 'title']); // Vérifie la session + l'id + le timer
$userId = $this->getUrl(2); $check = true;
$auth = $this->getUrl(3); $notification = 'Bienvenue sur le site ' . $this->getData(['config', 'title']);
// la validité du lien est dépassé $userId = $this->getUrl(2);
if (time() - $this->getData(['module', $this->getUrl(0), 'user', $userId, 'timer']) <= (60 * $this->getdata(['module', $this->getUrl(0), 'config', 'pageTimeOut']))) { $auth = $this->getUrl(3);
$check = false; // la validité du lien est dépassé
$notification = 'La validité 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), 'user', $userId, 'auth'])
&& $this->getData(['module', $this->getUrl(0), 'user', $userId, 'status']) !== self::STATUS_EMAIL_AWAITING
) {
$check = false;
$notification = 'L\adresse transmise est incorrecte !';
}
if ($check) {
if ( if (
// Pas d'approbation par un administrateur (time() - $this->getData(['module', $this->getUrl(0), 'users', $userId, 'timer']))
$this->getData(['module', $this->getUrl(0), 'config', 'approval']) === false >= $this->getdata(['module', $this->getUrl(0), 'config', 'timeOut'])
) { ) {
// Créer le compte $check = false;
$this->setData([ $notification = 'La validité du lien est dépassée';
'user',
$userId,
[
'firstname' => $this->getData(['module', $this->getUrl(0), 'user', $userId, 'firstname']),
'lastname' => $this->getData(['module', $this->getUrl(0), 'user', $userId, 'lastname']),
'mail' => $this->getData(['module', $this->getUrl(0), 'user', $userId, 'mail']),
'password' => $this->getData(['module', $this->getUrl(0), 'user', $userId, 'password']),
'group' => self::GROUP_MEMBER,
'profil' => 1,
'forgot' => 0,
'pseudo' => $userId,
'signature' => 1,
'language' => self::$siteContent,
]
]);
// Modifier le statut dans le module
$this->setData(['module', $this->getUrl(0), 'user', $userId, 'status', self::STATUS_ACCOUNT_VALID]);
$notification = 'Votre inscription est confirmée';
} else {
// Approbation nécessaire
$this->setData(['module', $this->getUrl(0), 'user', $userId, 'status', self::STATUS_ACCOUNT_AWAITING]);
$notification = 'L\'inscription doit être approuvée par un administrateur';
} }
// 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 // Valeurs en sortie
$this->addOutput([ $this->addOutput([
'redirect' => $check ? helper::baseUrl() . $this->getdata(['module', $this->getUrl(0), 'config', 'pageSuccess']) : helper::baseUrl() . $this->getdata(['module', $this->getUrl(0), 'config', 'pageError']), 'title' => 'Saisie du mot de passe',
'notificaton' => $notification, 'view' => 'validate'
'state' => $check
]); ]);
} }
@ -398,18 +452,21 @@ class suscribe extends common
$this->getUser('permission', __CLASS__, __FUNCTION__) === true $this->getUser('permission', __CLASS__, __FUNCTION__) === true
&& $this->isPost() && $this->isPost()
) { ) {
// Lire les options et les enregistrer // Lire les options et les enregistrer
$this->setData([ $this->setData([
'module', 'module',
$this->getUrl(0), $this->getUrl(0),
'config', 'config',
[ [
'timeOut' => $this->getInput('registrationConfigTimeOut', helper::FILTER_INT), 'timeOut' => $this->getInput('registrationConfigTimeOut', helper::FILTER_INT) * 60,
'pageSuccess' => $this->getInput('registrationConfigSuccess'), 'pageSuccess' => $this->getInput('registrationConfigSuccess'),
'pageError' => $this->getInput('registrationConfigError'), 'pageError' => $this->getInput('registrationConfigError'),
'approval' => $this->getInput('registrationConfigState', helper::FILTER_BOOLEAN), 'approval' => $this->getInput('registrationConfigState', helper::FILTER_BOOLEAN),
'mailRegisterContent' => $this->getInput('registrationconfigMailRegisterContent', null, true), 'mailRegisterContent' => $this->getInput('registrationconfigMailRegisterContent', null, true),
'mailValidateContent' => $this->getInput('registrationconfigMailValidateContent', null, true), 'mailValidateContent' => $this->getInput('registrationconfigMailValidateContent', null, true),
'layout' => $this->getInput('registrationConfigLayout'),
'filter' => $this->getInput('registrationConfigFilter', helper::FILTER_STRING_SHORT)
] ]
]); ]);
$this->addOutput([ $this->addOutput([

View File

@ -1,24 +1,22 @@
<?php echo template::formOpen('registrationConfig'); ?> <?php echo template::formOpen('registrationConfig'); ?>
<div class="row"> <div class="row">
<div class="col2"> <div class="col1">
<?php echo template::button('registrationConfigBack', [ <?php echo template::button('registrationConfigBack', [
'class' => '', 'class' => 'buttonGrey',
'href' => helper::baseUrl() .'page/edit/' . $this->getUrl(0) . '/' . self::$siteContent, 'href' => helper::baseUrl() . 'page/edit/' . $this->getUrl(0) . '/' . self::$siteContent,
'ico' => 'left', 'value' => template::ico('left')
'value' => 'Retour'
]); ?> ]); ?>
</div> </div>
<div class="col2 offset6"> <div class="col2 offset7">
<?php echo template::button('registrationConfigBack', [ <?php echo template::button('registrationConfigBack', [
'href' => helper::baseUrl() .$this->getUrl(0) . '/user' , 'href' => helper::baseUrl() . $this->getUrl(0) . '/users',
'value' => 'Inscriptions' 'value' => 'Inscriptions'
]); ?> ]); ?>
</div> </div>
<div class="col2"> <div class="col2">
<?php echo template::submit('registrationConfigSubmit',[ <?php echo template::submit('registrationConfigSubmit', [
'class' => 'green' 'class' => 'green'
]); ?> ]); ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
@ -26,55 +24,75 @@
<div class="block"> <div class="block">
<h4>Paramètres</h4> <h4>Paramètres</h4>
<div class="row"> <div class="row">
<div class="col6"> <div class="col4">
<?php echo template::select('registrationConfigTimeOut', $module::$timeLimit , [ <?php echo template::select('registrationConfigLayout', $module::$layout, [
'label' => 'Validité du lien', 'label' => 'Disposition',
'selected' => $this->getData(['module',$this->getUrl(0),'config','timeOut']) 'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'layout'])
]); ?>
</div>
<div class="col4">
<?php echo template::select('registrationConfigSuccess', helper::arraycollumn($this->getData(['page']), 'title', 'SORT_ASC'), [
'label' => 'Redirection après confirmation',
'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'pageSuccess'])
]); ?>
</div>
<div class="col4">
<?php echo template::select('registrationConfigError', helper::arraycollumn($this->getData(['page']), 'title', 'SORT_ASC'), [
'label' => 'Redirection après erreur',
'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'pageError'])
]); ?> ]); ?>
</div> </div>
</div> </div>
</div>
</div>
</div>
<div class="row">
<div class="col12">
<div class="block">
<h4>Communication</h4>
<div class="row"> <div class="row">
<div class="col6"> <div class="col6">
<?php echo template::select('registrationConfigSuccess', helper::arraycollumn($this->getData(['page']), 'title', 'SORT_ASC'), [ <?php echo template::select('registrationConfigTimeOut', $module::$timeLimit, [
'label' => 'Redirection après confirmation', 'label' => 'Validité du lien',
'selected' => $this->getData(['module',$this->getUrl(0),'config','pageSuccess']) 'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'timeOut']) / 60
]); ?> ]); ?>
</div> </div>
<div class="col6"> <div class="col6">
<?php echo template::select('registrationConfigError', helper::arraycollumn($this->getData(['page']), 'title', 'SORT_ASC'), [ <?php echo template::text('registrationConfigFilter', [
'label' => 'Redirection après erreur', 'label' => 'Domaines acceptés',
'selected' => $this->getData(['module',$this->getUrl(0),'config','pageError']) 'value' => $this->getData(['module', $this->getUrl(0), 'config', 'filter']),
]); ?> 'help' => 'Champ vide sinon limitation à des domaines spécifiques, le séparateur est ;'
]); ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<?php $messageDefault = '<p>Confirmez votre inscription en cliquant sur ce lien dans les ... minutes.</p>'; ?> <?php $messageDefault = '<p>Confirmez votre inscription en cliquant sur ce lien dans les ... minutes.</p>'; ?>
<?php echo template::textarea('registrationconfigMailRegisterContent', [ <?php echo template::textarea('registrationconfigMailRegisterContent', [
'label' => 'Corps du mail de confirmation', 'label' => 'Corps du mail de confirmation',
'value' => !empty($this->getData(['module',$this->getUrl(0),'config','mailRegisterContent'])) ? $this->getData(['module',$this->getUrl(0),'config','mailRegisterContent']) : $messageDefault, 'value' => !empty($this->getData(['module', $this->getUrl(0), 'config', 'mailRegisterContent'])) ? $this->getData(['module', $this->getUrl(0), 'config', 'mailRegisterContent']) : $messageDefault,
'class' => 'editorWysiwyg', 'class' => 'editorWysiwyg',
'help' => 'Précisez la durée de validité. Le lien sera inséré après ces explications.' 'help' => 'Précisez la durée de validité. Le lien sera inséré après ces explications.'
]); ?> ]); ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col6 verticalAlignMiddle"> <div class="col6 verticalAlignMiddle">
<?php echo template::checkbox('registrationConfigState', true, 'Approbation préalable', [ <?php echo template::checkbox('registrationConfigState', true, 'Approbation préalable', [
'checked' => $this->getData(['module',$this->getUrl(0),'config','approval']), 'checked' => $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.', 'help' => 'Les comptes sont inactifs tant que les inscriptions ne sont pas approuvées par un administrateur.',
'check' => true 'check' => true
]); ?> ]); ?>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<?php $messageDefault = '<p>Votre inscription a été approuvée par un administrateur.</p>'; ?> <?php $messageDefault = '<p>Votre inscription a été approuvée par un administrateur.</p>'; ?>
<?php echo template::textarea('registrationconfigMailValidateContent', [ <?php echo template::textarea('registrationconfigMailValidateContent', [
'label' => 'Corps du mail d\'approbation', 'label' => 'Corps du mail d\'approbation',
'value' =>!empty($this->getData(['module',$this->getUrl(0),'config','mailValidateContent'])) ? $this->getData(['module',$this->getUrl(0),'config','mailValidateContent']) : $messageDefault, 'value' => !empty($this->getData(['module', $this->getUrl(0), 'config', 'mailValidateContent'])) ? $this->getData(['module', $this->getUrl(0), 'config', 'mailValidateContent']) : $messageDefault,
'class' => 'editorWysiwyg' 'class' => 'editorWysiwyg'
]); ?> ]); ?>
</div> </div>
</div> </div>
</div> </div>

View File

@ -15,3 +15,7 @@
/** NE PAS EFFACER /** NE PAS EFFACER
* admin.css * admin.css
*/ */
#registrationUserEditProfil1Wrapper,
#registrationUserEditProfil2Wrapper {
padding: 0;
}

View File

@ -13,7 +13,19 @@
/** /**
* Droits des groupes * Droits des groupes
*/ */
$("#registrationUserEditGroup").on("change", function() {
$(".registrationUserEditGroupDescription").hide();
$("#registrationUserEditGroupDescription" + $(this).val()).show(); $(document).ready(function () {
}).trigger("change"); $(".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();
});
});

View File

@ -1,111 +1,135 @@
<?php echo template::formOpen('registrationUserEditForm'); ?> <?php echo template::formOpen('registrationUserEditForm'); ?>
<div class="row"> <div class="row">
<div class="col2"> <div class="col1">
<?php if($this->getUrl(3)): ?> <?php echo template::button('registrationUserEditBack', [
<?php echo template::button('registrationUserEditBack', [ 'class' => 'buttonGrey',
'class' => '', 'href' => helper::baseUrl() . $this->geturl(0) . '/users',
'href' => helper::baseUrl() . $this->geturl(0) . '/user', 'value' => template::ico('left')
'ico' => 'left', ]); ?>
'value' => 'Retour'
]); ?>
<?php else: ?>
<?php echo template::button('registrationUserEditBack', [
'class' => '',
'href' => helper::baseUrl(false),
'ico' => 'home',
'value' => 'Accueil'
]); ?>
<?php endif; ?>
</div>
<div class="col2 offset8">
<?php echo template::submit('registrationUserEditSubmit',[
'class' => 'green'
]); ?>
</div>
</div> </div>
<div class="row"> <div class="col2 offset9">
<div class="col12"> <?php echo template::submit('registrationUserEditSubmit', [
<div class="block"> 'class' => 'green'
<h4>Confirmation de l'inscription</h4> ]); ?>
<div class="row"> </div>
<div class="col6"> </div>
<div class="row"> <div class="row">
<div class="col6"> <div class="col12">
<?php echo template::text('registrationUserEditFirstname', [ <div class="block">
'autocomplete' => 'off', <h4>Confirmation de l'inscription</h4>
'label' => 'Prénom', <div class="row">
'value' => $this->getData(['user', $this->getUrl(2), 'firstname']), <div class="col12">
'disabled'=> true <div class="row">
]); ?> <div class="col6">
</div> <?php echo template::text('registrationUserEditFirstname', [
<div class="col6"> 'autocomplete' => 'off',
<?php echo template::text('registrationUserEditLastname', [ 'label' => 'Prénom',
'autocomplete' => 'off', 'value' => $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'firstname']),
'label' => 'Nom', 'disabled' => true
'value' => $this->getData(['user', $this->getUrl(2), 'lastname']), ]); ?>
'disabled'=> true
]); ?>
</div>
</div> </div>
<div class="row"> <div class="col6">
<div class="col12"> <?php echo template::text('registrationUserEditLastname', [
<?php echo template::mail('registrationUserEditMail', [ 'autocomplete' => 'off',
'autocomplete' => 'off', 'label' => 'Nom',
'label' => 'Adresse électronique', 'value' => $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'lastname']),
'value' => $this->getData(['user', $this->getUrl(2), 'mail']), 'disabled' => true
'disabled'=> true ]); ?>
]); ?>
</div>
</div>
<div class="row">
<div class="col6">
<?php $status = $module::$statusGroups[$this->getData(['user', $this->getUrl(2), 'group'])];?>
<?php echo template::text('resgistrationUserState', [
'label' => 'État de l\'inscription',
'value' => $status,
'disabled'=> true,
'help' => 'En attente : le mail n\'a pas encore été validé<br>Email validé : approbation nécessaire.'
]); ?>
</div>
<div class="col6">
<?php echo template::text('resgistrationUsertimer', [
'label' => 'Date',
'value' => helper::dateUTF8(date('Y-m-d G:i'), $this->getData(['user', $userId, 'timer'])),
'disabled'=> true
]); ?>
</div>
</div> </div>
</div> </div>
<div class="row">
<div class="col6"> <div class="col12">
<?php if($this->getUser('group') === self::GROUP_ADMIN): ?> <?php echo template::mail('registrationUserEditMail', [
<?php echo template::select('registrationUserEditGroup', self::$groupEdits, [ 'autocomplete' => 'off',
'disabled' => ($this->getUrl(2) === $this->getUser('id')), 'label' => 'Adresse électronique',
'help' => ($this->getUrl(2) === $this->getUser('id') ? 'Impossible de modifier votre propre groupe.' : ''), 'value' => $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'mail']),
'label' => 'Groupe <em>(Banni : en attente d\'approbation)</em>', 'disabled' => true
'selected' => $this->getData(['user', $this->getUrl(2), 'group'])
]); ?> ]); ?>
Autorisations : </div>
<ul id="registrationUserEditGroupDescription<?php echo self::GROUP_MEMBER; ?>" class="registrationUserEditGroupDescription displayNone"> </div>
<li>Accès aux pages privées membres</li> <div class="row">
</ul> <div class="col8">
<ul id="registrationUserEditGroupDescription<?php echo self::GROUP_EDITOR; ?>" class="registrationUserEditGroupDescription displayNone"> <?php echo template::text('registrationUserState', [
<li>Accès aux pages privées membres et éditeurs</li> 'label' => 'État de l\'inscription',
<li>Ajout - Édition - Suppression de pages</li> 'value' => $module::$statusGroups[$this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'status'])],
<li>Ajout - Édition - Suppression de fichiers</li> 'disabled' => true,
</ul> 'help' => 'En attente : le mail n\'a pas encore été validé<br>Email validé : approbation nécessaire.'
<ul id="registrationUserEditGroupDescription<?php echo self::GROUP_ADMIN; ?>" class="registrationUserEditGroupDescription displayNone"> ]); ?>
<li>Accès à toutes les pages privées</li> </div>
<li>Ajout - Édition - Suppression de pages</li> <div class="col4">
<li>Ajout - Édition - Suppression de fichiers</li> <?php echo template::text('registrationUsertimer', [
<li>Ajout / Édition / Suppression d'utilisateurs</li> 'label' => 'Date de demande',
<li>Configuration du site</li> 'value' => helper::dateUTF8(date('Y-m-d G:i'), $this->getData(['module', $this->getUrl(0), 'users', $this->getUrl(2), 'timer'])),
<li>Personnalisation du thème</li> 'disabled' => true
</ul> ]); ?>
<?php endif; ?> </div>
</div>
</div>
</div>
<div class="row">
<div class="col6">
<?php if ($this->getUser('group') === self::GROUP_ADMIN): ?>
<?php echo template::select('registrationUserEditGroup', $module::$groups, [
'disabled' => ($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'])
]); ?>
<?php endif; ?>
</div>
<div class="col6">
<div class="registrationUserEditGroupProfil"
id="registrationUserEditGroupProfil<?php echo self::GROUP_MEMBER; ?>">
<?php echo template::select('registrationUserEditProfil' . self::GROUP_MEMBER, $module::$userProfils[self::GROUP_MEMBER], [
'label' => 'Profil',
'selected' => $this->getData(['user', $this->getUrl(2), 'profil']),
'disabled' => $this->getUser('group') !== self::GROUP_ADMIN,
]); ?>
</div>
<div class="registrationUserEditGroupProfil"
id="registrationUserEditGroupProfil<?php echo self::GROUP_EDITOR; ?>">
<?php echo template::select('registrationUserEditProfil' . self::GROUP_EDITOR, $module::$userProfils[self::GROUP_EDITOR], [
'label' => 'Profil',
'selected' => $this->getData(['user', $this->getUrl(2), 'profil']),
'disabled' => $this->getUser('group') !== self::GROUP_ADMIN,
]); ?>
</div>
</div>
<div class="row">
<div class="col12">
<div id="registrationUserCommentProfil<?php echo self::GROUP_MEMBER; ?>"
class="col12 registrationUserCommentProfil">
<?php echo template::textarea('registrationUserEditProfilComment' . self::GROUP_MEMBER, [
'label' => 'Commentaire',
'value' => implode("\n", $module::$userProfilsComments[self::GROUP_MEMBER]),
'readonly' => true,
]);
?>
</div>
<div id="registrationUserCommentProfil<?php echo self::GROUP_EDITOR; ?>"
class="col12 registrationUserCommentProfil">
<?php echo template::textarea('registrationUserEditProfilComment' . self::GROUP_EDITOR, [
'label' => 'Commentaire',
'value' => implode("\n", $module::$userProfilsComments[self::GROUP_EDITOR]),
'readonly' => true,
]);
?>
</div>
<div id="registrationUserCommentProfil<?php echo self::GROUP_ADMIN; ?>"
class="col12 registrationUserCommentProfil">
<?php echo template::textarea('registrationUserEditProfilComment' . self::GROUP_ADMIN, [
'label' => 'Commentaire',
'value' => implode("\n", $module::$userProfilsComments[self::GROUP_ADMIN]),
'readonly' => true,
]);
?>
</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div>
<?php echo template::formClose(); ?> <?php echo template::formClose(); ?>

View File

@ -0,0 +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 <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-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 */
}

View File

@ -1,5 +1,5 @@
<?php echo template::formOpen('registrationAddForm'); ?> <?php echo template::formOpen('registrationAddForm'); ?>
<div class='inputContainer'> <div class="<?php echo $this->getData(['module', $this->getUrl(0), 'config', 'layout']); ?>">
<?php echo template::text('registrationAddFirstname', [ <?php echo template::text('registrationAddFirstname', [
'autocomplete' => 'off', 'autocomplete' => 'off',
'label' => 'Prénom' 'label' => 'Prénom'
@ -8,30 +8,22 @@
'autocomplete' => 'off', 'autocomplete' => 'off',
'label' => 'Nom' 'label' => 'Nom'
]); ?> ]); ?>
<?php echo template::mail('registrationAddMail', [
'autocomplete' => 'off',
'label' => 'Adresse électronique'
]); ?>
<?php echo template::text('registrationAddId', [ <?php echo template::text('registrationAddId', [
'autocomplete' => 'off', 'autocomplete' => 'off',
'label' => 'Identifiant de connexion' 'label' => 'Identifiant de connexion'
]); ?> ]); ?>
<?php echo template::password('registrationAddPassword', [ <?php echo template::mail('registrationAddMail', [
'autocomplete' => 'off', 'autocomplete' => 'off',
'label' => 'Mot de passe' 'label' => 'Adresse électronique'
]); ?> ]); ?>
<?php echo template::password('registrationAddConfirmPassword', [
'autocomplete' => 'off',
'label' => 'Confirmation du mot de passe'
]);
?>
</div> </div>
<div class="row"> <div class='submitContainer'>
<div class="col2 offset10"> <div class="row">
<?php echo template::submit('registrationAddSubmit', [ <div class="col2 offset10">
'value' => 'Envoyer', <?php echo template::submit('registrationAddSubmit', [
'class' => 'green' 'value' => 'Envoyer'
]); ?> ]); ?>
</div>
</div> </div>
</div> </div>
<?php echo template::formClose(); ?> <?php echo template::formClose(); ?>

View File

@ -1,9 +1,9 @@
<div class="row"> <div class="row">
<div class="col2"> <div class="col1">
<?php echo template::button('registrationUserBack', [ <?php echo template::button('registrationUserBack', [
'class' => '', 'class' => 'buttonGrey',
'href' => helper::baseUrl() . $this->getUrl(0) . '/config', 'href' => helper::baseUrl() . $this->getUrl(0) . '/config',
'value' => 'Retour' 'value' => template::ico('left')
]); ?> ]); ?>
</div> </div>
</div> </div>

View File

@ -0,0 +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 <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-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);
}

View File

@ -1,2 +1,23 @@
<?php <?php echo template::formOpen('registrationValidForm'); ?>
// Page vide <h3>Email confirmé</h3>
<div class="<?php echo $this->getData(['module',$this->getUrl(0),'config','layout']); ?>">
<?php echo template::password('registrationValidPassword', [
'autocomplete' => 'off',
'label' => 'Mot de passe'
]); ?>
<?php echo template::password('registrationValidConfirmPassword', [
'autocomplete' => 'off',
'label' => 'Confirmation du mot de passe'
]); ?>
</div>
<div class='submitContainer'>
<div class="row">
<div class="col2 offset10">
<?php echo template::submit('registrationValidSubmit', [
'value' => 'Envoyer',
'class' => 'green'
]); ?>
</div>
</div>
</div>
<?php echo template::formClose(); ?>