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