Fix a layout issue in 'moment' display.
[platal.git] / include / xnet / page.inc.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
0337d704 22class XnetPage extends PlatalPage
23{
2b1ee50b 24 public $nomenu = false;
d83a1b04 25
0337d704 26 // {{{ function XnetPage()
27
2b1ee50b 28 public function __construct($tpl, $type=SKINNED)
0337d704 29 {
2b1ee50b 30 parent::__construct($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
2b1ee50b 44 public function run()
0337d704 45 {
d83a1b04 46 if (!$this->nomenu) {
47 $this->useMenu();
48 }
0337d704 49 $this->_run('xnet/skin.tpl');
50 }
51
52 // }}}
1490093c 53 // {{{ function changeTpl()
54
55 public function changeTpl($tpl, $type = SKINNED)
56 {
57 global $globals;
58 parent::changeTpl($tpl, $type);
59 $this->assign('is_logged', S::logged());
eaf30d86 60 if ($globals->asso('id')) {
1490093c 61 $this->assign('asso', $globals->asso());
62 $this->setType($globals->asso('cat'));
63 $this->assign('is_admin', may_update());
64 $this->assign('is_member', is_member());
65 }
66 }
eaf30d86 67
1490093c 68 // }}}
0337d704 69 // {{{ function setType
70
2b1ee50b 71 public function setType($type)
0337d704 72 {
73 $this->assign('xnet_type', strtolower($type));
74 }
75
76 // }}}
77 // {{{ function useMenu
78
2b1ee50b 79 private function useMenu()
0337d704 80 {
81 global $globals;
82
83 $menu = array();
84
59ff13cf 85 $sub = array();
59ff13cf 86 $sub['liste des groupes'] = 'plan';
27455960 87 $sub['documentation'] = 'Xnet';
eaf30d86 88 $sub['signaler un bug'] = array('href' => 'send_bug', 'class' => 'popup_840x600');
6b4707eb 89 $menu["no_title"] = $sub;
eaf30d86 90
2c86d368 91 $perms = S::v('perms');
8e18295f 92 $dim = $globals->asso('diminutif');
5372c4d7 93 if (S::logged() && $globals->asso()) {
0337d704 94 $sub = array();
a7de4ef7 95 $sub['présentation'] = "login/$dim/";
2c86d368 96 if ($perms->hasFlag('groupannu')) {
2e94d2b8 97 $sub['annuaire du groupe'] = "$dim/annuaire";
28929cf0 98 $sub['trombinoscope'] = "$dim/trombi";
d957ae4d 99 $sub['planisphère'] = "$dim/geoloc";
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 }
59ff13cf 126 if (S::has_perms()) {
a7de4ef7 127 $sub['gérer les groupes'] = array('href' => 'admin', 'style' => 'color: gray;');
de4b22cc 128 $sub['clear cache'] = array('href' => 'purge_cache', 'style' => 'color: gray;');
59ff13cf 129 }
130 $menu['Administrer'] = $sub;
8383ee06 131 } elseif (S::has_perms()) {
132 $sub = array();
a7de4ef7 133 $sub['gérer les groupes'] = 'admin';
2aee5b48 134 $sub['clear cache'] = 'purge_cache';
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 }
151 $res = XDB::iterRow(
152 "SELECT a.nom, a.diminutif
153 FROM groupex.asso AS a
154 INNER JOIN groupex.membres AS m ON m.asso_id = a.id
155 WHERE m.uid={?}", S::v('uid'));
a7de4ef7 156 $links = '<a href="exit">déconnexion</a>';
e74411f7 157 $html = '<div>Mes groupes (' . $links . ') :</div>';
b76f0797 158 while (list($nom, $mini) = $res->next()) {
db5db6c8 159 $html .= "<span class='gp'>&bull; <a href='login/$mini'>$nom</a></span>";
b76f0797 160 }
161 return $html;
162}
163
164// }}}
165// {{{ cat_pp
166
167function cat_pp($cat)
168{
169 $trans = array(
170 'groupesx' => 'Groupes X' ,
171 'binets' => 'Binets' ,
172 'institutions' => 'Institutions' ,
173 'promotions' => 'Promotions'
174 );
175
176 return $trans[strtolower($cat)];
177}
178
179// }}}
180
a7de4ef7 181// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
0337d704 182?>