diff --git a/module/form/form.php b/module/form/form.php index 6a67b968..2b23efb2 100755 --- a/module/form/form.php +++ b/module/form/form.php @@ -48,10 +48,20 @@ class form extends common { self::TYPE_CHECKBOX => 'Case à cocher' ]; + public static $listUsers = [ + ]; + /** * Configuration */ public function config() { + // Liste des utilisateurs + $userIdsFirstnames = helper::arrayCollumn($this->getData(['user']), 'firstname'); + ksort($userIdsFirstnames); + self::$listUsers [] = ''; + foreach($userIdsFirstnames as $userId => $userFirstname) { + self::$listUsers [] = $this->getData(['user', $userId, 'mail']); + } // Soumission du formulaire if($this->isPost()) { // Configuration @@ -63,6 +73,8 @@ class form extends common { 'button' => $this->getInput('formConfigButton'), 'capcha' => $this->getInput('formConfigCapcha', helper::FILTER_BOOLEAN), 'group' => $this->getInput('formConfigGroup', helper::FILTER_INT), + 'user' => self::$listUsers [$this->getInput('formConfigUser', helper::FILTER_INT)], + 'mail' => $this->getInput('formConfigMail', helper::FILTER_MAIL), 'pageId' => $this->getInput('formConfigPageId', helper::FILTER_ID), 'subject' => $this->getInput('formConfigSubject') ] @@ -296,9 +308,13 @@ class form extends common { $this->setData(['module', $this->getUrl(0), 'data', helper::increment(1, $this->getData(['module', $this->getUrl(0), 'data'])), $data]); // Envoi du mail $sent = true; + $singleuser = $this->getData(['module', $this->getUrl(0), 'config', 'user']); + $singlemail = $this->getData(['module', $this->getUrl(0), 'config', 'mail']); if( self::$inputNotices === [] AND $group = $this->getData(['module', $this->getUrl(0), 'config', 'group']) + OR $singleuser !== '' + OR $singlemail !== '' ) { // Utilisateurs dans le groupe $to = []; @@ -307,6 +323,15 @@ class form extends common { $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']); diff --git a/module/form/view/config/config.js.php b/module/form/view/config/config.js.php index 6213d01e..41a9fbbb 100755 --- a/module/form/view/config/config.js.php +++ b/module/form/view/config/config.js.php @@ -142,6 +142,8 @@ $("#formConfigMailOptionsToggle").on("change", function() { $("#formConfigMailOptions").slideUp(function() { $("#formConfigGroup").val(""); $("#formConfigSubject").val(""); + $("#formConfigMail").val(""); + $("#formConfigUser").val(""); }); } }).trigger("change"); diff --git a/module/form/view/config/config.php b/module/form/view/config/config.php index 14e85340..ab3d368d 100755 --- a/module/form/view/config/config.php +++ b/module/form/view/config/config.php @@ -72,34 +72,63 @@ 'label' => 'Texte du bouton de soumission', 'value' => $this->getData(['module', $this->getUrl(0), 'config', 'button']) ]); ?> - (bool) $this->getData(['module', $this->getUrl(0), 'config', 'group']) - ]); ?> + (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' + ]); ?>
-
- 'Groupe', - 'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'group']) - ]); ?> -
-
+
'Laissez vide afin de conserver le texte par défaut.', 'label' => 'Sujet du mail', 'value' => $this->getData(['module', $this->getUrl(0), 'config', 'subject']) ]); ?>
+
+ + Destinataires : +
+
+ 'Un groupe de membres :', + 'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'group']) + ]); ?> +
+
+
+
+ 'Un membre :', + 'selected' => array_search($this->getData(['module', $this->getUrl(0), 'config', 'user']),$module::$listUsers) + ]); ?> +
+
+
+
+ 'Un eMail :', + 'value' => $this->getData(['module', $this->getUrl(0), 'config', 'mail']), + 'help' => 'Saisissez une adresse mail individuelle ou de liste' + ]); ?> +
- (bool) $this->getData(['module', $this->getUrl(0), 'config', 'pageId']) ]); ?> - 'displayNone', - 'label' => 'Page', - 'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'pageId']) - ]); ?> +
+ 'displayNone', + 'label' => 'Sélectionner une page du site :', + 'selected' => $this->getData(['module', $this->getUrl(0), 'config', 'pageId']) + ]); ?> +
$this->getData(['module', $this->getUrl(0), 'config', 'capcha']) ]); ?>