From 939e352b1e098fa65486ca31d81c2b6b21da9b39 Mon Sep 17 00:00:00 2001 From: "Pierre Habouzit (MadCoder" Date: Sat, 15 Jan 2005 09:43:57 +0000 Subject: [PATCH] closes FS#232 Patches applied: * opensource@polytechnique.org--2005/platal--release--0.9.3--patch-32 bug in the notifs git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-332 --- ChangeLog | 4 +++ bin/cron/send_notifs.php | 68 ++++++++++++++++++++++++++++++++++++------------ include/notifs.inc.php | 10 ++++--- 3 files changed, 61 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9bcba82..857a7b8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -21,6 +21,9 @@ New : - Brand new PDF of the contact list (using FPDF). -MC - Even include Photos in the PDF (kludgy !). -MC + * Notifications : + - Use Pascal's work to enable a simple, nicer html mail. -MC + * Photo Submission : - Rework of the form. -MC - Photo is resized on the fly, instead of dropping too big images. -MC @@ -58,6 +61,7 @@ Bug/Wish : * Notifications : - #63: Birthdays are now in the notifications ! -MC + - #232: Add a link to the fiche. -MC/Car * Profile : - #65 : Add professionnal cellphone. -Car diff --git a/bin/cron/send_notifs.php b/bin/cron/send_notifs.php index ed6e1ac..2c1abf4 100755 --- a/bin/cron/send_notifs.php +++ b/bin/cron/send_notifs.php @@ -27,33 +27,67 @@ require_once("diogenes/diogenes.hermes.inc.php"); $all = new AllNotifs(); foreach($all->_data as $u) { + $week = date("W - Y"); + $text = " ".($u['sexe'] ? 'Chère' : 'Cher')." {$u['prenom']},\n\n" . " Voici les évènements survenus dans la semaine écoulée,\n" - . "et depuis ta dernière visite sur le site.\n\n" - . "Tu trouveras les mêmes informations sur la page :\n" - . " {$globals->baseurl}/carnet/panel.php\n\n"; - $text .= "------------------------------------------------------------\n\n"; + . "et depuis ta dernière visite sur le site.\n\n" + . "Tu trouveras les mêmes informations sur la page :\n" + . " {$globals->baseurl}/carnet/panel.php\n\n" + . "------------------------------------------------------------------------\n\n"; + + $html = << + + Notifications de la semaine $week + + +

Voici les évènements survenus dans la semaine écoulée, et depuis ta dernière visite sur le site.

+

Tu trouveras les mêmes informations sur cette page

+EOF; + foreach($u['data'] as $cid=>$d) { - $text .= " {$all->_cats[$cid]['mail']} :\n\n"; - foreach($d as $promo=>$x) { - $text .= " - (X{$x['promo']}) {$x['prenom']} {$x['nom']} le {$x['date']}\n"; - } - $text .= "\n"; + $text .= " {$all->_cats[$cid]['mail']} :\n\n"; + $html .= "

{$all->_cats[$cid]['mail']} :

\n\n"; } - $text .= "------------------------------------------------------------\n\n" - . "Tu recois ce mail car tu as activé la notification\n" - . "automatique par mail des évènements que tu surveilles.\n\n" - . "Tu peux changer cette option sur :\n" - . " {$globals->baseurl}/carnet/notifs.php\n\n" - . "-- \n" - . "L'équipe de Polytechnique.org"; + $text .= "-- \n" + . "L'équipe de Polytechnique.org\n\n" + . "------------------------------------------------------------------------\n\n" + . "Tu recois ce mail car tu as activé la notification automatique \n" + . "par mail des évènements que tu surveilles.\n\n" + . "Tu peux changer cette option sur :\n" + . " {$globals->baseurl}/carnet/notifs.php"; + $html .= << +

L'équipe de Polytechnique.org

+
+

+ Tu recois ce mail car tu as activé la notification automatique par mail des évènements que tu surveilles. +

+

Tu peux changer cette option sur la page + de configuration des notifications +

+ + +EOF; $mailer = new HermesMailer(); $mailer->setFrom("Carnet Polytechnicien "); $mailer->addTo("\"{$u['prenom']} {$u['nom']}\" <{$u['bestalias']}@polytechnique.org>"); - $mailer->setSubject("Notifications de la semaine ".date("W - Y")); + $mailer->setSubject("Notifications de la semaine $week"); $mailer->setTxtBody($text); + if ($u['mail_fmt'] == 'html') { $mailer->setHtmlBody($html); } $mailer->send(); } diff --git a/include/notifs.inc.php b/include/notifs.inc.php index 892efee..1242057 100644 --- a/include/notifs.inc.php +++ b/include/notifs.inc.php @@ -85,7 +85,7 @@ function _select_notifs_base($table, $mail, $where) if ($mail) { $sql.=", w.uid AS aid, v.prenom AS aprenom, IF(v.epouse='',v.nom,v.prenom) AS anom, - b.alias AS abestalias, (v.flags='femme') AS sexe"; + b.alias AS abestalias, (v.flags='femme') AS sexe, q.core_mail_fmt AS mail_fmt"; } $sql .= " @@ -172,9 +172,11 @@ class AllNotifs { while($tmp = $res->next()) { $aid = $tmp['aid']; - $this->_data[$aid] = Array("prenom" => $tmp['aprenom'], 'nom' => $tmp['anom'], - 'bestalias'=>$tmp['abestalias'], 'sexe' => $tmp['sexe']); - unset($tmp['aprenom'],$tmp['anom'],$tmp['abestalias'],$tmp['aid'],$tmp['sexe']); + if (empty($this->_data[$aid])) { + $this->_data[$aid] = Array("prenom" => $tmp['aprenom'], 'nom' => $tmp['anom'], + 'bestalias'=>$tmp['abestalias'], 'sexe' => $tmp['sexe'], 'mail_fmt' => $tmp['mail_fmt']); + } + unset($tmp['aprenom'], $tmp['anom'], $tmp['abestalias'], $tmp['aid'], $tmp['sexe'], $tmp['mail_fmt']); $this->_data[$aid]['data'][$tmp['cid']][] = $tmp; } } -- 2.1.4