Commit | Line | Data |
---|---|---|
a0fce0c6 SJ |
1 | #!/usr/bin/php5 -q |
2 | <?php | |
3 | /*************************************************************************** | |
5e1513f6 | 4 | * Copyright (C) 2003-2011 Polytechnique.org * |
a0fce0c6 SJ |
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 | ||
f036c896 | 27 | $res = XDB::iterator('SELECT p.hrpid, pm.pid, a.full_name, pm.field, pm.oldText, pm.newText, p.sex, pd.yourself, ap.uid |
a0fce0c6 SJ |
28 | FROM profile_modifications AS pm |
29 | INNER JOIN accounts AS a ON (pm.uid = a.uid) | |
30 | INNER JOIN profiles AS p ON (pm.pid = p.pid) | |
31 | INNER JOIN profile_display AS pd ON (pm.pid = pd.pid) | |
32 | INNER JOIN account_profiles AS ap ON (pm.pid = ap.pid AND FIND_IN_SET(\'owner\', ap.perms)) | |
3e2fb187 | 33 | WHERE pm.type = \'third_party\' AND pm.field != \'deathdate\' |
f5751460 | 34 | ORDER BY pm.pid, pm.field, pm.timestamp'); |
a0fce0c6 | 35 | |
adbcb1b5 | 36 | if ($res->total() > 0) { |
d6c46405 SJ |
37 | $date = time(); |
38 | $values = $res->next(); | |
a0fce0c6 | 39 | |
a0fce0c6 SJ |
40 | $pid = $values['pid']; |
41 | $sex = ($values['sex'] == 'female') ? 1 : 0; | |
42 | $yourself = $values['yourself']; | |
f036c896 | 43 | $user = User::getSilentWithUID($values['uid']); |
a0fce0c6 | 44 | $hrpid = $values['hrpid']; |
d6c46405 | 45 | $modifications = array(); |
a0fce0c6 SJ |
46 | $modifications[] = array( |
47 | 'full_name' => $values['full_name'], | |
7a9680aa | 48 | 'field' => $values['field'], |
a0fce0c6 SJ |
49 | 'oldText' => $values['oldText'], |
50 | 'newText' => $values['newText'], | |
51 | ); | |
a0fce0c6 | 52 | |
d6c46405 SJ |
53 | while ($values = $res->next()) { |
54 | if ($values['pid'] != $pid) { | |
55 | $mailer = new PlMailer('profile/notification.mail.tpl'); | |
f036c896 | 56 | $mailer->addTo($user); |
d6c46405 SJ |
57 | $mailer->assign('modifications', $modifications); |
58 | $mailer->assign('yourself', $yourself); | |
59 | $mailer->assign('hrpid', $hrpid); | |
60 | $mailer->assign('sex', $sex); | |
61 | $mailer->assign('date', $date); | |
62 | $mailer->send(); | |
63 | $modifications = array(); | |
64 | } | |
65 | $pid = $values['pid']; | |
66 | $sex = ($values['sex'] == 'female') ? 1 : 0; | |
67 | $yourself = $values['yourself']; | |
f036c896 | 68 | $user = User::getSilentWithUID($values['uid']); |
d6c46405 SJ |
69 | $hrpid = $values['hrpid']; |
70 | $modifications[] = array( | |
71 | 'full_name' => $values['full_name'], | |
7a9680aa | 72 | 'field' => $values['field'], |
d6c46405 SJ |
73 | 'oldText' => $values['oldText'], |
74 | 'newText' => $values['newText'], | |
75 | ); | |
76 | } | |
77 | $mailer = new PlMailer('profile/notification.mail.tpl'); | |
f036c896 | 78 | $mailer->addTo($user); |
d6c46405 SJ |
79 | $mailer->assign('modifications', $modifications); |
80 | $mailer->assign('yourself', $yourself); | |
81 | $mailer->assign('hrpid', $hrpid); | |
82 | $mailer->assign('sex', $sex); | |
83 | $mailer->assign('date', $date); | |
84 | $mailer->send(); | |
85 | ||
f5751460 SJ |
86 | XDB::execute('DELETE FROM profile_modifications |
87 | WHERE type = \'third_party\''); | |
d6c46405 | 88 | } |
a0fce0c6 SJ |
89 | |
90 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: | |
91 | ?> |