Uses PlPage instead of PlatalPage (again).
[platal.git] / include / emails.combobox.inc.php
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
22 function fill_email_combobox(PlPage& $page)
23 {
24 global $globals;
25
26 $uid = S::v('uid');
27 $forlife = S::v('forlife');
28 $email_type = "directory";
29
30 $res = XDB::query(
31 "SELECT email_directory
32 FROM profile_directory
33 WHERE uid={?}", $uid);
34 $email_directory = $res->fetchOneCell();
35 if ($email_directory) {
36 $page->assign('email_directory', $email_directory);
37 list($alias, $domain) = explode('@', $email_directory);
38 } else {
39 $page->assign('email_directory', '');
40 $email_type = NULL;
41 $alias = $domain = '';
42 }
43
44 $res = XDB::query(
45 "SELECT alias
46 FROM virtual
47 INNER JOIN virtual_redirect USING(vid)
48 WHERE (redirect={?} OR redirect={?})
49 AND alias LIKE '%@{$globals->mail->alias_dom}'",
50 $forlife . '@' . $globals->mail->domain, $forlife . '@' . $globals->mail->domain2);
51 $melix = $res->fetchOneCell();
52 if ($melix) {
53 list($melix) = explode('@', $melix);
54 $page->assign('melix', $melix);
55 if (($domain == $globals->mail->alias_dom) || ($domain == $globals->mail->alias_dom2)) {
56 $email_type = "melix";
57 }
58 }
59
60 $res = XDB::query(
61 "SELECT alias
62 FROM aliases
63 WHERE id={?} AND (type='a_vie' OR type='alias')", $uid);
64 $res = $res->fetchAllAssoc();
65 $page->assign('list_email_X', $res);
66 if (($domain == $globals->mail->domain) || ($domain == $globals->mail->domain2)) {
67 foreach ($res as $res_it) {
68 if ($alias == $res_it['alias']) {
69 $email_type = "X";
70 }
71 }
72 }
73
74 require_once 'emails.inc.php';
75 $redirect = new Redirect($uid);
76 $redir = array();
77 foreach ($redirect->emails as $redirect_it) {
78 if ($redirect_it instanceof EmailRedirection) {
79 $redir[] = $redirect_it->email;
80 if ($email_directory == $redirect_it->email) {
81 $email_type = "redir";
82 }
83 }
84 }
85 $page->assign('list_email_redir', $redir);
86
87 $res = XDB::query(
88 "SELECT email
89 FROM entreprises
90 WHERE uid={?}", $uid);
91 $res = $res->fetchAllAssoc();
92 $pro = array();
93 foreach ($res as $res_it) {
94 if ($res_it['email'] != '') {
95 $pro[] = $res_it['email'];
96 if ($email_directory == $res_it['email']) {
97 $email_type = "pro";
98 }
99 }
100 }
101 $page->assign('list_email_pro', $pro);
102
103 $page->assign('email_type', $email_type);
104 }
105
106 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
107 ?>