Bug 130: Les pages ont toutes un titre different.
[platal.git] / htdocs / admin / homonymes.php
CommitLineData
0337d704 1<?php
2/***************************************************************************
3 * Copyright (C) 2003-2004 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
22require_once("xorg.inc.php");
23new_admin_page('admin/homonymes.tpl');
d9a33f98 24$page->assign('xorg_title','Polytechnique.org - Administration - Homonymes');
0337d704 25require_once("homonymes.inc.php");
26
27$op = Env::get('op', 'list');
28$target = Env::getInt('target');
29
30if ($target) {
31 if (! list($prenom,$nom,$forlife,$loginbis) = select_if_homonyme($target)) {
32 $target=0;
33 } else {
34 $page->assign('nom',$nom);
35 $page->assign('prenom',$prenom);
36 $page->assign('forlife',$forlife);
37 $page->assign('loginbis',$loginbis);
38 }
39}
40
41$page->assign('op',$op);
42$page->assign('target',$target);
43$page->assign('baseurl',$globals->baseurl);
44
45// on a un $target valide, on prepare les mails
46if ($target) {
47
48 // on examine l'op a effectuer
49 switch ($op) {
50 case 'mail':
51 send_warning_homonyme($prenom, $nom, $forlife, $loginbis);
52 switch_bestalias($target, $loginbis);
53 $op = 'list';
54 break;
55 case 'correct':
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);
60 $op = 'list';
61 break;
62 }
63}
64
65if ($op == 'list') {
66 $res = $globals->xdb->iterator(
67 "SELECT a.alias AS homonyme,s.id AS user_id,s.alias AS forlife,
68 promo,prenom,nom,
69 IF(h.homonyme_id=s.id, a.expire, NULL) AS expire,
70 IF(h.homonyme_id=s.id, a.type, NULL) AS type
71 FROM aliases AS a
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");
77 $hnymes = Array();
78 while ($tab = $res->next()) {
79 $hnymes[$tab['homonyme']][] = $tab;
80 }
81 $page->assign_by_ref('hnymes',$hnymes);
82}
83
84$page->run();
85?>