closes FS#232
authorPierre Habouzit (MadCoder <pierre.habouzit@m4x.org>
Sat, 15 Jan 2005 09:43:57 +0000 (09:43 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Thu, 26 Jun 2008 21:27:36 +0000 (23:27 +0200)
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
bin/cron/send_notifs.php
include/notifs.inc.php

index 9bcba82..857a7b8 100644 (file)
--- 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
index ed6e1ac..2c1abf4 100755 (executable)
@@ -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  = <<<EOF
+<html>
+  <head>
+    <title>Notifications de la semaine $week</title>
+  </head>
+  <body>
+    <p>Voici les évènements survenus dans la semaine écoulée, et depuis ta dernière visite sur le site.</p>
+    <p>Tu trouveras les mêmes informations sur <a href='{$globals->baseurl}/carnet/panel.php'>cette page</a></p>
+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 .= "<h1 style='font-size: 120%'>{$all->_cats[$cid]['mail']} :</h1>\n<ul>\n";
+
+        foreach($d as $promo=>$x) {
+            require_once('../../plugins/modifier.date_format.php');
+            $date  = smarty_modifier_date_format($x['date'], '%d %b %Y');
+            $text .= "    - (X{$x['promo']}) {$x['prenom']} {$x['nom']} le $date\n";
+            $text .= "      {$globals->baseurl}/fiche.php?user={$x['bestalias']}\n\n";
+            $html .= "<li>(X{$x['promo']}) <a href='{$globals->baseurl}/fiche.php?user={$x['bestalias']}'>{$x['prenom']} {$x['nom']}</a> le $date</li>\n";
+        }
+        $text .= "\n";
+        $html .= "</ul>\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 .= <<<EOF
+    <hr />
+    <p>L'équipe de Polytechnique.org</p>
+    <br />
+    <p>
+    Tu recois ce mail car tu as activé la notification automatique par mail des évènements que tu surveilles.
+    </p>
+    <p>Tu peux changer cette option sur la <a href="{$globals->baseurl}/carnet/notifs.php">page
+    de configuration des notifications</a>
+    </p>
+  </body>
+</html>
+EOF;
     
     $mailer = new HermesMailer();
     $mailer->setFrom("Carnet Polytechnicien <support_carnet@polytechnique.org>");
     $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();
 }
 
index 892efee..1242057 100644 (file)
@@ -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;
        }
     }