- ... - Lire la suite -
-Cet item ne reçoit pas de commentaire.
- -' . $this->getdata(['module','registration',$this->getUrl(0),'config','mailValidateContent']) . '
' - - ); - } - // Valeurs en sortie - $this->addOutput([ - 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/user', - 'notification' => 'Modifications enregistrées', - 'state' => true - ]); - } - // Valeurs en sortie - $this->addOutput([ - 'title' => $this->getData(['user', $this->getUrl(2), 'firstname']) . ' ' . $this->getData(['user', $this->getUrl(2), 'lastname']), - 'view' => 'edit' - ]); - } - } - - - /** - * Suppression - */ - public function delete() { - // Accès refusé - if( - // L'utilisateur n'existe pas - $this->getData(['user', $this->getUrl(2)]) === null - // Groupe insuffisant - AND ($this->getUrl('group') < self::GROUP_MODERATOR) - ) { - // Valeurs en sortie - $this->addOutput([ - 'access' => false - ]); - } - // Jeton incorrect - elseif ($this->getUrl(3) !== $_SESSION['csrf']) { - // Valeurs en sortie - $this->addOutput([ - 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/user', - 'notification' => 'Action non autorisée' - ]); - } - // Bloque la suppression de son propre compte - elseif($this->getUser('id') === $this->getUrl(2)) { - // Valeurs en sortie - $this->addOutput([ - 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/user', - 'notification' => 'Impossible de supprimer votre propre compte' - ]); - } - // Suppression - else { - $this->deleteData(['user', $this->getUrl(2)]); - // Valeurs en sortie - $this->addOutput([ - 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/user', - 'notification' => 'Utilisateur supprimé', - 'state' => true - ]); - } - } - - - /** - * Ajout - */ - public function index() { - // Soumission du formulaire - if($this->isPost()) { - $check=true; - // L'identifiant d'utilisateur est indisponible - $userId = $this->getInput('registrationAddId', helper::FILTER_ID, true); - if($this->getData(['module','registration', $userId])) { - self::$inputNotices['registrationAddId'] = 'Identifiant déjà utilisé'; - $check=false; - } - // Double vérification pour le mot de passe - if($this->getInput('registrationAddPassword', helper::FILTER_STRING_SHORT, true) !== $this->getInput('registrationAddConfirmPassword', helper::FILTER_STRING_SHORT, true)) { - self::$inputNotices['registrationAddConfirmPassword'] = 'Incorrect'; - $check = false; - } - // Le mail existe déjà - foreach($this->getData(['user']) as $usersId => $user) { - if($user['mail'] === $this->getInput('registrationAddMail', helper::FILTER_MAIL, true) ) { - self::$inputNotices['registrationAddMail'] = 'Mail déjà utilisé'; - $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); - $userTimer = $this->getInput('registrationAddTimer', helper::FILTER_INT, true); - // Pas de nom saisi - if (empty($userFirstname) || - empty($userLastname) || - empty($this->getInput('registrationAddPassword', helper::FILTER_STRING_SHORT, true)) || - empty($this->getInput('registrationAddConfirmPassword', helper::FILTER_STRING_SHORT, true))) { - $check=false; - } - // Si tout est ok - if ($check === true) { - // création effective temporaire - $this->setData([ - 'user', - $userId, - [ - 'firstname' => $userFirstname, - 'lastname' => $userLastname, - 'mail' => $userMail, - 'password' => $this->getInput('registrationAddPassword', helper::FILTER_PASSWORD, true), - // pas de groupe afin de le différencier dans la liste des users - 'group' => null, - 'forgot' => 0, - 'timer' => $userTimer, - 'auth' => $_SESSION['csrf'], - 'status' => self::STATUS_AWAITING - ] - ]); - // Mail d'avertissement aux administrateurs - // Utilisateurs dans le groupe admin - $to = []; - foreach($this->getData(['user']) as $userId => $user) { - if($user['group'] == self::GROUP_ADMIN) { - $to[] = $user['mail']; - } - } - // Envoi du mail - if($to) { - $messageAdmin = $this->getdata(['module','registration',$this->getUrl(0),'config','state']) ? 'Une demande d\'inscription attend l`approbation d\'un administrateur.' : 'Un nouveau membre s\'est inscrit.'; - // Envoi le mail - $this->sendMail( - $to, - 'Auto-inscription sur le site ' . $this->getData(['config', 'title']), - '' . $messageAdmin . '
' . - 'Identifiant du compte : ' . $userId .' (' . $userFirstname . ' ' . $userLastname . ')
' .
- 'Email : ' . $userMail . '
' . $this->getdata(['module','registration',$this->getUrl(0),'config','mailRegisterContent']) . '
' . - 'Activer votre compte' - ); - } - } - // Valeurs en sortie - $this->addOutput([ - 'redirect' => helper::baseUrl(), - //'redirect' => $validateLink, - 'notification' => $sentMailtoUser ? "Consultez votre messagerie, 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() { - // Vérifie la session + l'id + le timer - $check = true; - $notification = 'Bienvenue sur le site' . $this->getData(['config', 'title']) ; - $csrf = $this->getUrl(3); - $userId = $this->getUrl(2); - // Validité - if ( time() - $this->getData(['user',$userId,'timer']) <= (60 * $this->getdata(['module','registration',$this->getUrl(0),'config','pageTimeOut'])) ) { - $check = false; - $notification = 'Le lien n\'est plus valide'; - } - if (( $csrf !== $this->getData(['user',$userId,'auth']) ) ) { - $check = false; - $notification = 'Identifiant ou mot de passe inconnu'; - } - if ($check) { - $this->setData([ - 'user', - $userId, - [ - 'firstname' => $this->getData(['user',$userId,'firstname']), - 'lastname' => $this->getData(['user',$userId,'lastname']), - 'mail' => $this->getData(['user',$userId,'mail']), - 'password' => $this->getData(['user',$userId,'password']), - 'group' => $this->getdata(['module','registration',$this->getUrl(0),'config','state']) === true ? self::STATUS_VALIDATED : self::GROUP_MEMBER, - 'forgot' => 0, - 'timer' => $this->getData(['user',$userId,'timer']) - ] - ]); - } - // Valeurs en sortie - $this->addOutput([ - 'redirect' => $check ? helper::baseUrl() . $this->getdata(['module','registration',$this->getUrl(0),'config','pageSuccess']) : helper::baseUrl() . $this->getdata(['module','registration',$this->getUrl(0),'config','pageError']) , - 'notificaton' => $notification, - 'state' => $check - ]); - } - - /** - * Module de configuration - */ - public function config() { - // Soumission du formulaire - if($this->isPost()) { - // Lire les options et les enregistrer - $this->setData(['module','registration',$this->getUrl(0),'config', [ - 'timeOut' => $this->getInput('registrationConfigTimeOut',helper::FILTER_INT), - 'pageSuccess' => $this->getInput('registrationConfigSuccess'), - 'pageError' => $this->getInput('registrationConfigError'), - 'state' => $this->getInput('registrationConfigState',helper::FILTER_BOOLEAN), - 'mailRegisterContent' => $this->getInput('registrationconfigMailRegisterContent', null, true), - 'mailValidateContent' => $this->getInput('registrationconfigMailValidateContent', null, true), - ]]); - $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/registration/view/config/config.css b/module/registration/view/config/config.css deleted file mode 100644 index 9774521b..00000000 --- a/module/registration/view/config/config.css +++ /dev/null @@ -1,15 +0,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