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