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 class XnetModule
extends PLModule
27 'index' => $this->make_hook('index', AUTH_PUBLIC
),
28 'exit' => $this->make_hook('exit', AUTH_PUBLIC
),
30 'about' => $this->make_hook('about', AUTH_PUBLIC
),
31 'article12' => $this->make_hook('article12', AUTH_PUBLIC
),
32 'article16' => $this->make_hook('article16', AUTH_PUBLIC
),
33 'creategpx' => $this->make_hook('creategpx', AUTH_PUBLIC
),
34 'services' => $this->make_hook('services', AUTH_PUBLIC
),
35 'manuel' => $this->make_hook('manuel', AUTH_PUBLIC
),
37 'admin' => $this->make_hook('admin', AUTH_MDP
, 'admin'),
38 'groups' => $this->make_hook('groups', AUTH_PUBLIC
),
39 'groupes.php' => $this->make_hook('groups2', AUTH_PUBLIC
),
40 'plan' => $this->make_hook('plan', AUTH_PUBLIC
),
44 function handler_index(&$page)
46 $page->changeTpl('xnet/index.tpl');
49 function handler_exit(&$page)
51 XnetSession
::destroy();
52 $page->changeTpl('xnet/deconnexion.tpl');
56 function handler_about(&$page)
58 $page->changeTpl('xnet/apropos.tpl');
62 function handler_article12(&$page)
64 $page->changeTpl('xnet/article12.tpl');
68 function handler_article16(&$page)
70 $page->changeTpl('xnet/article16.tpl');
74 function handler_creategpx(&$page)
76 $page->changeTpl('xnet/creation-groupex.tpl');
80 function handler_services(&$page)
82 $page->changeTpl('xnet/services.tpl');
86 function handler_manuel(&$page, $type = null
)
88 $page->changeTpl('xnet/manuel.tpl');
92 $page->assign('type', $type);
95 function handler_admin(&$page)
97 new_admin_page('xnet/admin.tpl');
100 if (Get
::has('del')) {
101 $res = XDB
::query('SELECT id, nom, mail_domain
102 FROM groupex.asso WHERE diminutif={?}',
104 list($id, $nom, $domain) = $res->fetchOneRow();
105 $page->assign('nom', $nom);
106 if ($id && Post
::has('del')) {
107 XDB
::query('DELETE FROM groupex.membres WHERE asso_id={?}', $id);
108 $page->trig('membres supprimés');
111 XDB
::query('DELETE FROM virtual_domains WHERE domain={?}', $domain);
112 XDB
::query('DELETE FROM virtual, virtual_redirect
113 USING virtual INNER JOIN virtual_redirect USING (vid)
114 WHERE alias LIKE {?}', '%@'.$domain);
115 $page->trig('suppression des alias mails');
117 require_once('lists.inc.php');
118 $client =& lists_xmlrpc(S
::v('uid'), S
::v('password'), $domain);
119 if ($listes = $client->get_lists()) {
120 foreach ($listes as $l) {
121 $client->delete_list($l['list'], true
);
123 $page->trig('mail lists surpprimées');
127 XDB
::query('DELETE FROM groupex.asso WHERE id={?}', $id);
128 $page->trig("Groupe $nom supprimé");
136 if (Post
::has('diminutif')) {
137 XDB
::query('INSERT INTO groupex.asso (id,diminutif)
138 VALUES(NULL,{?})', Post
::v('diminutif'));
139 pl_redirect('../'.Post
::v('diminutif').'/edit');
142 $res = XDB
::query('SELECT nom,diminutif FROM groupex.asso ORDER by NOM');
143 $page->assign('assos', $res->fetchAllAssoc());
146 function handler_plan(&$page)
148 $page->changeTpl('xnet/plan.tpl');
150 $page->setType('plan');
152 $res = XDB
::iterator(
153 'SELECT dom.id, dom.nom as domnom, asso.diminutif, asso.nom
155 INNER JOIN groupex.asso ON dom.id = asso.dom
156 WHERE FIND_IN_SET("GroupesX", dom.cat) AND FIND_IN_SET("GroupesX", asso.cat)
157 ORDER BY dom.nom, asso.nom');
159 while ($tmp = $res->next()) { $groupesx[$tmp['id']][] = $tmp; }
160 $page->assign('groupesx', $groupesx);
162 $res = XDB
::iterator(
163 'SELECT dom.id, dom.nom as domnom, asso.diminutif, asso.nom
165 INNER JOIN groupex.asso ON dom.id = asso.dom
166 WHERE FIND_IN_SET("Binets", dom.cat) AND FIND_IN_SET("Binets", asso.cat)
167 ORDER BY dom.nom, asso.nom');
169 while ($tmp = $res->next()) { $binets[$tmp['id']][] = $tmp; }
170 $page->assign('binets', $binets);
172 $res = XDB
::iterator(
173 'SELECT asso.diminutif, asso.nom
175 WHERE cat LIKE "%Promotions%"
176 ORDER BY diminutif');
177 $page->assign('promos', $res);
179 $res = XDB
::iterator(
180 'SELECT asso.diminutif, asso.nom
182 WHERE FIND_IN_SET("Institutions", cat)
183 ORDER BY diminutif');
184 $page->assign('inst', $res);
188 function handler_groups2(&$page)
190 $this->handler_groups(&$page, Get
::v('cat'), Get
::v('dom'));
193 function handler_groups(&$page, $cat = null
, $dom = null
)
196 $this->handler_index(&$page);
199 $cat = strtolower($cat);
201 $page->changeTpl('xnet/groupes.tpl');
202 $page->assign('cat', $cat);
203 $page->assign('dom', $dom);
205 $res = XDB
::query("SELECT id,nom FROM groupex.dom
206 WHERE FIND_IN_SET({?}, cat) ORDER BY nom", $cat);
207 $doms = $res->fetchAllAssoc();
208 $page->assign('doms', $doms);
211 $res = XDB
::iterator("SELECT diminutif, nom FROM groupex.asso
212 WHERE FIND_IN_SET({?}, cat) ORDER BY nom", $cat);
213 } elseif (!is_null($dom)) {
214 $res = XDB
::iterator("SELECT diminutif, nom FROM groupex.asso
215 WHERE FIND_IN_SET({?}, cat) AND dom={?}
216 ORDER BY nom", $cat, $dom);
220 $page->assign('gps', $res);
223 $page->setType($cat);