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 | ||
27 | $res = XDB::iterator('SELECT p.hrpid, pm.pid, a.full_name, pm.field, pm.oldText, pm.newText, p.sex, pd.yourself, al.alias | |
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)) | |
33 | INNER JOIN aliases AS al ON (ap.uid = al.uid AND FIND_IN_SET(\'bestalias\', al.flags)) | |
34 | ORDER BY pm.pid, pm.field'); | |
35 | ||
36 | $date = time(); | |
37 | $values = $res->next(); | |
38 | ||
39 | $pid = $values['pid']; | |
40 | $sex = ($values['sex'] == 'female') ? 1 : 0; | |
41 | $yourself = $values['yourself']; | |
42 | $alias = $values['alias']; | |
43 | $hrpid = $values['hrpid']; | |
44 | $modifications = array(); | |
45 | $modifications[] = array( | |
46 | 'full_name' => $values['full_name'], | |
47 | 'field' => $values['field'], | |
48 | 'oldText' => $values['oldText'], | |
49 | 'newText' => $values['newText'], | |
50 | ); | |
51 | ||
52 | while ($values = $res->next()) { | |
53 | if ($values['pid'] != $pid) { | |
54 | $mailer = new PlMailer('profile/notification.mail.tpl'); | |
55 | $mailer->addTo($alias . '@' . $globals->mail->domain); | |
56 | $mailer->assign('modifications', $modifications); | |
57 | $mailer->assign('yourself', $yourself); | |
58 | $mailer->assign('hrpid', $hrpid); | |
59 | $mailer->assign('sex', $sex); | |
60 | $mailer->assign('date', $date); | |
61 | $mailer->send(); | |
62 | $modifications = array(); | |
63 | } | |
64 | $pid = $values['pid']; | |
65 | $sex = ($values['sex'] == 'female') ? 1 : 0; | |
66 | $yourself = $values['yourself']; | |
67 | $alias = $values['alias']; | |
68 | $hrpid = $values['hrpid']; | |
69 | $modifications[] = array( | |
70 | 'full_name' => $values['full_name'], | |
71 | 'field' => $values['field'], | |
72 | 'oldText' => $values['oldText'], | |
73 | 'newText' => $values['newText'], | |
74 | ); | |
75 | } | |
76 | $mailer = new PlMailer('profile/notification.mail.tpl'); | |
77 | $mailer->addTo($alias . '@' . $globals->mail->domain); | |
78 | $mailer->assign('modifications', $modifications); | |
79 | $mailer->assign('yourself', $yourself); | |
80 | $mailer->assign('hrpid', $hrpid); | |
81 | $mailer->assign('sex', $sex); | |
82 | $mailer->assign('date', $date); | |
83 | $mailer->send(); | |
84 | ||
85 | XDB::execute('DELETE FROM profile_modifications'); | |
86 | ||
87 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: | |
88 | ?> |