Commit | Line | Data |
---|---|---|
b715c1e1 SJ |
1 | <?php |
2 | /*************************************************************************** | |
3 | * Copyright (C) 2003-2008 Polytechnique.org * | |
4 | * http://opensource.polytechnique.org/ * | |
5 | * * | |
6 | * This program is free software; you can redistribute it and/or modify * | |
7 | * it under the terms of the GNU General Public License as published by * | |
8 | * the Free Software Foundation; either version 2 of the License, or * | |
9 | * (at your option) any later version. * | |
10 | * * | |
11 | * This program is distributed in the hope that it will be useful, * | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
14 | * GNU General Public License for more details. * | |
15 | * * | |
16 | * You should have received a copy of the GNU General Public License * | |
17 | * along with this program; if not, write to the Free Software * | |
18 | * Foundation, Inc., * | |
19 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * | |
20 | ***************************************************************************/ | |
21 | ||
b8d90797 | 22 | function fill_email_combobox(PlPage& $page) |
b715c1e1 SJ |
23 | { |
24 | global $globals; | |
25 | ||
acc9be56 | 26 | $user = S::user(); |
b715c1e1 SJ |
27 | $email_type = "directory"; |
28 | ||
29 | $res = XDB::query( | |
30 | "SELECT email_directory | |
31 | FROM profile_directory | |
acc9be56 | 32 | WHERE uid = {?}", $user->id()); |
b715c1e1 SJ |
33 | $email_directory = $res->fetchOneCell(); |
34 | if ($email_directory) { | |
35 | $page->assign('email_directory', $email_directory); | |
36 | list($alias, $domain) = explode('@', $email_directory); | |
37 | } else { | |
38 | $page->assign('email_directory', ''); | |
39 | $email_type = NULL; | |
40 | $alias = $domain = ''; | |
41 | } | |
42 | ||
43 | $res = XDB::query( | |
44 | "SELECT alias | |
45 | FROM virtual | |
46 | INNER JOIN virtual_redirect USING(vid) | |
acc9be56 | 47 | WHERE (redirect = {?} OR redirect = {?}) |
b715c1e1 | 48 | AND alias LIKE '%@{$globals->mail->alias_dom}'", |
acc9be56 VZ |
49 | $user->forlifeEmail(), |
50 | // TODO: remove this über-ugly hack. The issue is that you need | |
51 | // to remove all @m4x.org addresses in virtual_redirect first. | |
52 | $user->login() . '@' . $globals->mail->domain2); | |
b715c1e1 SJ |
53 | $melix = $res->fetchOneCell(); |
54 | if ($melix) { | |
55 | list($melix) = explode('@', $melix); | |
56 | $page->assign('melix', $melix); | |
57 | if (($domain == $globals->mail->alias_dom) || ($domain == $globals->mail->alias_dom2)) { | |
58 | $email_type = "melix"; | |
59 | } | |
60 | } | |
61 | ||
62 | $res = XDB::query( | |
63 | "SELECT alias | |
64 | FROM aliases | |
acc9be56 | 65 | WHERE id={?} AND (type='a_vie' OR type='alias')", $user->id()); |
b715c1e1 SJ |
66 | $res = $res->fetchAllAssoc(); |
67 | $page->assign('list_email_X', $res); | |
68 | if (($domain == $globals->mail->domain) || ($domain == $globals->mail->domain2)) { | |
69 | foreach ($res as $res_it) { | |
70 | if ($alias == $res_it['alias']) { | |
71 | $email_type = "X"; | |
72 | } | |
73 | } | |
74 | } | |
75 | ||
76 | require_once 'emails.inc.php'; | |
acc9be56 | 77 | $redirect = new Redirect($user); |
b715c1e1 SJ |
78 | $redir = array(); |
79 | foreach ($redirect->emails as $redirect_it) { | |
80 | if ($redirect_it instanceof EmailRedirection) { | |
81 | $redir[] = $redirect_it->email; | |
82 | if ($email_directory == $redirect_it->email) { | |
83 | $email_type = "redir"; | |
84 | } | |
85 | } | |
86 | } | |
87 | $page->assign('list_email_redir', $redir); | |
88 | ||
89 | $res = XDB::query( | |
90 | "SELECT email | |
f9cddbef | 91 | FROM profile_job |
acc9be56 | 92 | WHERE uid = {?}", $user->id()); |
b715c1e1 SJ |
93 | $res = $res->fetchAllAssoc(); |
94 | $pro = array(); | |
95 | foreach ($res as $res_it) { | |
96 | if ($res_it['email'] != '') { | |
97 | $pro[] = $res_it['email']; | |
98 | if ($email_directory == $res_it['email']) { | |
99 | $email_type = "pro"; | |
100 | } | |
101 | } | |
102 | } | |
103 | $page->assign('list_email_pro', $pro); | |
104 | ||
105 | $page->assign('email_type', $email_type); | |
106 | } | |
107 | ||
108 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: | |
109 | ?> |