From: Stéphane Jacob Date: Wed, 16 Jun 2010 16:08:59 +0000 (+0200) Subject: Fixes notification email, uses fullname in notification email(Closes #507). X-Git-Tag: xorg/1.0.0~124 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=0afc098bcd8218a807ecdc51857143e2aae6e662;p=platal.git Fixes notification email, uses fullname in notification email(Closes #507). Signed-off-by: Stéphane Jacob --- diff --git a/ChangeLog b/ChangeLog index 6083859..125ac8e 100644 --- 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: diff --git a/bin/cron/notifs.send.php b/bin/cron/notifs.send.php index a9958e4..939b558 100755 --- a/bin/cron/notifs.send.php +++ b/bin/cron/notifs.send.php @@ -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 diff --git a/templates/carnet/notif.mail.tpl b/templates/carnet/notif.mail.tpl index 6ebdbb5..3cb9a66 100644 --- a/templates/carnet/notif.mail.tpl +++ b/templates/carnet/notif.mail.tpl @@ -27,18 +27,18 @@ {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}