Commit | Line | Data |
---|---|---|
ee68ddc1 | 1 | #!/usr/bin/php5 -q |
0337d704 | 2 | <?php |
3 | /*************************************************************************** | |
5ddeb07c | 4 | * Copyright (C) 2003-2007 Polytechnique.org * |
0337d704 | 5 | * http://opensource.polytechnique.org/ * |
6 | * * | |
7 | * This program is free software; you can redistribute it and/or modify * | |
8 | * it under the terms of the GNU General Public License as published by * | |
9 | * the Free Software Foundation; either version 2 of the License, or * | |
10 | * (at your option) any later version. * | |
11 | * * | |
12 | * This program is distributed in the hope that it will be useful, * | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
15 | * GNU General Public License for more details. * | |
16 | * * | |
17 | * You should have received a copy of the GNU General Public License * | |
18 | * along with this program; if not, write to the Free Software * | |
19 | * Foundation, Inc., * | |
20 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * | |
21 | ***************************************************************************/ | |
22 | ||
23 | require_once('./connect.db.inc.php'); | |
1e33266a | 24 | require_once('../../classes/plmailer.php'); |
0337d704 | 25 | require_once("../../include/notifs.inc.php"); |
0337d704 | 26 | |
27 | $all = new AllNotifs(); | |
28 | ||
29 | foreach($all->_data as $u) { | |
30 | $week = date("W - Y"); | |
31 | ||
a7de4ef7 | 32 | $text = " ".($u['sexe'] ? 'Chère' : 'Cher')." {$u['prenom']},\n\n" |
33 | . " Voici les événements survenus dans la semaine écoulée,\n" | |
34 | . "et depuis ta dernière visite sur le site.\n\n" | |
35 | . "Tu trouveras les mêmes informations sur la page :\n" | |
fa7e726d | 36 | . " https://www.polytechnique.org/carnet/panel\n\n" |
0337d704 | 37 | . "------------------------------------------------------------------------\n\n"; |
38 | ||
39 | $html = <<<EOF | |
40 | <html> | |
41 | <head> | |
42 | <title>Notifications de la semaine $week</title> | |
43 | </head> | |
44 | <body> | |
a7de4ef7 | 45 | <p>Voici les événements survenus dans la semaine écoulée, et depuis ta dernière visite sur le site.</p> |
46 | <p>Tu trouveras les mêmes informations sur <a href='https://www.polytechnique.org/carnet/panel'>cette page</a></p> | |
0337d704 | 47 | EOF; |
48 | ||
49 | foreach($u['data'] as $cid=>$d) { | |
50 | $text .= " {$all->_cats[$cid][(count($d)==1)?'mail_sg':'mail']} :\n\n"; | |
51 | $html .= "<h1 style='font-size: 120%'>{$all->_cats[$cid][(count($d)==1)?'mail_sg':'mail']} :</h1>\n<ul>\n"; | |
52 | ||
53 | foreach($d as $promo=>$x) { | |
54 | require_once('../../plugins/modifier.date_format.php'); | |
55 | $date = smarty_modifier_date_format($x['date'], '%d %b %Y'); | |
56 | $text .= " - (X{$x['promo']}) {$x['prenom']} {$x['nom']} le $date\n"; | |
a3ba371a | 57 | $text .= " https://www.polytechnique.org/profile/private/{$x['bestalias']}\n\n"; |
58 | $html .= "<li>(X{$x['promo']}) <a href='https://www.polytechnique.org/profile/private/{$x['bestalias']}'>{$x['prenom']} {$x['nom']}</a> le $date</li>\n"; | |
0337d704 | 59 | } |
60 | $text .= "\n"; | |
61 | $html .= "</ul>\n"; | |
62 | } | |
63 | ||
64 | $text .= "-- \n" | |
a7de4ef7 | 65 | . "L'équipe de Polytechnique.org\n\n" |
0337d704 | 66 | . "------------------------------------------------------------------------\n\n" |
a7de4ef7 | 67 | . "Tu recois ce mail car tu as activé la notification automatique \n" |
68 | . "par mail des événements que tu surveilles.\n\n" | |
0337d704 | 69 | . "Tu peux changer cette option sur :\n" |
fa7e726d | 70 | . " https://www.polytechnique.org/carnet/notifs"; |
0337d704 | 71 | $html .= <<<EOF |
72 | <hr /> | |
a7de4ef7 | 73 | <p>L'équipe de Polytechnique.org</p> |
0337d704 | 74 | <br /> |
75 | <p> | |
a7de4ef7 | 76 | Tu recois ce mail car tu as activé la notification automatique par mail des événements que tu surveilles. |
0337d704 | 77 | </p> |
fa7e726d | 78 | <p>Tu peux changer cette option sur la <a href="https://www.polytechnique.org/carnet/notifs">page |
0337d704 | 79 | de configuration des notifications</a> |
80 | </p> | |
81 | </body> | |
82 | </html> | |
83 | EOF; | |
eaf30d86 | 84 | |
9954aca6 | 85 | global $globals; |
1e33266a | 86 | $mailer = new PlMailer(); |
1d55fe45 | 87 | $mailer->setFrom('Carnet Polytechnicien <support_carnet@' . $globals->mail->domain . '>'); |
9954aca6 | 88 | $mailer->addTo("\"{$u['prenom']} {$u['nom']}\" <{$u['bestalias']}@" . $globals->mail->domain . '>'); |
0337d704 | 89 | $mailer->setSubject("Notifications de la semaine $week"); |
90 | $mailer->setTxtBody($text); | |
91 | if ($u['mail_fmt'] == 'html') { $mailer->setHtmlBody($html); } | |
92 | $mailer->send(); | |
93 | } | |
94 | ||
87691841 FB |
95 | XDB::execute("DELETE FROM watch_profile |
96 | WHERE ts < DATE_SUB(CURRENT_DATE, INTERVAL 15 DAY)"); | |
97 | ||
a7de4ef7 | 98 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: |
0337d704 | 99 | ?> |