From: Stéphane Jacob Date: Fri, 13 Nov 2009 09:41:29 +0000 (+0100) Subject: Notifies the user when an email is not valid. X-Git-Tag: xorg/0.10.2~1 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=6ff4f8c0ff2e02e07b1f45793a5db3b306d50813;p=platal.git Notifies the user when an email is not valid. --- diff --git a/modules/email.php b/modules/email.php index 272756f..0898aa4 100644 --- a/modules/email.php +++ b/modules/email.php @@ -424,8 +424,20 @@ class EmailModule extends PLModule $cc = str_replace(';', ',', Env::t('cc')); $bcc = str_replace(';', ',', Env::t('bcc')); + $email_regex = '/^[a-z0-9.\-+_\$]+@([\-.+_]?[a-z0-9])+$/i'; + foreach (explode(',', $to . ',' . $cc . ',' . $bcc) as $email) { + $email = trim($email); + if ($email != '' && !preg_match($email_regex, $email)) { + $page->trigError("L'adresse email " . $email . ' est erronée.'); + $error = true; + } + } if (empty($to) && empty($cc) && empty($to2) && empty($bcc) && empty($cc2)) { $page->trigError("Indique au moins un destinataire."); + $error = true; + } + + if ($error) { $page->assign('uploaded_f', PlUpload::listFilenames(S::user()->login(), 'emails.send')); } else { $mymail = new PlMailer();