7d73eb286b777f7f3a8f49c3c130fa1e783dab3c
2 /***************************************************************************
3 * Copyright (C) 2003-2007 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 'admin' => $this->make_hook('admin', AUTH_MDP
, 'admin'),
31 'groups' => $this->make_hook('groups', AUTH_PUBLIC
),
32 'groupes.php' => $this->make_hook('groups2', AUTH_PUBLIC
),
33 'plan' => $this->make_hook('plan', AUTH_PUBLIC
),
34 'photo' => $this->make_hook('photo', AUTH_MDP
),
38 function handler_photo(&$page, $x = null
)
44 $res = XDB
::query("SELECT attachmime, attach
46 INNER JOIN photo ON(id = uid)
47 WHERE alias = {?}", $x);
49 if ((list($type, $data) = $res->fetchOneRow())) {
50 Header("Content-type: image/$type");
53 Header('Content-type: image/png');
54 echo file_get_contents(dirname(__FILE__
).'/../htdocs/images/none.png');
59 function handler_index(&$page)
62 $page->changeTpl('xnet/index.tpl');
65 function handler_exit(&$page)
67 XnetSession
::killSuid();
68 XnetSession
::destroy();
69 $page->changeTpl('xnet/deconnexion.tpl');
72 function handler_admin(&$page)
74 new_admin_page('xnet/admin.tpl');
76 if (Get
::has('del')) {
77 $res = XDB
::query('SELECT id, nom, mail_domain
78 FROM groupex.asso WHERE diminutif={?}',
80 list($id, $nom, $domain) = $res->fetchOneRow();
81 $page->assign('nom', $nom);
82 if ($id && Post
::has('del')) {
83 XDB
::query('DELETE FROM groupex.membres WHERE asso_id={?}', $id);
84 $page->trig('membres supprimés');
87 XDB
::query('DELETE FROM virtual_domains WHERE domain={?}', $domain);
88 XDB
::query('DELETE FROM virtual, virtual_redirect
89 USING virtual INNER JOIN virtual_redirect USING (vid)
90 WHERE alias LIKE {?}', '%@'.$domain);
91 $page->trig('suppression des alias mails');
93 $mmlist = new MMList(S
::v('uid'), S
::v('password'), $domain);
94 if ($listes = $mmlist->get_lists()) {
95 foreach ($listes as $l) {
96 $mmlist->delete_list($l['list'], true
);
98 $page->trig('mail lists surpprimées');
102 XDB
::query('DELETE FROM groupex.asso WHERE id={?}', $id);
103 $page->trig("Groupe $nom supprimé");
111 if (Post
::has('diminutif')) {
112 XDB
::query('INSERT INTO groupex.asso (id,diminutif)
113 VALUES(NULL,{?})', Post
::v('diminutif'));
114 pl_redirect('../'.Post
::v('diminutif').'/edit');
117 $res = XDB
::query('SELECT nom,diminutif FROM groupex.asso ORDER by NOM');
118 $page->assign('assos', $res->fetchAllAssoc());
121 function handler_plan(&$page)
123 $page->changeTpl('xnet/plan.tpl');
125 $page->setType('plan');
127 $res = XDB
::iterator(
128 'SELECT dom.id, dom.nom as domnom, asso.diminutif, asso.nom
130 INNER JOIN groupex.asso ON dom.id = asso.dom
131 WHERE FIND_IN_SET("GroupesX", dom.cat) AND FIND_IN_SET("GroupesX", asso.cat)
132 ORDER BY dom.nom, asso.nom');
134 while ($tmp = $res->next()) { $groupesx[$tmp['id']][] = $tmp; }
135 $page->assign('groupesx', $groupesx);
137 $res = XDB
::iterator(
138 'SELECT dom.id, dom.nom as domnom, asso.diminutif, asso.nom
140 INNER JOIN groupex.asso ON dom.id = asso.dom
141 WHERE FIND_IN_SET("Binets", dom.cat) AND FIND_IN_SET("Binets", asso.cat)
142 ORDER BY dom.nom, asso.nom');
144 while ($tmp = $res->next()) { $binets[$tmp['id']][] = $tmp; }
145 $page->assign('binets', $binets);
147 $res = XDB
::iterator(
148 'SELECT asso.diminutif, asso.nom
150 WHERE cat LIKE "%Promotions%"
151 ORDER BY diminutif');
152 $page->assign('promos', $res);
154 $res = XDB
::iterator(
155 'SELECT asso.diminutif, asso.nom
157 WHERE FIND_IN_SET("Institutions", cat)
158 ORDER BY diminutif');
159 $page->assign('inst', $res);
162 function handler_groups2(&$page)
164 $this->handler_groups(&$page, Get
::v('cat'), Get
::v('dom'));
167 function handler_groups(&$page, $cat = null
, $dom = null
)
170 $this->handler_index(&$page);
173 $cat = strtolower($cat);
175 $page->changeTpl('xnet/groupes.tpl');
176 $page->assign('cat', $cat);
177 $page->assign('dom', $dom);
179 $res = XDB
::query("SELECT id,nom FROM groupex.dom
180 WHERE FIND_IN_SET({?}, cat)
181 ORDER BY nom", $cat);
182 $doms = $res->fetchAllAssoc();
183 $page->assign('doms', $doms);
186 $res = XDB
::query("SELECT diminutif, nom, site FROM groupex.asso
187 WHERE FIND_IN_SET({?}, cat)
188 ORDER BY nom", $cat);
189 $page->assign('gps', $res->fetchAllAssoc());
190 } elseif (!is_null($dom)) {
191 $res = XDB
::query("SELECT diminutif, nom, site FROM groupex.asso
192 WHERE FIND_IN_SET({?}, cat) AND dom={?}
193 ORDER BY nom", $cat, $dom);
194 $page->assign('gps', $res->fetchAllAssoc());
197 $page->setType($cat);
201 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: