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