Backport
[platal.git] / include / xnet / page.inc.php
CommitLineData
0337d704 1<?php
2/***************************************************************************
2b105fb6 3 * Copyright (C) 2003-2006 Polytechnique.org *
0337d704 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
0337d704 22class XnetPage extends PlatalPage
23{
d83a1b04 24 var $nomenu = false;
25
0337d704 26 // {{{ function XnetPage()
27
28 function XnetPage($tpl, $type=SKINNED)
29 {
30 $this->PlatalPage($tpl, $type);
63528107 31
32 $this->register_function('list_all_my_groups', 'list_all_my_groups');
33 $this->register_modifier('cat_pp', 'cat_pp');
34 $this->assign('it_is_xnet', true);
35
36 if (!S::logged() && Get::has('auth')) {
37 XnetSession::doAuthX();
38 }
0337d704 39 }
40
41 // }}}
42 // {{{ function run()
43
44 function run()
45 {
d83a1b04 46 if (!$this->nomenu) {
47 $this->useMenu();
48 }
0337d704 49 $this->_run('xnet/skin.tpl');
50 }
51
52 // }}}
53 // {{{ function setType
54
55 function setType($type)
56 {
57 $this->assign('xnet_type', strtolower($type));
58 }
59
60 // }}}
61 // {{{ function useMenu
62
63 function useMenu()
64 {
65 global $globals;
66
67 $menu = array();
68
59ff13cf 69 $sub = array();
59ff13cf 70 $sub['liste des groupes'] = 'plan';
27455960 71 $sub['documentation'] = 'Xnet';
c0d230b0 72 $sub['signaler un bug'] = array('href' => 'send_bug', 'class' => 'popup_840x600');
6b4707eb 73 $menu["no_title"] = $sub;
3cabafae 74
5372c4d7 75 if (S::logged() && $globals->asso()) {
0337d704 76 $sub = array();
77 $dim = $globals->asso('diminutif');
27ae65e3 78 $sub['présentation'] = "login/$dim/";
d24c8a11 79 if (may_update() || (is_member() && $globals->asso('pub') == 'public')
80 || $globals->asso('cat') == 'Promotions') {
2e94d2b8 81 $sub['annuaire du groupe'] = "$dim/annuaire";
28929cf0 82 $sub['trombinoscope'] = "$dim/trombi";
e336465e 83 $sub['carte'] = "$dim/geoloc";
2b105fb6 84 }
3cabafae 85 if ((is_member() || may_update()) && $globals->asso('mail_domain')) {
80f44cfe 86 $sub['listes de diffusion'] = "$dim/lists";
0337d704 87 }
4f10a058 88 $sub['événement'] = "$dim/events";
3cabafae 89 if (may_update() || is_member()) {
da938539 90 $sub['télépaiement'] = "$dim/payment";
3cabafae 91 }
0337d704 92
93 $menu[$globals->asso('nom')] = $sub;
94 }
95
cab08090 96 if (S::logged() && may_update()) {
0337d704 97 $sub = array();
2e94d2b8 98 $sub['modifier l\'accueil'] = "$dim/edit";
24bcf50c 99 $sub['gérer les annonces'] = "$dim/admin/announces";
0337d704 100 if ($globals->asso('mail_domain')) {
3cabafae 101 $sub['envoyer un mail'] = "$dim/mail";
80f44cfe 102 $sub['créer une liste'] = "$dim/lists/create";
d1fcf09c 103 $sub['créer un alias'] = "$dim/alias/create";
0337d704 104 }
59ff13cf 105 if (S::has_perms()) {
de4b22cc 106 $sub['gérer les groupes'] = array('href' => 'admin', 'style' => 'color: gray;');
107 $sub['clear cache'] = array('href' => 'purge_cache', 'style' => 'color: gray;');
59ff13cf 108 }
109 $menu['Administrer'] = $sub;
8383ee06 110 } elseif (S::has_perms()) {
111 $sub = array();
112 $sub['gérer les groupes'] = 'admin';
2aee5b48 113 $sub['clear cache'] = 'purge_cache';
8383ee06 114 $menu['Administrer'] = $sub;
0337d704 115 }
116
117 $this->assign('menu', $menu);
118 }
119
120 // }}}
0337d704 121}
122
b76f0797 123// {{{ function list_all_my_groups
124
125function list_all_my_groups($params)
126{
127 if (!S::logged()) {
128 return;
129 }
130 $res = XDB::iterRow(
131 "SELECT a.nom, a.diminutif
132 FROM groupex.asso AS a
133 INNER JOIN groupex.membres AS m ON m.asso_id = a.id
134 WHERE m.uid={?}", S::v('uid'));
6b4707eb 135 $html = '<div>Mes groupes (<a href="exit">déconnexion</a>) :</div>';
b76f0797 136 while (list($nom, $mini) = $res->next()) {
db5db6c8 137 $html .= "<span class='gp'>&bull; <a href='login/$mini'>$nom</a></span>";
b76f0797 138 }
139 return $html;
140}
141
142// }}}
143// {{{ cat_pp
144
145function cat_pp($cat)
146{
147 $trans = array(
148 'groupesx' => 'Groupes X' ,
149 'binets' => 'Binets' ,
150 'institutions' => 'Institutions' ,
151 'promotions' => 'Promotions'
152 );
153
154 return $trans[strtolower($cat)];
155}
156
157// }}}
158
0337d704 159// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
160?>