Cet item ne reçoit pas de commentaire.
- -- - - - 0 ? $commentsNb . ' ' . 'commentaire' . $s : 'Pas encore de commentaire'; ?> -
- - 'Rédiger un commentaire...', - 'readonly' => true - ]); ?> -- le - -
Cet item ne reçoit pas de commentaire.
+ ++ + + + 0 ? $commentsNb . ' ' . 'commentaire' . $s : 'Pas encore de commentaire'; ?> +
+ + 'Rédiger un commentaire...', + 'readonly' => true + ]); ?> ++ le + +
' . $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 new file mode 100644 index 00000000..9774521b --- /dev/null +++ b/module/registration/view/config/config.css @@ -0,0 +1,15 @@ +/** + * 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 JeanParamètres
+Approbation préalable
+Confirmation de l'inscription
+Email validé : approbation nécessaire.' + ]); ?> +
-
+
- Accès aux pages privées membres +
-
+
- Accès aux pages privées membres et éditeurs +
- Ajout / Édition / Suppression de pages +
- Ajout / Édition / Suppression de fichiers +
-
+
- Accès à toutes les pages privées +
- Ajout / Édition / Suppression de pages +
- Ajout / Édition / Suppression de fichiers +
- Ajout / Édition / Suppression d'utilisateurs +
- Configuration du site +
- Personnalisation du thème +
Identité
+Données de connexion
+'; + } + self::$data[] = [ + $content, + template::button('formDataDelete' . $dataIds[$i], [ + 'class' => 'formDataDelete buttonRed', + 'href' => helper::baseUrl() . $this->getUrl(0) . '/delete/' . $dataIds[$i] . '/' . $_SESSION['csrf'], + 'value' => template::ico('cancel') + ]) + ]; + } + } + // Valeurs en sortie + $this->addOutput([ + 'title' => 'Données enregistrées', + 'view' => 'data' + ]); + } + + /** + * Réponses enregistrées + */ + public function result() { + $data = $this->getData(['module', $this->getUrl(0), 'data']); + if($data) { + // Pagination + $pagination = helper::pagination($data, $this->getUrl(),$this->getData(['config','itemsperPage'])); + // Liste des pages + self::$pagination = $pagination['pages']; + // Inverse l'ordre du tableau + $dataIds = array_reverse(array_keys($data)); + $data = array_reverse($data); + // Données en fonction de la pagination + for($i = $pagination['first']; $i < $pagination['last']; $i++) { + $content = ''; + foreach($data[$i] as $input => $value) { + $content .= $input . ' : ' . $value . '
'; + } + self::$data[] = [ + $content + ]; + } + } + // Valeurs en sortie + $this->addOutput([ + 'title' => 'Réponses', + 'view' => 'result' + ]); + } + + /** + * Export CSV + * @author Frédéric Tempez
sous le nom '.$csvfilename, + 'redirect' => helper::baseUrl() . $this->getUrl(0) .'/data', + 'state' => true + ]); + } else { + $this->addOutput([ + 'notification' => 'Aucune donnée à exporter', + 'redirect' => helper::baseUrl() . $this->getUrl(0) .'/data' + ]); + } + } + } + + + /** + * Suppression + */ + public function deleteall() { + // Jeton incorrect + if ($this->getUrl(2) !== $_SESSION['csrf']) { + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/data', + 'notification' => 'Action non autorisée' + ]); + } else { + $data = ($this->getData(['module', $this->getUrl(0), 'data'])); + if (count($data) > 0 ) { + // Suppression multiple + for ($i = 1; $i <= count($data) ; $i++) { + echo $this->deleteData(['module', $this->getUrl(0), 'data', $i]); + } + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/data', + 'notification' => 'Données supprimées', + 'state' => true + ]); + } else { + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/data', + 'notification' => 'Aucune donnée à supprimer' + ]); + } + } + } + + + /** + * Suppression + */ + public function delete() { + // Jeton incorrect + if ($this->getUrl(3) !== $_SESSION['csrf']) { + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/data', + 'notification' => 'Action non autorisée' + ]); + } else { + // La donnée n'existe pas + if($this->getData(['module', $this->getUrl(0), 'data', $this->getUrl(2)]) === null) { + // Valeurs en sortie + $this->addOutput([ + 'access' => false + ]); + } + // Suppression + else { + $this->deleteData(['module', $this->getUrl(0), 'data', $this->getUrl(2)]); + // Valeurs en sortie + $this->addOutput([ + 'redirect' => helper::baseUrl() . $this->getUrl(0) . '/data', + 'notification' => 'Donnée supprimée', + 'state' => true + ]); + } + } + } + + + + + /** + * Accueil + */ + public function index() { + // Soumission du formulaire + if($this->isPost()) { + // Check la capcha + if( + $this->getData(['module', $this->getUrl(0), 'config', 'capcha']) + AND $this->getInput('formCapcha', helper::FILTER_INT) !== $this->getInput('formCapchaFirstNumber', helper::FILTER_INT) + $this->getInput('formCapchaSecondNumber', helper::FILTER_INT)) + { + self::$inputNotices['formCapcha'] = 'Incorrect'; + + } + // Préparation le contenu du mail + $data = []; + $content = ''; + foreach($this->getData(['module', $this->getUrl(0), 'input']) as $index => $input) { + // Filtre la valeur + switch($input['type']) { + case self::TYPE_MAIL: + $filter = helper::FILTER_MAIL; + break; + case self::TYPE_TEXTAREA: + $filter = helper::FILTER_STRING_LONG; + break; + case self::TYPE_DATETIME: + $filter = helper::FILTER_STRING_SHORT; // Mettre TYPE_DATETIME pour récupérer un TIMESTAMP + break; + CASE self::TYPE_CHECKBOX: + $filter = helper::FILTER_BOOLEAN; + break; + default: + $filter = helper::FILTER_STRING_SHORT; + } + $value = $this->getInput('formInput[' . $index . ']', $filter, $input['required']); + // Préparation des données pour la création dans la base + $data[$this->getData(['module', $this->getUrl(0), 'input', $index, 'name'])] = $value; + // Préparation des données pour le mail + $content .= '' . $this->getData(['module', $this->getUrl(0), 'input', $index, 'name']) . ' : ' . $value . '
'; + } + // Crée les données + $this->setData(['module', $this->getUrl(0), 'data', helper::increment(1, $this->getData(['module', $this->getUrl(0), 'data'])), $data]); + // Envoi du mail + // Rechercher l'adresse en fonction du mail + $sent = true; + $singleuser = $this->getData(['user', + $this->getData(['module', $this->getUrl(0), 'config', 'user']), + 'mail']); + $singlemail = $this->getData(['module', $this->getUrl(0), 'config', 'mail']); + $group = $this->getData(['module', $this->getUrl(0), 'config', 'group']); + // Verification si le mail peut être envoyé + if( + self::$inputNotices === [] && ( + $group > 0 || + $singleuser !== '' || + $singlemail !== '' ) + ) { + // Utilisateurs dans le groupe + $to = []; + if ($group > 0){ + foreach($this->getData(['user']) as $userId => $user) { + if($user['group'] >= $group) { + $to[] = $user['mail']; + } + } + } + // Utilisateur désigné + if (!empty($singleuser)) { + $to[] = $singleuser; + } + // Mail désigné + if (!empty($singlemail)) { + $to[] = $singlemail; + } + if($to) { + // Sujet du mail + $subject = $this->getData(['module', $this->getUrl(0), 'config', 'subject']); + if($subject === '') { + $subject = 'Nouveau message en provenance de votre site'; + } + // Envoi le mail + $sent = $this->sendMail( + $to, + $subject, + 'Nouveau message en provenance de la page "' . $this->getData(['page', $this->getUrl(0), 'title']) . '" :
' . + $content + ); + } + } + // Redirection + $redirect = $this->getData(['module', $this->getUrl(0), 'config', 'pageId']); + // Valeurs en sortie + $this->addOutput([ + 'notification' => ($sent === true ? 'Formulaire soumis' : $sent), + 'redirect' => $redirect ? helper::baseUrl() . $redirect : '', + 'state' => ($sent === true ? true : null) + ]); + } + // Valeurs en sortie + $this->addOutput([ + 'showBarEditButton' => true, + 'showPageContent' => true, + 'view' => 'index', + 'vendor' => [ + 'flatpickr' + ], + ]); + } +} \ No newline at end of file diff --git a/module/sondage/vendor/html-sortable/html-sortable.min.js b/module/sondage/vendor/html-sortable/html-sortable.min.js new file mode 100644 index 00000000..9a96985e --- /dev/null +++ b/module/sondage/vendor/html-sortable/html-sortable.min.js @@ -0,0 +1 @@ +!function(e,t){"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?module.exports=t():e.sortable=t()}(this,function(){"use strict";function e(e,t,n){var r=null;return 0===t?e:function(){var a=n||this,o=arguments;clearTimeout(r),r=setTimeout(function(){e.apply(a,o)},t)}}var t,n,r,a=[],o=[],i=function(e,t,n){return void 0===n?e&&e.h5s&&e.h5s.data&&e.h5s.data[t]:(e.h5s=e.h5s||{},e.h5s.data=e.h5s.data||{},e.h5s.data[t]=n,void 0)},s=function(e){e.h5s&&delete e.h5s.data};switch(!0){case"matches"in window.Element.prototype:r="matches";break;case"mozMatchesSelector"in window.Element.prototype:r="mozMatchesSelector";break;case"msMatchesSelector"in window.Element.prototype:r="msMatchesSelector";break;case"webkitMatchesSelector"in window.Element.prototype:r="webkitMatchesSelector"}var l=function(e,t){if(!t)return Array.prototype.slice.call(e);for(var n=[],a=0;a
Configuration
+ 'Laissez vide afin de conserver le texte par défaut.', + 'label' => 'Texte du bouton de soumission', + 'value' => $this->getData(['module', $this->getUrl(0), 'config', 'button']) + ]); ?> + (bool) $this->getData(['module', $this->getUrl(0), 'config', 'group']) || + !empty($this->getData(['module', $this->getUrl(0), 'config', 'user'])) || + !empty($this->getData(['module', $this->getUrl(0), 'config', 'mail'])), + 'help' => 'Sélectionnez au moins un groupe, un utilisateur ou saississez un email.' + ]); ?> +Membres = membres + éditeurs + administrateurs' + ]); ?> +