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