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_admin_page('admin/homonymes.tpl');
24 require_once("homonymes.inc.php");
26 $op = Env
::get('op', 'list');
27 $target = Env
::getInt('target');
30 if (! list($prenom,$nom,$forlife,$loginbis) = select_if_homonyme($target)) {
33 $page->assign('nom',$nom);
34 $page->assign('prenom',$prenom);
35 $page->assign('forlife',$forlife);
36 $page->assign('loginbis',$loginbis);
40 $page->assign('op',$op);
41 $page->assign('target',$target);
42 $page->assign('baseurl',$globals->baseurl
);
44 // on a un $target valide, on prepare les mails
47 // on examine l'op a effectuer
50 send_warning_homonyme($prenom, $nom, $forlife, $loginbis);
51 switch_bestalias($target, $loginbis);
55 switch_bestalias($target, $loginbis);
56 $globals->xdb
->execute("UPDATE aliases SET type='homonyme',expire=NOW() WHERE alias={?}", $loginbis);
57 $globals->xdb
->execute("REPLACE INTO homonymes (homonyme_id,user_id) VALUES({?},{?})", $target, $target);
58 send_robot_homonyme($prenom, $nom, $forlife, $loginbis);
65 $res = $globals->xdb
->iterator(
66 "SELECT a.alias AS homonyme,s.id AS user_id,s.alias AS forlife,
68 IF(h.homonyme_id=s.id, a.expire, NULL) AS expire,
69 IF(h.homonyme_id=s.id, a.type, NULL) AS type
71 LEFT JOIN homonymes AS h ON (h.homonyme_id = a.id)
72 INNER JOIN aliases AS s ON (s.id = h.user_id AND s.type='a_vie')
73 INNER JOIN auth_user_md5 AS u ON (s.id=u.user_id)
74 WHERE a.type='homonyme' OR a.expire!=''
75 ORDER BY a.alias,promo");
77 while ($tab = $res->next()) {
78 $hnymes[$tab['homonyme']][] = $tab;
80 $page->assign_by_ref('hnymes',$hnymes);