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
),
36 'admin' => $this->make_hook('admin', AUTH_MDP
, 'admin'),
37 'groups' => $this->make_hook('groups', AUTH_PUBLIC
),
38 'groupes.php' => $this->make_hook('groups2', AUTH_PUBLIC
),
39 'plan' => $this->make_hook('plan', AUTH_PUBLIC
),
43 function handler_index(&$page)
45 $page->changeTpl('xnet/index.tpl');
48 function handler_exit(&$page)
50 XnetSession
::destroy();
51 $page->changeTpl('xnet/deconnexion.tpl');
55 function handler_about(&$page)
57 $page->changeTpl('xnet/apropos.tpl');
61 function handler_article12(&$page)
63 $page->changeTpl('xnet/article12.tpl');
67 function handler_article16(&$page)
69 $page->changeTpl('xnet/article16.tpl');
73 function handler_creategpx(&$page)
75 $page->changeTpl('xnet/creation-groupex.tpl');
79 function handler_services(&$page)
81 $page->changeTpl('xnet/services.tpl');
85 function handler_admin(&$page)
87 new_admin_page('xnet/admin.tpl');
90 if (Get
::has('del')) {
91 $res = XDB
::query('SELECT id, nom, mail_domain
92 FROM groupex.asso WHERE diminutif={?}',
94 list($id, $nom, $domain) = $res->fetchOneRow();
95 $page->assign('nom', $nom);
96 if ($id && Post
::has('del')) {
97 XDB
::query('DELETE FROM groupex.membres WHERE asso_id={?}', $id);
98 $page->trig('membres supprimés');
101 XDB
::query('DELETE FROM virtual_domains WHERE domain={?}', $domain);
102 XDB
::query('DELETE FROM virtual, virtual_redirect
103 USING virtual INNER JOIN virtual_redirect USING (vid)
104 WHERE alias LIKE {?}', '%@'.$domain);
105 $page->trig('suppression des alias mails');
107 require_once('lists.inc.php');
108 $client =& lists_xmlrpc(S
::v('uid'), S
::v('password'), $domain);
109 if ($listes = $client->get_lists()) {
110 foreach ($listes as $l) {
111 $client->delete_list($l['list'], true
);
113 $page->trig('mail lists surpprimées');
117 XDB
::query('DELETE FROM groupex.asso WHERE id={?}', $id);
118 $page->trig("Groupe $nom supprimé");
126 if (Post
::has('diminutif')) {
127 XDB
::query('INSERT INTO groupex.asso (id,diminutif)
128 VALUES(NULL,{?})', Post
::v('diminutif'));
129 pl_redirect('../'.Post
::v('diminutif').'/edit');
132 $res = XDB
::query('SELECT nom,diminutif FROM groupex.asso ORDER by NOM');
133 $page->assign('assos', $res->fetchAllAssoc());
136 function handler_plan(&$page)
138 $page->changeTpl('xnet/plan.tpl');
140 $page->setType('plan');
142 $res = XDB
::iterator(
143 'SELECT dom.id, dom.nom as domnom, asso.diminutif, asso.nom
145 INNER JOIN groupex.asso ON dom.id = asso.dom
146 WHERE FIND_IN_SET("GroupesX", dom.cat) AND FIND_IN_SET("GroupesX", asso.cat)
147 ORDER BY dom.nom, asso.nom');
149 while ($tmp = $res->next()) { $groupesx[$tmp['id']][] = $tmp; }
150 $page->assign('groupesx', $groupesx);
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("Binets", dom.cat) AND FIND_IN_SET("Binets", asso.cat)
157 ORDER BY dom.nom, asso.nom');
159 while ($tmp = $res->next()) { $binets[$tmp['id']][] = $tmp; }
160 $page->assign('binets', $binets);
162 $res = XDB
::iterator(
163 'SELECT asso.diminutif, asso.nom
165 WHERE cat LIKE "%Promotions%"
166 ORDER BY diminutif');
167 $page->assign('promos', $res);
169 $res = XDB
::iterator(
170 'SELECT asso.diminutif, asso.nom
172 WHERE FIND_IN_SET("Institutions", cat)
173 ORDER BY diminutif');
174 $page->assign('inst', $res);
178 function handler_groups2(&$page)
180 $this->handler_groups(&$page, Get
::v('cat'), Get
::v('dom'));
183 function handler_groups(&$page, $cat = null
, $dom = null
)
186 $this->handler_index(&$page);
189 $cat = strtolower($cat);
191 $page->changeTpl('xnet/groupes.tpl');
192 $page->assign('cat', $cat);
193 $page->assign('dom', $dom);
195 $res = XDB
::query("SELECT id,nom FROM groupex.dom
196 WHERE FIND_IN_SET({?}, cat)
197 ORDER BY nom", $cat);
198 $doms = $res->fetchAllAssoc();
199 $page->assign('doms', $doms);
202 $res = XDB
::query("SELECT diminutif, nom FROM groupex.asso
203 WHERE FIND_IN_SET({?}, cat)
204 ORDER BY nom", $cat);
205 $page->assign('gps', $res->fetchAllAssoc());
206 } elseif (!is_null($dom)) {
207 $res = XDB
::query("SELECT diminutif, nom FROM groupex.asso
208 WHERE FIND_IN_SET({?}, cat) AND dom={?}
209 ORDER BY nom", $cat, $dom);
210 $page->assign('gps', $res->fetchAllAssoc());
214 $page->setType($cat);