Fixes notification email, uses fullname in notification email(Closes #507).
authorStéphane Jacob <sj@m4x.org>
Wed, 16 Jun 2010 16:08:59 +0000 (18:08 +0200)
committerStéphane Jacob <sj@m4x.org>
Thu, 17 Jun 2010 14:54:26 +0000 (16:54 +0200)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
ChangeLog
bin/cron/notifs.send.php
templates/carnet/notif.mail.tpl

index 6083859..125ac8e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -13,6 +13,7 @@ Bug/Wish:
         - #1089: Also logs the return url in auth for groupesx             -Car
 
     * Carnet:
+        - #507: Uses full name in notification email                       -JAC
         - #1074: Removes the red cross to reset contact search             -Car
 
     * Core:
index a9958e4..939b558 100755 (executable)
@@ -24,16 +24,25 @@ require_once 'connect.db.inc.php';
 require_once 'plmailer.php';
 require_once 'notifs.inc.php';
 
-$all = new AllNotifs();
+$uids = XDB::query('SELECT  uid
+                      FROM  watch
+                     WHERE  FIND_IN_SET(\'mail\', flags)
+                  ORDER BY  uid');
+$iterator = User::iterOverUIDs($uids->fetchColumn());
 
 $mailer = new PlMailer('carnet/notif.mail.tpl');
-foreach ($all->_data as $u) {
-    $mailer = new PlMailer('carnet/notif.mail.tpl');
-    $mailer->assign('u', $u);
-    $mailer->assign('week', date("W - Y"));
-    $mailer->assign('cats', $all->_cats);
-    $mailer->addTo('"' . $u['prenom'] . ' ' . $u['nom'] . '" <' . $u['bestalias'] . '@polytechnique.org>');
-    $mailer->send($u['mail_fmt'] == 'html');
+while($user = $iterator->next()) {
+    if (Watch::getCount($user) > 0) {
+        $notifs = Watch::getEvents($user, time() - (7 * 86400));
+        $mailer->assign('sex', $user->profile()->isFemale());
+        $mailer->assign('yourself', $user->profile()->yourself);
+        $mailer->assign('week', date('W - Y'));
+        $mailer->assign('notifs', $notifs);
+        $mailer->addTo('"' . $user->full_name . '" <' . $user->bestalias . '>');
+        $mailer->send($user->email_format == 'html');
+        unset($notifs);
+    }
+    unset($user);
 }
 
 XDB::execute("UPDATE  watch_profile
index 6ebdbb5..3cb9a66 100644 (file)
 {if isset(#replyto#)}{add_header name='Reply-To' value=#replyto#}{/if}
 {if isset(#retpath#)}{add_header name='Return-Path' value=#retpath#}{/if}
 {elseif $mail_part eq 'wiki'}
-{if $u.sexe}Chère{else}Cher{/if} {$u.prenom},
+{if $sex}Chère{else}Cher{/if} {$yourself},
 
 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 [[https://www.polytechnique.org/carnet/panel|cette page]].
 
-{foreach from=$u.data key=cid item=d}
+{foreach from=$notifs item=cat}
+{$cat.title} :
 
-'''{if $d|@count eq 1}{if $d[0].sexe}{$cats[$cid].mail_sg_xette}{else}{$cats[$cid].mail_sg}{/if}{else}{$cats[$cid].mail}{/if} :'''
-
-{foreach from=$d item=x}
-* (X{$x.promo}), le {$x.date|date_format:"%d %B %Y"}, [[https://www.polytechnique.org/profile/private/{$x.bestalias}|{$x.prenom} {$x.nom}]]
+{foreach from=$cat.users item=user}
+{assign var=profile value=$user->profile()}
+* Le {$cat.operation->getDate($user)|date_format:"%d %B %Y"}, [[https://www.polytechnique.org/profile/private/{$profile->hrid()}|{$profile->fullname(true)}]]
 {/foreach}
 
 {/foreach}