From 2f9f61c5a3b952f132dc41f50997ffb88bca7564 Mon Sep 17 00:00:00 2001 From: fredtempez Date: Sat, 19 Oct 2019 19:57:49 +0200 Subject: [PATCH] =?UTF-8?q?[10.0.37.dev]=20emp=C3=AAche=20l'envoi=20d'un?= =?UTF-8?q?=20mail=20si=20captcha=20incorrect?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/core.php | 2 +- module/form/form.php | 94 ++++++++++++++++++++++---------------------- 2 files changed, 49 insertions(+), 47 deletions(-) diff --git a/core/core.php b/core/core.php index 53236eaa..f63137e8 100644 --- a/core/core.php +++ b/core/core.php @@ -31,7 +31,7 @@ class common { const TEMP_DIR = 'site/tmp/'; // Numéro de version - const ZWII_VERSION = '10.0.36.dev'; + const ZWII_VERSION = '10.0.37.dev'; public static $actions = []; public static $coreModuleIds = [ diff --git a/module/form/form.php b/module/form/form.php index 794ad019..70e5410c 100644 --- a/module/form/form.php +++ b/module/form/form.php @@ -293,6 +293,7 @@ class form extends common { // Préparation le contenu du mail $data = []; $content = ''; + $sent = false; foreach($this->getData(['module', $this->getUrl(0), 'input']) as $index => $input) { // Filtre la valeur switch($input['type']) { @@ -318,55 +319,56 @@ class form extends common { $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]); + $success = $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']; + if ($success === true) { + // Rechercher l'adresse en fonction du mail + $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'; + } + // phpMailer + require_once "core/vendor/phpmailer/phpmailer.php"; + require_once "core/vendor/phpmailer/exception.php"; + // Envoi le mail + $sent = $this->sendMail( + $to, + $subject, + 'Nouveau message en provenance de la page "' . $this->getData(['page', $this->getUrl(0), 'title']) . '" :

' . + $content + ); } - } - // 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'; - } - // phpMailer - require_once "core/vendor/phpmailer/phpmailer.php"; - require_once "core/vendor/phpmailer/exception.php"; - // Envoi le mail - $sent = $this->sendMail( - $to, - $subject, - 'Nouveau message en provenance de la page "' . $this->getData(['page', $this->getUrl(0), 'title']) . '" :

' . - $content - ); } } // Redirection