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