use sesion_write_close before redirects ... should solve some login problems user...
[platal.git] / htdocs / listes / trombi.php
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
22 require_once("xorg.inc.php");
23 if (!Env::has('liste')) redirect('index.php');
24 $liste = strtolower(Env::get('liste'));
25
26 new_skinned_page('listes/trombi.tpl', AUTH_COOKIE);
27 require_once("trombi.inc.php");
28 require_once('lists.inc.php');
29
30 $client =& lists_xmlrpc(Session::getInt('uid'), Session::get('password'));
31
32 if(Get::has('del')) {
33 $client->unsubscribe($liste);
34 redirect("{$_SERVER['PHP_SELF']}?liste=$liste");
35 }
36 if(Get::has('add')) {
37 $client->subscribe($liste);
38 redirect("{$_SERVER['PHP_SELF']}?liste=$liste");
39 }
40
41 function getList($offset,$limit)
42 {
43 global $client, $globals;
44 $liste = Env::get('liste');
45 list($total,$members) = $client->get_members_limit($liste,$offset,$limit);
46
47 $membres = Array();
48 foreach ($members as $member) {
49 list($m) = explode('@',$member[1]);
50 $res = $globals->xdb->query("SELECT prenom,IF(nom_usage='', nom, nom_usage) AS nom, promo, a.alias AS forlife
51 FROM auth_user_md5 AS u
52 INNER JOIN aliases AS a ON u.user_id = a.id
53 WHERE a.alias = {?}", $m);
54 if ($tmp = $res->fetchOneAssoc()) {
55 $membres[$tmp['nom']] = $tmp;
56 } else {
57 $membres[$member[0]] = Array('addr' => $member[0]);
58 }
59 }
60 return Array($total,$membres);
61 }
62
63 $owners = $client->get_owners($liste);
64
65 if(is_array($owners)) {
66 $moderos = list_sort_owners($owners[1]);
67
68 $page->assign_by_ref('details', $owners[0]);
69 $page->assign_by_ref('owners', $moderos);
70
71 $trombi = new Trombi('getList');
72 $page->assign_by_ref('trombi',$trombi);
73 } else {
74 $page->kill("La liste n'existe pas ou tu n'as pas le droit d'en voir les détails");
75 }
76
77 $page->run();
78 ?>