[10.0.37.dev] empêche l'envoi d'un mail si captcha incorrect

This commit is contained in:
fredtempez 2019-10-19 19:57:49 +02:00
parent 5d880fa2da
commit 2f9f61c5a3
2 changed files with 49 additions and 47 deletions

View File

@ -31,7 +31,7 @@ class common {
const TEMP_DIR = 'site/tmp/'; const TEMP_DIR = 'site/tmp/';
// Numéro de version // Numéro de version
const ZWII_VERSION = '10.0.36.dev'; const ZWII_VERSION = '10.0.37.dev';
public static $actions = []; public static $actions = [];
public static $coreModuleIds = [ public static $coreModuleIds = [

View File

@ -293,6 +293,7 @@ class form extends common {
// Préparation le contenu du mail // Préparation le contenu du mail
$data = []; $data = [];
$content = ''; $content = '';
$sent = false;
foreach($this->getData(['module', $this->getUrl(0), 'input']) as $index => $input) { foreach($this->getData(['module', $this->getUrl(0), 'input']) as $index => $input) {
// Filtre la valeur // Filtre la valeur
switch($input['type']) { switch($input['type']) {
@ -318,55 +319,56 @@ class form extends common {
$content .= '<strong>' . $this->getData(['module', $this->getUrl(0), 'input', $index, 'name']) . ' :</strong> ' . $value . '<br>'; $content .= '<strong>' . $this->getData(['module', $this->getUrl(0), 'input', $index, 'name']) . ' :</strong> ' . $value . '<br>';
} }
// Crée les données // 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 // Envoi du mail
// Rechercher l'adresse en fonction du mail if ($success === true) {
$sent = true; // Rechercher l'adresse en fonction du mail
$singleuser = $this->getData(['user', $singleuser = $this->getData(['user',
$this->getData(['module', $this->getUrl(0), 'config', 'user']), $this->getData(['module', $this->getUrl(0), 'config', 'user']),
'mail']); 'mail']);
$singlemail = $this->getData(['module', $this->getUrl(0), 'config', 'mail']); $singlemail = $this->getData(['module', $this->getUrl(0), 'config', 'mail']);
$group = $this->getData(['module', $this->getUrl(0), 'config', 'group']); $group = $this->getData(['module', $this->getUrl(0), 'config', 'group']);
// Verification si le mail peut être envoyé // Verification si le mail peut être envoyé
if( if(
self::$inputNotices === [] && ( self::$inputNotices === [] && (
$group > 0 || $group > 0 ||
$singleuser !== '' || $singleuser !== '' ||
$singlemail !== '' ) $singlemail !== '' )
) { ) {
// Utilisateurs dans le groupe // Utilisateurs dans le groupe
$to = []; $to = [];
if ($group > 0){ if ($group > 0){
foreach($this->getData(['user']) as $userId => $user) { foreach($this->getData(['user']) as $userId => $user) {
if($user['group'] >= $group) { if($user['group'] >= $group) {
$to[] = $user['mail']; $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']) . '" :<br><br>' .
$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']) . '" :<br><br>' .
$content
);
} }
} }
// Redirection // Redirection