+ }
+
+ function handler_exit(&$page)
+ {
+ Platal::session()->stopSUID();
+ Platal::session()->destroy();
+ $page->changeTpl('xnet/deconnexion.tpl');
+ }
+
+ function handler_admin(&$page)
+ {
+ $page->changeTpl('xnet/admin.tpl');
+
+ if (Get::has('del')) {
+ $res = XDB::query('SELECT id, nom, mail_domain
+ FROM groupex.asso WHERE diminutif={?}',
+ Get::v('del'));
+ list($id, $nom, $domain) = $res->fetchOneRow();
+ $page->assign('nom', $nom);
+ if ($id && Post::has('del')) {
+ S::assert_xsrf_token();
+
+ XDB::query('DELETE FROM groupex.membres WHERE asso_id={?}', $id);
+ $page->trigSuccess('membres supprimés');
+
+ if ($domain) {
+ XDB::query('DELETE FROM virtual_domains WHERE domain={?}', $domain);
+ XDB::query('DELETE FROM virtual, virtual_redirect
+ USING virtual INNER JOIN virtual_redirect USING (vid)
+ WHERE alias LIKE {?}', '%@'.$domain);
+ $page->trigSuccess('suppression des alias mails');
+
+ $mmlist = new MMList(S::v('uid'), S::v('password'), $domain);
+ if ($listes = $mmlist->get_lists()) {
+ foreach ($listes as $l) {
+ $mmlist->delete_list($l['list'], true);
+ }
+ $page->trigSuccess('mail lists surpprimées');
+ }
+ }
+
+ XDB::query('DELETE FROM groupex.asso WHERE id={?}', $id);
+ $page->trigSuccess("Groupe $nom supprimé");
+ Get::kill('del');
+ }
+ if (!$id) {
+ Get::kill('del');
+ }
+ }
+
+ if (Post::has('diminutif')) {
+ S::assert_xsrf_token();
+
+ XDB::query('INSERT INTO groupex.asso (id,diminutif)
+ VALUES(NULL,{?})', Post::v('diminutif'));
+ pl_redirect('../'.Post::v('diminutif').'/edit');
+ }
+
+ $res = XDB::query('SELECT nom,diminutif FROM groupex.asso ORDER by NOM');
+ $page->assign('assos', $res->fetchAllAssoc());
+ }
+
+ function handler_plan(&$page)
+ {
+ $page->changeTpl('xnet/plan.tpl');
+
+ $page->setType('plan');
+
+ $res = XDB::iterator(
+ 'SELECT dom.id, dom.nom as domnom, asso.diminutif, asso.nom
+ FROM groupex.dom
+ INNER JOIN groupex.asso ON dom.id = asso.dom
+ WHERE FIND_IN_SET("GroupesX", dom.cat) AND FIND_IN_SET("GroupesX", asso.cat)
+ ORDER BY dom.nom, asso.nom');
+ $groupesx = array();
+ while ($tmp = $res->next()) { $groupesx[$tmp['id']][] = $tmp; }
+ $page->assign('groupesx', $groupesx);
+
+ $res = XDB::iterator(
+ 'SELECT dom.id, dom.nom as domnom, asso.diminutif, asso.nom
+ FROM groupex.dom
+ INNER JOIN groupex.asso ON dom.id = asso.dom
+ WHERE FIND_IN_SET("Binets", dom.cat) AND FIND_IN_SET("Binets", asso.cat)
+ ORDER BY dom.nom, asso.nom');
+ $binets = array();
+ while ($tmp = $res->next()) { $binets[$tmp['id']][] = $tmp; }
+ $page->assign('binets', $binets);
+
+ $res = XDB::iterator(
+ 'SELECT asso.diminutif, asso.nom
+ FROM groupex.asso
+ WHERE cat LIKE "%Promotions%"
+ ORDER BY diminutif');
+ $page->assign('promos', $res);
+
+ $res = XDB::iterator(
+ 'SELECT asso.diminutif, asso.nom
+ FROM groupex.asso
+ WHERE FIND_IN_SET("Institutions", cat)
+ ORDER BY diminutif');
+ $page->assign('inst', $res);
+ }
+
+ function handler_groups2(&$page)
+ {
+ $this->handler_groups(&$page, Get::v('cat'), Get::v('dom'));
+ }
+
+ function handler_groups(&$page, $cat = null, $dom = null)
+ {
+ if (!$cat) {
+ $this->handler_index(&$page);
+ }
+
+ $cat = strtolower($cat);
+
+ $page->changeTpl('xnet/groupes.tpl');
+ $page->assign('cat', $cat);
+ $page->assign('dom', $dom);
+
+ $res = XDB::query("SELECT id,nom FROM groupex.dom
+ WHERE FIND_IN_SET({?}, cat)
+ ORDER BY nom", $cat);
+ $doms = $res->fetchAllAssoc();
+ $page->assign('doms', $doms);
+
+ if (empty($doms)) {
+ $res = XDB::query("SELECT diminutif, nom, site FROM groupex.asso
+ WHERE FIND_IN_SET({?}, cat)
+ ORDER BY nom", $cat);
+ $page->assign('gps', $res->fetchAllAssoc());
+ } elseif (!is_null($dom)) {
+ $res = XDB::query("SELECT diminutif, nom, site FROM groupex.asso
+ WHERE FIND_IN_SET({?}, cat) AND dom={?}
+ ORDER BY nom", $cat, $dom);
+ $page->assign('gps', $res->fetchAllAssoc());
+ }
+
+ $page->setType($cat);
+ }
+
+ function handler_autologin(&$page)
+ {
+ $allkeys = func_get_args();
+ unset($allkeys[0]);
+ $url = join('/',$allkeys);
+ header("Content-type: text/javascript; charset=utf-8");
+ echo '$.ajax({ url: "'.$url.'?forceXml=1", dataType: "xml", success: function(xml) { $("body",xml).insertBefore("body"); $("body:eq(1)").remove(); }});';
+ exit;