Commit | Line | Data |
---|---|---|
a0fce0c6 SJ |
1 | #!/usr/bin/php5 -q |
2 | <?php | |
3 | /*************************************************************************** | |
4 | * Copyright (C) 2003-2010 Polytechnique.org * | |
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'; | |
24 | require_once 'plmailer.php'; | |
25 | global $globals; | |
26 | ||
14aba233 SJ |
27 | $translations = array( |
28 | 'search_names' => 'Noms', | |
29 | 'nationality1' => 'Nationalité', | |
30 | 'nationality2' => '2e nationalité', | |
31 | 'nationality3' => '3e nationalité', | |
32 | 'promo_display' => 'Promotion affichée', | |
33 | 'email_directory' => 'Email annuaire papier', | |
34 | 'networking' => 'Messageries…', | |
35 | 'tels' => 'Téléphones', | |
36 | 'edus' => 'Formations', | |
37 | 'promo' => 'Promotion de sortie', | |
38 | 'birthdate' => 'Date de naissance', | |
39 | 'yourself' => 'Nom affiché', | |
40 | 'freetext' => 'Commentaire', | |
41 | 'freetext_pub' => 'Affichage de ton commentaire', | |
42 | 'photo_pub' => 'Affichage de ta photo', | |
43 | 'addresses' => 'Adresses', | |
44 | 'corps' => 'Corps', | |
45 | 'cv' => 'CV', | |
46 | 'jobs' => 'Emplois', | |
47 | 'section' => 'Section', | |
48 | 'binets' => 'Binets', | |
49 | 'medals' => 'Décorations', | |
50 | 'medals_pub' => 'Affichage de tes décorations', | |
51 | 'competences' => 'Compétences', | |
52 | 'langues' => 'Langues', | |
53 | 'expertise' => 'Expertises (mentoring)', | |
54 | 'terms' => 'Compétences (mentoring)', | |
55 | 'countries' => 'Pays (mentoring)' | |
56 | ); | |
a0fce0c6 SJ |
57 | $res = XDB::iterator('SELECT p.hrpid, pm.pid, a.full_name, pm.field, pm.oldText, pm.newText, p.sex, pd.yourself, al.alias |
58 | FROM profile_modifications AS pm | |
59 | INNER JOIN accounts AS a ON (pm.uid = a.uid) | |
60 | INNER JOIN profiles AS p ON (pm.pid = p.pid) | |
61 | INNER JOIN profile_display AS pd ON (pm.pid = pd.pid) | |
62 | INNER JOIN account_profiles AS ap ON (pm.pid = ap.pid AND FIND_IN_SET(\'owner\', ap.perms)) | |
63 | INNER JOIN aliases AS al ON (ap.uid = al.uid AND FIND_IN_SET(\'bestalias\', al.flags)) | |
3e2fb187 | 64 | WHERE pm.type = \'third_party\' AND pm.field != \'deathdate\' |
f5751460 | 65 | ORDER BY pm.pid, pm.field, pm.timestamp'); |
a0fce0c6 | 66 | |
adbcb1b5 | 67 | if ($res->total() > 0) { |
d6c46405 SJ |
68 | $date = time(); |
69 | $values = $res->next(); | |
a0fce0c6 | 70 | |
a0fce0c6 SJ |
71 | $pid = $values['pid']; |
72 | $sex = ($values['sex'] == 'female') ? 1 : 0; | |
73 | $yourself = $values['yourself']; | |
74 | $alias = $values['alias']; | |
75 | $hrpid = $values['hrpid']; | |
d6c46405 | 76 | $modifications = array(); |
a0fce0c6 SJ |
77 | $modifications[] = array( |
78 | 'full_name' => $values['full_name'], | |
14aba233 | 79 | 'field' => $translations[$values['field']], |
a0fce0c6 SJ |
80 | 'oldText' => $values['oldText'], |
81 | 'newText' => $values['newText'], | |
82 | ); | |
a0fce0c6 | 83 | |
d6c46405 SJ |
84 | while ($values = $res->next()) { |
85 | if ($values['pid'] != $pid) { | |
86 | $mailer = new PlMailer('profile/notification.mail.tpl'); | |
87 | $mailer->addTo($alias . '@' . $globals->mail->domain); | |
88 | $mailer->assign('modifications', $modifications); | |
89 | $mailer->assign('yourself', $yourself); | |
90 | $mailer->assign('hrpid', $hrpid); | |
91 | $mailer->assign('sex', $sex); | |
92 | $mailer->assign('date', $date); | |
93 | $mailer->send(); | |
94 | $modifications = array(); | |
95 | } | |
96 | $pid = $values['pid']; | |
97 | $sex = ($values['sex'] == 'female') ? 1 : 0; | |
98 | $yourself = $values['yourself']; | |
99 | $alias = $values['alias']; | |
100 | $hrpid = $values['hrpid']; | |
101 | $modifications[] = array( | |
102 | 'full_name' => $values['full_name'], | |
14aba233 | 103 | 'field' => $translations[$values['field']], |
d6c46405 SJ |
104 | 'oldText' => $values['oldText'], |
105 | 'newText' => $values['newText'], | |
106 | ); | |
107 | } | |
108 | $mailer = new PlMailer('profile/notification.mail.tpl'); | |
109 | $mailer->addTo($alias . '@' . $globals->mail->domain); | |
110 | $mailer->assign('modifications', $modifications); | |
111 | $mailer->assign('yourself', $yourself); | |
112 | $mailer->assign('hrpid', $hrpid); | |
113 | $mailer->assign('sex', $sex); | |
114 | $mailer->assign('date', $date); | |
115 | $mailer->send(); | |
116 | ||
f5751460 SJ |
117 | XDB::execute('DELETE FROM profile_modifications |
118 | WHERE type = \'third_party\''); | |
d6c46405 | 119 | } |
a0fce0c6 SJ |
120 | |
121 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: | |
122 | ?> |