Small improvements.
[platal.git] / classes / xnetpage.php
CommitLineData
0337d704 1<?php
2/***************************************************************************
5e1513f6 3 * Copyright (C) 2003-2011 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
04334c61 22class XnetPage extends PlPage
0337d704 23{
2b1ee50b 24 public $nomenu = false;
d83a1b04 25
0337d704 26 // {{{ function XnetPage()
27
6b79b8ef 28 public function __construct()
0337d704 29 {
6b79b8ef 30 parent::__construct();
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
6b79b8ef
FB
36 global $globals;
37 $this->assign('is_logged', S::logged());
38 if ($globals->asso('id')) {
39 $this->assign('asso', $globals->asso());
40 $this->setType($globals->asso('cat'));
41 $this->assign('is_admin', may_update());
42 $this->assign('is_member', is_member());
63528107 43 }
e97df22e
VZ
44 $this->addJsLink('jquery.js');
45 $this->addJsLink('overlib.js');
46 $this->addJsLink('wiki.js');
4c92db48 47 $this->addJsLink('xorg.js');
ff996dd2 48 $this->setTitle('Les associations polytechniciennes');
0337d704 49 }
50
51 // }}}
52 // {{{ function run()
53
2b1ee50b 54 public function run()
0337d704 55 {
d83a1b04 56 if (!$this->nomenu) {
57 $this->useMenu();
3b2d1a55
SJ
58 } else {
59 $this->assign('menu', false);
d83a1b04 60 }
0337d704 61 $this->_run('xnet/skin.tpl');
62 }
63
64 // }}}
65 // {{{ function setType
66
2b1ee50b 67 public function setType($type)
0337d704 68 {
69 $this->assign('xnet_type', strtolower($type));
70 }
71
72 // }}}
73 // {{{ function useMenu
74
2b1ee50b 75 private function useMenu()
0337d704 76 {
77 global $globals;
78
79 $menu = array();
80
59ff13cf 81 $sub = array();
01c0448f 82 $sub['tous les groupes'] = 'plan';
27455960 83 $sub['documentation'] = 'Xnet';
b206cca9 84 $sub['signaler un bug'] = array('href' => 'send_bug/'.$_SERVER['REQUEST_URI'], 'class' => 'popup_840x600');
6b4707eb 85 $menu["no_title"] = $sub;
eaf30d86 86
2c86d368 87 $perms = S::v('perms');
8e18295f 88 $dim = $globals->asso('diminutif');
5372c4d7 89 if (S::logged() && $globals->asso()) {
0337d704 90 $sub = array();
a7de4ef7 91 $sub['présentation'] = "login/$dim/";
2c86d368 92 if ($perms->hasFlag('groupannu')) {
2e94d2b8 93 $sub['annuaire du groupe'] = "$dim/annuaire";
28929cf0 94 $sub['trombinoscope'] = "$dim/trombi";
2b105fb6 95 }
2c86d368 96 if ($perms->hasFlag('groupmember')) {
4f355064 97 if ($globals->asso('forum')) {
98 $sub['forum'] = "$dim/forum";
99 }
100 if ($globals->asso('mail_domain')) {
101 $sub['listes de diffusion'] = "$dim/lists";
102 }
0337d704 103 }
a7de4ef7 104 $sub['événement'] = "$dim/events";
2c86d368 105 if ($perms->hasFlag('groupmember')) {
a7de4ef7 106 $sub['télépaiement'] = "$dim/payment";
3cabafae 107 }
0337d704 108
109 $menu[$globals->asso('nom')] = $sub;
110 }
111
c7c7321e 112 if ($globals->asso() && is_object($perms) && $perms->hasFlag('groupadmin')) {
0337d704 113 $sub = array();
2e94d2b8 114 $sub['modifier l\'accueil'] = "$dim/edit";
a7de4ef7 115 $sub['gérer les annonces'] = "$dim/admin/announces";
0337d704 116 if ($globals->asso('mail_domain')) {
3cabafae 117 $sub['envoyer un mail'] = "$dim/mail";
a7de4ef7 118 $sub['créer une liste'] = "$dim/lists/create";
119 $sub['créer un alias'] = "$dim/alias/create";
0337d704 120 }
dd70cd28 121 if (S::admin()) {
a7de4ef7 122 $sub['gérer les groupes'] = array('href' => 'admin', 'style' => 'color: gray;');
85909256 123 $sub['clear cache'] = array('href' => 'purge_cache?token=' . S::v('xsrf_token'), 'style' => 'color: gray;');
59ff13cf 124 }
125 $menu['Administrer'] = $sub;
dd70cd28 126 } elseif (S::admin()) {
8383ee06 127 $sub = array();
a7de4ef7 128 $sub['gérer les groupes'] = 'admin';
85909256 129 $sub['clear cache'] = 'purge_cache?token=' . S::v('xsrf_token');
8383ee06 130 $menu['Administrer'] = $sub;
0337d704 131 }
132
133 $this->assign('menu', $menu);
134 }
135
136 // }}}
0337d704 137}
138
b76f0797 139// {{{ function list_all_my_groups
140
141function list_all_my_groups($params)
142{
143 if (!S::logged()) {
144 return;
145 }
34ade5a6 146 $res = XDB::iterRow('SELECT a.nom, a.diminutif
eb41eda9
FB
147 FROM groups AS a
148 INNER JOIN group_members AS m ON m.asso_id = a.id
34ade5a6 149 WHERE m.uid = {?}', S::i('uid'));
a7de4ef7 150 $links = '<a href="exit">déconnexion</a>';
e74411f7 151 $html = '<div>Mes groupes (' . $links . ') :</div>';
b76f0797 152 while (list($nom, $mini) = $res->next()) {
db5db6c8 153 $html .= "<span class='gp'>&bull; <a href='login/$mini'>$nom</a></span>";
b76f0797 154 }
155 return $html;
156}
157
158// }}}
159// {{{ cat_pp
160
161function cat_pp($cat)
162{
163 $trans = array(
164 'groupesx' => 'Groupes X' ,
165 'binets' => 'Binets' ,
166 'institutions' => 'Institutions' ,
167 'promotions' => 'Promotions'
168 );
169
170 return $trans[strtolower($cat)];
171}
172
173// }}}
174
a7de4ef7 175// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
0337d704 176?>