Remove xnet manuel... ==> wiki
[platal.git] / modules / xnet.php
CommitLineData
bd4be95d 1<?php
2/***************************************************************************
3 * Copyright (C) 2003-2006 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
22class XnetModule extends PLModule
23{
24 function handlers()
25 {
26 return array(
71fe935c 27 'index' => $this->make_hook('index', AUTH_PUBLIC),
28 'exit' => $this->make_hook('exit', AUTH_PUBLIC),
29
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),
71fe935c 35
d55888e6 36 'admin' => $this->make_hook('admin', AUTH_MDP, 'admin'),
0e02493e 37 'groups' => $this->make_hook('groups', AUTH_PUBLIC),
38 'groupes.php' => $this->make_hook('groups2', AUTH_PUBLIC),
71fe935c 39 'plan' => $this->make_hook('plan', AUTH_PUBLIC),
bd4be95d 40 );
41 }
42
43 function handler_index(&$page)
44 {
45 $page->changeTpl('xnet/index.tpl');
bd4be95d 46 }
045a1522 47
71fe935c 48 function handler_exit(&$page)
49 {
50 XnetSession::destroy();
51 $page->changeTpl('xnet/deconnexion.tpl');
52 $page->useMenu();
71fe935c 53 }
54
045a1522 55 function handler_about(&$page)
56 {
57 $page->changeTpl('xnet/apropos.tpl');
58 $page->useMenu();
71fe935c 59 }
60
61 function handler_article12(&$page)
62 {
63 $page->changeTpl('xnet/article12.tpl');
64 $page->useMenu();
71fe935c 65 }
66
67 function handler_article16(&$page)
68 {
69 $page->changeTpl('xnet/article16.tpl');
70 $page->useMenu();
71fe935c 71 }
72
73 function handler_creategpx(&$page)
74 {
75 $page->changeTpl('xnet/creation-groupex.tpl');
76 $page->useMenu();
71fe935c 77 }
78
883ae44b 79 function handler_services(&$page)
71fe935c 80 {
81 $page->changeTpl('xnet/services.tpl');
82 $page->useMenu();
71fe935c 83 }
84
d55888e6 85 function handler_admin(&$page)
86 {
d55888e6 87 new_admin_page('xnet/admin.tpl');
88 $page->useMenu();
89
90 if (Get::has('del')) {
08cce2ff 91 $res = XDB::query('SELECT id, nom, mail_domain
d55888e6 92 FROM groupex.asso WHERE diminutif={?}',
5e2307dc 93 Get::v('del'));
d55888e6 94 list($id, $nom, $domain) = $res->fetchOneRow();
95 $page->assign('nom', $nom);
96 if ($id && Post::has('del')) {
08cce2ff 97 XDB::query('DELETE FROM groupex.membres WHERE asso_id={?}', $id);
d55888e6 98 $page->trig('membres supprimés');
99
100 if ($domain) {
08cce2ff 101 XDB::query('DELETE FROM virtual_domains WHERE domain={?}', $domain);
102 XDB::query('DELETE FROM virtual, virtual_redirect
d55888e6 103 USING virtual INNER JOIN virtual_redirect USING (vid)
104 WHERE alias LIKE {?}', '%@'.$domain);
105 $page->trig('suppression des alias mails');
106
107 require_once('lists.inc.php');
cab08090 108 $client =& lists_xmlrpc(S::v('uid'), S::v('password'), $domain);
d55888e6 109 if ($listes = $client->get_lists()) {
110 foreach ($listes as $l) {
111 $client->delete_list($l['list'], true);
112 }
113 $page->trig('mail lists surpprimées');
114 }
115 }
116
08cce2ff 117 XDB::query('DELETE FROM groupex.asso WHERE id={?}', $id);
d55888e6 118 $page->trig("Groupe $nom supprimé");
119 Get::kill('del');
120 }
121 if (!$id) {
122 Get::kill('del');
123 }
124 }
125
126 if (Post::has('diminutif')) {
08cce2ff 127 XDB::query('INSERT INTO groupex.asso (id,diminutif)
5e2307dc 128 VALUES(NULL,{?})', Post::v('diminutif'));
129 pl_redirect('../'.Post::v('diminutif').'/edit');
d55888e6 130 }
131
08cce2ff 132 $res = XDB::query('SELECT nom,diminutif FROM groupex.asso ORDER by NOM');
d55888e6 133 $page->assign('assos', $res->fetchAllAssoc());
134 }
135
71fe935c 136 function handler_plan(&$page)
137 {
71fe935c 138 $page->changeTpl('xnet/plan.tpl');
139
140 $page->setType('plan');
141
08cce2ff 142 $res = XDB::iterator(
71fe935c 143 'SELECT dom.id, dom.nom as domnom, asso.diminutif, asso.nom
144 FROM groupex.dom
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');
148 $groupesx = array();
149 while ($tmp = $res->next()) { $groupesx[$tmp['id']][] = $tmp; }
150 $page->assign('groupesx', $groupesx);
151
08cce2ff 152 $res = XDB::iterator(
71fe935c 153 'SELECT dom.id, dom.nom as domnom, asso.diminutif, asso.nom
154 FROM groupex.dom
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');
158 $binets = array();
159 while ($tmp = $res->next()) { $binets[$tmp['id']][] = $tmp; }
160 $page->assign('binets', $binets);
161
08cce2ff 162 $res = XDB::iterator(
71fe935c 163 'SELECT asso.diminutif, asso.nom
164 FROM groupex.asso
165 WHERE cat LIKE "%Promotions%"
166 ORDER BY diminutif');
167 $page->assign('promos', $res);
168
08cce2ff 169 $res = XDB::iterator(
71fe935c 170 'SELECT asso.diminutif, asso.nom
171 FROM groupex.asso
172 WHERE FIND_IN_SET("Institutions", cat)
173 ORDER BY diminutif');
174 $page->assign('inst', $res);
6fb8424a 175 $page->useMenu();
045a1522 176 }
0e02493e 177
178 function handler_groups2(&$page)
179 {
5e2307dc 180 $this->handler_groups(&$page, Get::v('cat'), Get::v('dom'));
0e02493e 181 }
182
183 function handler_groups(&$page, $cat = null, $dom = null)
184 {
0e02493e 185 if (!$cat) {
186 $this->handler_index(&$page);
187 }
188
189 $cat = strtolower($cat);
190
191 $page->changeTpl('xnet/groupes.tpl');
192 $page->assign('cat', $cat);
193 $page->assign('dom', $dom);
194
08cce2ff 195 $res = XDB::query("SELECT id,nom FROM groupex.dom
f0430dc7 196 WHERE FIND_IN_SET({?}, cat)
197 ORDER BY nom", $cat);
0e02493e 198 $doms = $res->fetchAllAssoc();
199 $page->assign('doms', $doms);
200
201 if (empty($doms)) {
f0430dc7 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());
0e02493e 206 } elseif (!is_null($dom)) {
f0430dc7 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());
0e02493e 211 }
0e02493e 212
213 $page->useMenu();
214 $page->setType($cat);
215 }
bd4be95d 216}
217
218?>