2 /***************************************************************************
3 * Copyright (C) 2003-2014 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
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. *
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. *
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 *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 class XnetPage
extends PlPage
24 public $nomenu = false
;
26 // {{{ function XnetPage()
28 public function __construct()
31 parent
::__construct();
33 $this->register_function('list_all_my_groups', 'list_all_my_groups');
34 $this->register_modifier('cat_pp', 'cat_pp');
35 $this->assign('it_is_xnet', true
);
38 $this->assign('is_logged', S
::logged());
39 if ($globals->asso('id')) {
40 $this->assign('asso', $globals->asso());
41 $this->setType($globals->asso('cat'));
42 $this->assign('is_admin', may_update());
43 $this->assign('is_member', is_member());
45 if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false
) {
46 $this->addJsLink('json2.js');
48 $this->addJsLink('jquery.xorg.js');
49 $this->addJsLink('overlib.js');
50 $this->addJsLink('core.js');
51 $this->addJsLink('xorg.js');
52 if ($globals->core
->sentry_js_dsn
) {
53 $this->addJsLink('raven.min.js');
55 $this->setTitle('Les associations polytechniciennes');
66 $this->assign('menu', false
);
68 $this->_run('xnet/skin.tpl');
72 // {{{ function setType
74 public function setType($type)
76 $this->assign('xnet_type', strtolower($type));
80 // {{{ function useMenu
82 private function useMenu()
89 $sub['tous les groupes'] = 'plan';
90 $sub['documentation'] = 'Xnet';
91 if (S
::user()->type
== 'xnet') {
92 $sub['mon compte'] = 'edit';
93 $sub['mes préférences'] = $globals->xnet
->xorg_baseurl
. 'prefs';
95 $sub['signaler un bug'] = array('href' => 'send_bug/'.$_SERVER['REQUEST_URI'], 'class' => 'popup_840x600');
96 $menu["no_title"] = $sub;
98 $perms = S
::v('perms');
99 $dim = $globals->asso('diminutif');
100 if (S
::logged() && $globals->asso()) {
102 $sub['présentation'] = "login/$dim/";
103 if ($perms->hasFlag('groupannu')) {
104 $sub['annuaire du groupe'] = "$dim/annuaire";
105 $sub['trombinoscope'] = "$dim/trombi";
107 if ($globals->asso('forum')) {
108 $sub['forum'] = "$dim/forum";
110 if ($perms->hasFlag('groupmember')) {
111 if ($globals->asso('mail_domain')) {
112 $sub['listes de diffusion'] = "$dim/lists";
114 if ($globals->asso('has_nl')) {
115 $sub['newsletter'] = "$dim/nl";
118 $sub['événement'] = "$dim/events";
119 if ($perms->hasFlag('groupadmin')) {
120 $sub['télépaiement'] = "$dim/payment";
123 $menu[$globals->asso('nom')] = $sub;
126 if ($globals->asso() && is_object($perms) && $perms->hasFlag('groupadmin')) {
128 $sub['modifier l\'accueil'] = "$dim/edit";
129 $sub['gérer les annonces'] = "$dim/admin/announces";
130 if ($globals->asso('mail_domain')) {
131 if (!$globals->asso('disable_mails')) {
132 $sub['envoyer un mail'] = "$dim/mail";
134 $sub['créer une liste'] = "$dim/lists/create";
135 $sub['créer un alias'] = "$dim/alias/create";
137 if (!$globals->asso('has_nl')) {
138 $sub['créer la newsletter'] = "$dim/admin/nl/enable";
141 $sub['gérer les groupes'] = array('href' => 'admin', 'style' => 'color: gray;');
142 $sub['clear cache'] = array('href' => 'purge_cache?token=' . S
::v('xsrf_token'), 'style' => 'color: gray;');
144 $menu['Administrer'] = $sub;
145 } elseif (S
::admin()) {
147 $sub['gérer les groupes'] = 'admin';
148 $sub['clear cache'] = 'purge_cache?token=' . S
::v('xsrf_token');
149 $menu['Administrer'] = $sub;
152 $this->assign('menu', $menu);
158 // {{{ function list_all_my_groups
160 function list_all_my_groups($params)
165 $res = XDB
::iterRow('SELECT a.nom, a.diminutif
167 INNER JOIN group_members AS m ON m.asso_id = a.id
168 WHERE m.uid = {?}', S
::i('uid'));
169 $links = '<a href="exit">déconnexion</a>';
170 $html = '<div>Mes groupes (' . $links . ') :</div>';
171 while (list($nom, $mini) = $res->next()) {
172 $html .= "<span class='gp'>• <a href='login/$mini'>$nom</a></span>";
180 function cat_pp($cat)
183 'groupesx' => 'Groupes X' ,
184 'binets' => 'Binets' ,
185 'institutions' => 'Institutions' ,
186 'promotions' => 'Promotions'
189 return $trans[strtolower($cat)];
194 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8: