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 'login' => $this->make_hook('login', AUTH_MDP
),
29 'exit' => $this->make_hook('exit', AUTH_PUBLIC
),
31 'admin' => $this->make_hook('admin', AUTH_MDP
, 'admin'),
32 'groups' => $this->make_hook('groups', AUTH_PUBLIC
),
33 'groupes.php' => $this->make_hook('groups2', AUTH_PUBLIC
),
34 'plan' => $this->make_hook('plan', AUTH_PUBLIC
),
35 'send_bug' => $this->make_hook('bug', AUTH_MDP
),
39 function handler_bug(&$page)
41 $this->handler_index(&$page);
42 $page->assign('bug', 1);
45 function handler_index(&$page)
48 $page->changeTpl('xnet/index.tpl');
51 function handler_login(&$page)
53 $allkeys = func_get_args();
55 $url = join('/',$allkeys);
59 function handler_exit(&$page)
61 XnetSession
::destroy();
62 $page->changeTpl('xnet/deconnexion.tpl');
65 function handler_admin(&$page)
67 new_admin_page('xnet/admin.tpl');
69 if (Get
::has('del')) {
70 $res = XDB
::query('SELECT id, nom, mail_domain
71 FROM groupex.asso WHERE diminutif={?}',
73 list($id, $nom, $domain) = $res->fetchOneRow();
74 $page->assign('nom', $nom);
75 if ($id && Post
::has('del')) {
76 XDB
::query('DELETE FROM groupex.membres WHERE asso_id={?}', $id);
77 $page->trig('membres supprimés');
80 XDB
::query('DELETE FROM virtual_domains WHERE domain={?}', $domain);
81 XDB
::query('DELETE FROM virtual, virtual_redirect
82 USING virtual INNER JOIN virtual_redirect USING (vid)
83 WHERE alias LIKE {?}', '%@'.$domain);
84 $page->trig('suppression des alias mails');
86 $mmlist = new MMList(S
::v('uid'), S
::v('password'), $domain);
87 if ($listes = $mmlist->get_lists()) {
88 foreach ($listes as $l) {
89 $mmlist->delete_list($l['list'], true
);
91 $page->trig('mail lists surpprimées');
95 XDB
::query('DELETE FROM groupex.asso WHERE id={?}', $id);
96 $page->trig("Groupe $nom supprimé");
104 if (Post
::has('diminutif')) {
105 XDB
::query('INSERT INTO groupex.asso (id,diminutif)
106 VALUES(NULL,{?})', Post
::v('diminutif'));
107 pl_redirect('../'.Post
::v('diminutif').'/edit');
110 $res = XDB
::query('SELECT nom,diminutif FROM groupex.asso ORDER by NOM');
111 $page->assign('assos', $res->fetchAllAssoc());
114 function handler_plan(&$page)
116 $page->changeTpl('xnet/plan.tpl');
118 $page->setType('plan');
120 $res = XDB
::iterator(
121 'SELECT dom.id, dom.nom as domnom, asso.diminutif, asso.nom
123 INNER JOIN groupex.asso ON dom.id = asso.dom
124 WHERE FIND_IN_SET("GroupesX", dom.cat) AND FIND_IN_SET("GroupesX", asso.cat)
125 ORDER BY dom.nom, asso.nom');
127 while ($tmp = $res->next()) { $groupesx[$tmp['id']][] = $tmp; }
128 $page->assign('groupesx', $groupesx);
130 $res = XDB
::iterator(
131 'SELECT dom.id, dom.nom as domnom, asso.diminutif, asso.nom
133 INNER JOIN groupex.asso ON dom.id = asso.dom
134 WHERE FIND_IN_SET("Binets", dom.cat) AND FIND_IN_SET("Binets", asso.cat)
135 ORDER BY dom.nom, asso.nom');
137 while ($tmp = $res->next()) { $binets[$tmp['id']][] = $tmp; }
138 $page->assign('binets', $binets);
140 $res = XDB
::iterator(
141 'SELECT asso.diminutif, asso.nom
143 WHERE cat LIKE "%Promotions%"
144 ORDER BY diminutif');
145 $page->assign('promos', $res);
147 $res = XDB
::iterator(
148 'SELECT asso.diminutif, asso.nom
150 WHERE FIND_IN_SET("Institutions", cat)
151 ORDER BY diminutif');
152 $page->assign('inst', $res);
155 function handler_groups2(&$page)
157 $this->handler_groups(&$page, Get
::v('cat'), Get
::v('dom'));
160 function handler_groups(&$page, $cat = null
, $dom = null
)
163 $this->handler_index(&$page);
166 $cat = strtolower($cat);
168 $page->changeTpl('xnet/groupes.tpl');
169 $page->assign('cat', $cat);
170 $page->assign('dom', $dom);
172 $res = XDB
::query("SELECT id,nom FROM groupex.dom
173 WHERE FIND_IN_SET({?}, cat)
174 ORDER BY nom", $cat);
175 $doms = $res->fetchAllAssoc();
176 $page->assign('doms', $doms);
179 $res = XDB
::query("SELECT diminutif, nom, site FROM groupex.asso
180 WHERE FIND_IN_SET({?}, cat)
181 ORDER BY nom", $cat);
182 $page->assign('gps', $res->fetchAllAssoc());
183 } elseif (!is_null($dom)) {
184 $res = XDB
::query("SELECT diminutif, nom, site FROM groupex.asso
185 WHERE FIND_IN_SET({?}, cat) AND dom={?}
186 ORDER BY nom", $cat, $dom);
187 $page->assign('gps', $res->fetchAllAssoc());
190 $page->setType($cat);