2 /***************************************************************************
3 * Copyright (C) 2003-2006 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 $page->assign('xorg_title','Polytechnique.org - Administration - Homonymes');
25 require_once("homonymes.inc.php");
27 $op = Env
::get('op', 'list');
28 $target = Env
::getInt('target');
31 if (! list($prenom,$nom,$forlife,$loginbis) = select_if_homonyme($target)) {
34 $page->assign('nom',$nom);
35 $page->assign('prenom',$prenom);
36 $page->assign('forlife',$forlife);
37 $page->assign('loginbis',$loginbis);
41 $page->assign('op',$op);
42 $page->assign('target',$target);
43 $page->assign('baseurl',$globals->baseurl
);
45 // on a un $target valide, on prepare les mails
48 // on examine l'op a effectuer
51 send_warning_homonyme($prenom, $nom, $forlife, $loginbis);
52 switch_bestalias($target, $loginbis);
56 switch_bestalias($target, $loginbis);
57 $globals->xdb
->execute("UPDATE aliases SET type='homonyme',expire=NOW() WHERE alias={?}", $loginbis);
58 $globals->xdb
->execute("REPLACE INTO homonymes (homonyme_id,user_id) VALUES({?},{?})", $target, $target);
59 send_robot_homonyme($prenom, $nom, $forlife, $loginbis);
66 $res = $globals->xdb
->iterator(
67 "SELECT a.alias AS homonyme,s.id AS user_id,s.alias AS forlife,
69 IF(h.homonyme_id=s.id, a.expire, NULL) AS expire,
70 IF(h.homonyme_id=s.id, a.type, NULL) AS type
72 LEFT JOIN homonymes AS h ON (h.homonyme_id = a.id)
73 INNER JOIN aliases AS s ON (s.id = h.user_id AND s.type='a_vie')
74 INNER JOIN auth_user_md5 AS u ON (s.id=u.user_id)
75 WHERE a.type='homonyme' OR a.expire!=''
76 ORDER BY a.alias,promo");
78 while ($tab = $res->next()) {
79 $hnymes[$tab['homonyme']][] = $tab;
81 $page->assign_by_ref('hnymes',$hnymes);