bug 420, nom d'epouse sur le trombi promo
[platal.git] / htdocs / trombipromo.php
1 <?php
2 /***************************************************************************
3 * Copyright (C) 2003-2006 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 require_once("xorg.inc.php");
23 new_skinned_page('trombipromo.tpl', AUTH_COOKIE);
24 require_once("trombi.inc.php");
25 $page->assign('xorg_title','Polytechnique.org - Trombi Promo');
26
27 function getList($offset,$limit) {
28 global $globals;
29
30 $xpromo = Env::getInt('xpromo');
31 $where = ( $xpromo>0 ? "WHERE promo='$xpromo'" : "" );
32
33 $res = $globals->xdb->query(
34 "SELECT COUNT(*)
35 FROM auth_user_md5 AS u
36 RIGHT JOIN photo AS p ON u.user_id=p.uid
37 $where");
38 $pnb = $res->fetchOneCell();
39
40 $res = $globals->xdb->query(
41 "SELECT promo,user_id,a.alias AS forlife,IF(nom_usage='', nom, nom_usage) AS nom,prenom
42 FROM photo AS p
43 INNER JOIN auth_user_md5 AS u ON u.user_id=p.uid
44 INNER JOIN aliases AS a ON ( u.user_id=a.id AND a.type='a_vie' )
45 $where
46 ORDER BY promo,nom,prenom LIMIT {?}, {?}", $offset*$limit, $limit);
47
48 return Array($pnb, $res->fetchAllAssoc());
49 }
50
51 if (Env::has('xpromo')) {
52 $xpromo = Env::getInt('xpromo');
53
54 if ( $xpromo<1900 || $xpromo>date('Y') || ($xpromo == -1 && Session::get('perms')!="admin") ) {
55 $page->trig("Promotion incorrecte (saisir au format YYYY). Recommence.");
56 $page->assign('error', true);
57 } else {
58 $trombi = new Trombi('getList');
59 $trombi->hidePromo();
60 $trombi->setAdmin();
61 $page->assign_by_ref('trombi',$trombi);
62 }
63 } else {
64 $tmp = new Trombi();
65 $page->assign("limit", $tmp->limit);
66 }
67
68 $page->run();
69
70 ?>