2 /***************************************************************************
3 * Copyright (C) 2003-2004 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
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. *
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. *
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 *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 require_once("xorg.inc.php");
23 new_skinned_page('emails/redirect.tpl',AUTH_MDP
);
24 require_once("emails.inc.php");
26 $uid = Session
::getInt('uid');
27 $forlife = Session
::get('forlife');
29 $redirect = new Redirect(Session
::getInt('uid'));
31 if (Env
::has('emailop')) {
32 $actifs = Env
::getMixed('emails_actifs', Array());
33 if (Env
::get('emailop') == "retirer" && Env
::has('email')) {
34 $page->assign('retour', $redirect->delete_email(Env
::get('email')));
35 } elseif (Env
::get('emailop') == "ajouter" && Env
::has('email')) {
36 $page->assign('retour', $redirect->add_email(Env
::get('email')));
37 } elseif (empty($actifs)) {
38 $page->assign('retour', ERROR_INACTIVE_REDIRECTION
);
39 } elseif (is_array($actifs)) {
40 $page->assign('retour', $redirect->modify_email($actifs, Env
::getMixed('emails_rewrite',Array())));
43 $res = $globals->xdb
->query(
46 INNER JOIN virtual_redirect USING(vid)
47 WHERE (redirect={?} OR redirect={?})
48 AND alias LIKE '%@{$globals->mail->alias_dom}'",
49 $forlife.'@'.$globals->mail
->domain
, $forlife.'@'.$globals->mail
->domain2
);
50 $melix = $res->fetchOneCell();
52 list($melix) = split('@', $melix);
53 $page->assign('melix',$melix);
56 $res = $globals->xdb
->query(
59 WHERE id={?} AND (type='a_vie' OR type='alias')
60 ORDER BY !FIND_IN_SET('usage',flags), LENGTH(alias)", $uid);
61 $page->assign('alias', $res->fetchAllAssoc());
62 $page->assign('emails',$redirect->emails
);