7d8b17cb |
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 | class ProfileModule extends PLModule |
23 | { |
24 | function handlers() |
25 | { |
26 | return array( |
27 | 'trombi' => $this->make_hook('trombi', AUTH_COOKIE), |
28 | ); |
29 | } |
30 | |
31 | function _trombi_getlist($offset, $limit) |
32 | { |
33 | global $globals; |
34 | |
35 | $where = ( $this->promo > 0 ? "WHERE promo='{$this->promo}'" : "" ); |
36 | |
37 | $res = $globals->xdb->query( |
38 | "SELECT COUNT(*) |
39 | FROM auth_user_md5 AS u |
40 | RIGHT JOIN photo AS p ON u.user_id=p.uid |
41 | $where"); |
42 | $pnb = $res->fetchOneCell(); |
43 | |
44 | $res = $globals->xdb->query( |
45 | "SELECT promo,user_id,a.alias AS forlife,IF(nom_usage='', nom, nom_usage) AS nom,prenom |
46 | FROM photo AS p |
47 | INNER JOIN auth_user_md5 AS u ON u.user_id=p.uid |
48 | INNER JOIN aliases AS a ON ( u.user_id=a.id AND a.type='a_vie' ) |
49 | $where |
50 | ORDER BY promo,nom,prenom LIMIT {?}, {?}", $offset*$limit, $limit); |
51 | |
52 | return array($pnb, $res->fetchAllAssoc()); |
53 | } |
54 | |
55 | function handler_trombi(&$page, $promo = null) |
56 | { |
57 | require_once 'trombi.inc.php'; |
58 | |
59 | $page->changeTpl('trombipromo.tpl'); |
60 | $page->assign('xorg_title','Polytechnique.org - Trombi Promo'); |
61 | |
62 | if (is_null($promo)) { |
63 | return PL_OK; |
64 | } |
65 | |
66 | $this->promo = $promo = intval($promo); |
67 | |
68 | if ($promo >= 1900 && $promo < intval(date('Y')) |
69 | || ($promo == -1 && has_perms())) |
70 | { |
71 | $trombi = new Trombi(array($this, '_trombi_getlist')); |
72 | $trombi->hidePromo(); |
73 | $trombi->setAdmin(); |
74 | $page->assign_by_ref('trombi', $trombi); |
75 | } else { |
76 | $page->trig('Promotion incorrecte (saisir au format YYYY). Recommence.'); |
77 | } |
78 | |
79 | return PL_OK; |
80 | } |
81 | } |
82 | |
83 | ?> |