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');
89 $page->assign('type', $type);
92 function handler_admin(&$page)
94 new_admin_page('xnet/admin.tpl');
97 if (Get
::has('del')) {
98 $res = XDB
::query('SELECT id, nom, mail_domain
99 FROM groupex.asso WHERE diminutif={?}',
101 list($id, $nom, $domain) = $res->fetchOneRow();
102 $page->assign('nom', $nom);
103 if ($id && Post
::has('del')) {
104 XDB
::query('DELETE FROM groupex.membres WHERE asso_id={?}', $id);
105 $page->trig('membres supprimés');
108 XDB
::query('DELETE FROM virtual_domains WHERE domain={?}', $domain);
109 XDB
::query('DELETE FROM virtual, virtual_redirect
110 USING virtual INNER JOIN virtual_redirect USING (vid)
111 WHERE alias LIKE {?}', '%@'.$domain);
112 $page->trig('suppression des alias mails');
114 require_once('lists.inc.php');
115 $client =& lists_xmlrpc(S
::v('uid'), S
::v('password'), $domain);
116 if ($listes = $client->get_lists()) {
117 foreach ($listes as $l) {
118 $client->delete_list($l['list'], true
);
120 $page->trig('mail lists surpprimées');
124 XDB
::query('DELETE FROM groupex.asso WHERE id={?}', $id);
125 $page->trig("Groupe $nom supprimé");
133 if (Post
::has('diminutif')) {
134 XDB
::query('INSERT INTO groupex.asso (id,diminutif)
135 VALUES(NULL,{?})', Post
::v('diminutif'));
136 pl_redirect('../'.Post
::v('diminutif').'/edit');
139 $res = XDB
::query('SELECT nom,diminutif FROM groupex.asso ORDER by NOM');
140 $page->assign('assos', $res->fetchAllAssoc());
143 function handler_plan(&$page)
145 $page->changeTpl('xnet/plan.tpl');
147 $page->setType('plan');
149 $res = XDB
::iterator(
150 'SELECT dom.id, dom.nom as domnom, asso.diminutif, asso.nom
152 INNER JOIN groupex.asso ON dom.id = asso.dom
153 WHERE FIND_IN_SET("GroupesX", dom.cat) AND FIND_IN_SET("GroupesX", asso.cat)
154 ORDER BY dom.nom, asso.nom');
156 while ($tmp = $res->next()) { $groupesx[$tmp['id']][] = $tmp; }
157 $page->assign('groupesx', $groupesx);
159 $res = XDB
::iterator(
160 'SELECT dom.id, dom.nom as domnom, asso.diminutif, asso.nom
162 INNER JOIN groupex.asso ON dom.id = asso.dom
163 WHERE FIND_IN_SET("Binets", dom.cat) AND FIND_IN_SET("Binets", asso.cat)
164 ORDER BY dom.nom, asso.nom');
166 while ($tmp = $res->next()) { $binets[$tmp['id']][] = $tmp; }
167 $page->assign('binets', $binets);
169 $res = XDB
::iterator(
170 'SELECT asso.diminutif, asso.nom
172 WHERE cat LIKE "%Promotions%"
173 ORDER BY diminutif');
174 $page->assign('promos', $res);
176 $res = XDB
::iterator(
177 'SELECT asso.diminutif, asso.nom
179 WHERE FIND_IN_SET("Institutions", cat)
180 ORDER BY diminutif');
181 $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);