X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Femail.php;h=8c363a80e804ad36c234822684eacb5914866d8b;hb=ee71865181e96e7b0754ef9e7da4b3cb26f4c1d7;hp=34d508a338114cf645ea6ae22472ce63ae08a1df;hpb=1c6b72d2eb255ee50fb6ff1ef0b45bc36d0d068a;p=platal.git diff --git a/modules/email.php b/modules/email.php index 34d508a..8c363a8 100644 --- a/modules/email.php +++ b/modules/email.php @@ -260,7 +260,15 @@ class EmailModule extends PLModule $actifs = Env::v('emails_actifs', Array()); print_r(Env::v('emails_rewrite')); if (Env::v('emailop') == "ajouter" && Env::has('email')) { - $result = $redirect->add_email(Env::v('email')); + $new_email = Env::v('email'); + if ($new_email == "new@example.org") { + $new_email = Env::v('email_new'); + } + $result = $redirect->add_email($new_email); + if ($result == ERROR_INVALID_EMAIL) { + $page->assign('email', $new_email); + } + $page->assign('retour', $result); } elseif (empty($actifs)) { $result = ERROR_INACTIVE_REDIRECTION; } elseif (is_array($actifs)) { @@ -312,6 +320,9 @@ class EmailModule extends PLModule // Display GoogleApps acount information. require_once 'googleapps.inc.php'; $page->assign('googleapps', GoogleAppsAccount::account_status($user->id())); + + require_once 'emails.combobox.inc.php'; + fill_email_combobox($page); } function handler_antispam(&$page, $statut_filtre = null) @@ -418,14 +429,26 @@ class EmailModule extends PLModule $to2 = getEmails(Env::v('to_contacts')); $cc2 = getEmails(Env::v('cc_contacts')); $txt = str_replace('^M', '', Env::v('contenu')); - $to = Env::v('to'); - $subj = Env::v('sujet'); - $from = Env::v('from'); - $cc = trim(Env::v('cc')); - $bcc = trim(Env::v('bcc')); - + $to = str_replace(';', ',', Env::t('to')); + $subj = Env::t('sujet'); + $from = Env::t('from'); + $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(); @@ -655,7 +678,7 @@ L'équipe d'administration mail->domain . '>'; $mail->setSubject("Une de tes adresse de redirection Polytechnique.org ne marche plus !!"); $mail->setTxtBody($message); $mail->send(); - $page->trigSuccess("Email envoyé !"); + $page->trigSuccess('Email envoyé !'); } } elseif (Post::has('email')) { S::assert_xsrf_token(); @@ -824,8 +847,8 @@ L'équipe d'administration mail->domain . '>'; foreach ($broken_list as $orig_email) { $email = valide_email(trim($orig_email)); if (empty($email) || $email == '@') { - $invalid_emails[] = "$orig_email: invalid email"; - } else { + $invalid_emails[] = trim($orig_email) . ': invalid email'; + } elseif (!in_array($email, $valid_emails)) { $res = XDB::query('SELECT COUNT(*) FROM emails WHERE email = {?}', $email); @@ -913,11 +936,11 @@ L'équipe d'administration mail->domain . '>'; // Output the list of users with recently broken addresses, // along with the count of valid redirections. - header('Content-Type: text/x-csv; charset=utf-8;'); - header('Cache-Control: no-cache'); + require_once 'include/notifs.inc.php'; + pl_content_headers("text/x-csv"); $csv = fopen('php://output', 'w'); - fputcsv($csv, array('nom', 'prenom', 'alias', 'bounce', 'nbmails', 'url'), ';'); + fputcsv($csv, array('nom', 'prenom', 'promo', 'alias', 'bounce', 'nbmails', 'url'), ';'); foreach ($broken_user_list as $alias => $mails) { $sel = Xdb::query( "SELECT u.user_id, count(e.email) AS nb_mails, u.nom, u.prenom, u.promo @@ -929,9 +952,12 @@ L'équipe d'administration mail->domain . '>'; GROUP BY u.user_id", $alias); if ($x = $sel->fetchOneAssoc()) { + if ($x['nb_mails'] == 0) { + register_profile_update($x['user_id'], 'broken'); + } fputcsv($csv, array($x['nom'], $x['prenom'], $x['promo'], $alias, - join(',', $mails), $x['nb_mails']), - 'https://www.polytechnique.org/marketing/broken/' . $alias, ';'); + join(',', $mails), $x['nb_mails'], + 'https://www.polytechnique.org/marketing/broken/' . $alias), ';'); } } fclose($csv);