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');
90 $page->assign('type', $type);
93 function handler_admin(&$page)
95 new_admin_page('xnet/admin.tpl');
98 if (Get
::has('del')) {
99 $res = XDB
::query('SELECT id, nom, mail_domain
100 FROM groupex.asso WHERE diminutif={?}',
102 list($id, $nom, $domain) = $res->fetchOneRow();
103 $page->assign('nom', $nom);
104 if ($id && Post
::has('del')) {
105 XDB
::query('DELETE FROM groupex.membres WHERE asso_id={?}', $id);
106 $page->trig('membres supprimés');
109 XDB
::query('DELETE FROM virtual_domains WHERE domain={?}', $domain);
110 XDB
::query('DELETE FROM virtual, virtual_redirect
111 USING virtual INNER JOIN virtual_redirect USING (vid)
112 WHERE alias LIKE {?}', '%@'.$domain);
113 $page->trig('suppression des alias mails');
115 require_once('lists.inc.php');
116 $client =& lists_xmlrpc(S
::v('uid'), S
::v('password'), $domain);
117 if ($listes = $client->get_lists()) {
118 foreach ($listes as $l) {
119 $client->delete_list($l['list'], true
);
121 $page->trig('mail lists surpprimées');
125 XDB
::query('DELETE FROM groupex.asso WHERE id={?}', $id);
126 $page->trig("Groupe $nom supprimé");
134 if (Post
::has('diminutif')) {
135 XDB
::query('INSERT INTO groupex.asso (id,diminutif)
136 VALUES(NULL,{?})', Post
::v('diminutif'));
137 pl_redirect('../'.Post
::v('diminutif').'/edit');
140 $res = XDB
::query('SELECT nom,diminutif FROM groupex.asso ORDER by NOM');
141 $page->assign('assos', $res->fetchAllAssoc());
144 function handler_plan(&$page)
146 $page->changeTpl('xnet/plan.tpl');
148 $page->setType('plan');
150 $res = XDB
::iterator(
151 'SELECT dom.id, dom.nom as domnom, asso.diminutif, asso.nom
153 INNER JOIN groupex.asso ON dom.id = asso.dom
154 WHERE FIND_IN_SET("GroupesX", dom.cat) AND FIND_IN_SET("GroupesX", asso.cat)
155 ORDER BY dom.nom, asso.nom');
157 while ($tmp = $res->next()) { $groupesx[$tmp['id']][] = $tmp; }
158 $page->assign('groupesx', $groupesx);
160 $res = XDB
::iterator(
161 'SELECT dom.id, dom.nom as domnom, asso.diminutif, asso.nom
163 INNER JOIN groupex.asso ON dom.id = asso.dom
164 WHERE FIND_IN_SET("Binets", dom.cat) AND FIND_IN_SET("Binets", asso.cat)
165 ORDER BY dom.nom, asso.nom');
167 while ($tmp = $res->next()) { $binets[$tmp['id']][] = $tmp; }
168 $page->assign('binets', $binets);
170 $res = XDB
::iterator(
171 'SELECT asso.diminutif, asso.nom
173 WHERE cat LIKE "%Promotions%"
174 ORDER BY diminutif');
175 $page->assign('promos', $res);
177 $res = XDB
::iterator(
178 'SELECT asso.diminutif, asso.nom
180 WHERE FIND_IN_SET("Institutions", cat)
181 ORDER BY diminutif');
182 $page->assign('inst', $res);
185 function handler_groups2(&$page)
187 $this->handler_groups(&$page, Get
::v('cat'), Get
::v('dom'));
190 function handler_groups(&$page, $cat = null
, $dom = null
)
193 $this->handler_index(&$page);
196 $cat = strtolower($cat);
198 $page->changeTpl('xnet/groupes.tpl');
199 $page->assign('cat', $cat);
200 $page->assign('dom', $dom);
202 $res = XDB
::query("SELECT id,nom FROM groupex.dom
203 WHERE FIND_IN_SET({?}, cat) ORDER BY nom", $cat);
204 $doms = $res->fetchAllAssoc();
205 $page->assign('doms', $doms);
208 $res = XDB
::iterator("SELECT diminutif, nom FROM groupex.asso
209 WHERE FIND_IN_SET({?}, cat) ORDER BY nom", $cat);
210 } elseif (!is_null($dom)) {
211 $res = XDB
::iterator("SELECT diminutif, nom FROM groupex.asso
212 WHERE FIND_IN_SET({?}, cat) AND dom={?}
213 ORDER BY nom", $cat, $dom);
217 $page->assign('gps', $res);
220 $page->setType($cat);