Commit | Line | Data |
---|---|---|
0337d704 | 1 | <?php |
2 | /*************************************************************************** | |
c441aabe | 3 | * Copyright (C) 2003-2014 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 | 22 | class XnetPage extends PlPage |
0337d704 | 23 | { |
2b1ee50b | 24 | public $nomenu = false; |
d83a1b04 | 25 | |
0337d704 | 26 | // {{{ function XnetPage() |
27 | ||
6b79b8ef | 28 | public function __construct() |
0337d704 | 29 | { |
8e18c1a2 | 30 | global $globals; |
6b79b8ef | 31 | parent::__construct(); |
63528107 | 32 | |
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); | |
36 | ||
6b79b8ef FB |
37 | global $globals; |
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()); | |
63528107 | 44 | } |
40324482 FB |
45 | if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) { |
46 | $this->addJsLink('json2.js'); | |
47 | } | |
b7bad73e | 48 | $this->addJsLink('jquery.xorg.js'); |
e97df22e | 49 | $this->addJsLink('overlib.js'); |
e5b254d5 | 50 | $this->addJsLink('core.js'); |
4c92db48 | 51 | $this->addJsLink('xorg.js'); |
8e18c1a2 NI |
52 | if ($globals->core->sentry_js_dsn) { |
53 | $this->addJsLink('raven.min.js'); | |
54 | } | |
ff996dd2 | 55 | $this->setTitle('Les associations polytechniciennes'); |
0337d704 | 56 | } |
57 | ||
58 | // }}} | |
59 | // {{{ function run() | |
60 | ||
2b1ee50b | 61 | public function run() |
0337d704 | 62 | { |
d83a1b04 | 63 | if (!$this->nomenu) { |
64 | $this->useMenu(); | |
3b2d1a55 SJ |
65 | } else { |
66 | $this->assign('menu', false); | |
d83a1b04 | 67 | } |
0337d704 | 68 | $this->_run('xnet/skin.tpl'); |
69 | } | |
70 | ||
71 | // }}} | |
72 | // {{{ function setType | |
73 | ||
2b1ee50b | 74 | public function setType($type) |
0337d704 | 75 | { |
76 | $this->assign('xnet_type', strtolower($type)); | |
77 | } | |
78 | ||
79 | // }}} | |
80 | // {{{ function useMenu | |
81 | ||
2b1ee50b | 82 | private function useMenu() |
0337d704 | 83 | { |
84 | global $globals; | |
85 | ||
86 | $menu = array(); | |
87 | ||
59ff13cf | 88 | $sub = array(); |
01c0448f | 89 | $sub['tous les groupes'] = 'plan'; |
27455960 | 90 | $sub['documentation'] = 'Xnet'; |
05023b9f | 91 | if (S::user()->type == 'xnet') { |
7267c7df | 92 | $sub['mon compte'] = 'edit'; |
a88f005d | 93 | $sub['mes préférences'] = $globals->xnet->xorg_baseurl . 'prefs'; |
05023b9f | 94 | } |
b206cca9 | 95 | $sub['signaler un bug'] = array('href' => 'send_bug/'.$_SERVER['REQUEST_URI'], 'class' => 'popup_840x600'); |
6b4707eb | 96 | $menu["no_title"] = $sub; |
eaf30d86 | 97 | |
2c86d368 | 98 | $perms = S::v('perms'); |
8e18295f | 99 | $dim = $globals->asso('diminutif'); |
5372c4d7 | 100 | if (S::logged() && $globals->asso()) { |
0337d704 | 101 | $sub = array(); |
a7de4ef7 | 102 | $sub['présentation'] = "login/$dim/"; |
2c86d368 | 103 | if ($perms->hasFlag('groupannu')) { |
2e94d2b8 | 104 | $sub['annuaire du groupe'] = "$dim/annuaire"; |
28929cf0 | 105 | $sub['trombinoscope'] = "$dim/trombi"; |
2b105fb6 | 106 | } |
e557b0db AL |
107 | if ($globals->asso('forum')) { |
108 | $sub['forum'] = "$dim/forum"; | |
109 | } | |
2c86d368 | 110 | if ($perms->hasFlag('groupmember')) { |
4f355064 | 111 | if ($globals->asso('mail_domain')) { |
112 | $sub['listes de diffusion'] = "$dim/lists"; | |
113 | } | |
c40a0fb3 RB |
114 | if ($globals->asso('has_nl')) { |
115 | $sub['newsletter'] = "$dim/nl"; | |
116 | } | |
0337d704 | 117 | } |
a7de4ef7 | 118 | $sub['événement'] = "$dim/events"; |
138c03a1 | 119 | if ($perms->hasFlag('groupadmin')) { |
a7de4ef7 | 120 | $sub['télépaiement'] = "$dim/payment"; |
3cabafae | 121 | } |
0337d704 | 122 | |
123 | $menu[$globals->asso('nom')] = $sub; | |
124 | } | |
125 | ||
c7c7321e | 126 | if ($globals->asso() && is_object($perms) && $perms->hasFlag('groupadmin')) { |
0337d704 | 127 | $sub = array(); |
2e94d2b8 | 128 | $sub['modifier l\'accueil'] = "$dim/edit"; |
a7de4ef7 | 129 | $sub['gérer les annonces'] = "$dim/admin/announces"; |
0337d704 | 130 | if ($globals->asso('mail_domain')) { |
08906e89 RB |
131 | if (!$globals->asso('disable_mails')) { |
132 | $sub['envoyer un mail'] = "$dim/mail"; | |
133 | } | |
a7de4ef7 | 134 | $sub['créer une liste'] = "$dim/lists/create"; |
135 | $sub['créer un alias'] = "$dim/alias/create"; | |
0337d704 | 136 | } |
738b4620 RB |
137 | if (!$globals->asso('has_nl')) { |
138 | $sub['créer la newsletter'] = "$dim/admin/nl/enable"; | |
139 | } | |
dd70cd28 | 140 | if (S::admin()) { |
a7de4ef7 | 141 | $sub['gérer les groupes'] = array('href' => 'admin', 'style' => 'color: gray;'); |
85909256 | 142 | $sub['clear cache'] = array('href' => 'purge_cache?token=' . S::v('xsrf_token'), 'style' => 'color: gray;'); |
59ff13cf | 143 | } |
144 | $menu['Administrer'] = $sub; | |
dd70cd28 | 145 | } elseif (S::admin()) { |
8383ee06 | 146 | $sub = array(); |
a7de4ef7 | 147 | $sub['gérer les groupes'] = 'admin'; |
85909256 | 148 | $sub['clear cache'] = 'purge_cache?token=' . S::v('xsrf_token'); |
8383ee06 | 149 | $menu['Administrer'] = $sub; |
0337d704 | 150 | } |
151 | ||
152 | $this->assign('menu', $menu); | |
153 | } | |
154 | ||
155 | // }}} | |
0337d704 | 156 | } |
157 | ||
b76f0797 | 158 | // {{{ function list_all_my_groups |
159 | ||
160 | function list_all_my_groups($params) | |
161 | { | |
162 | if (!S::logged()) { | |
163 | return; | |
164 | } | |
34ade5a6 | 165 | $res = XDB::iterRow('SELECT a.nom, a.diminutif |
eb41eda9 FB |
166 | FROM groups AS a |
167 | INNER JOIN group_members AS m ON m.asso_id = a.id | |
34ade5a6 | 168 | WHERE m.uid = {?}', S::i('uid')); |
a7de4ef7 | 169 | $links = '<a href="exit">déconnexion</a>'; |
e74411f7 | 170 | $html = '<div>Mes groupes (' . $links . ') :</div>'; |
b76f0797 | 171 | while (list($nom, $mini) = $res->next()) { |
db5db6c8 | 172 | $html .= "<span class='gp'>• <a href='login/$mini'>$nom</a></span>"; |
b76f0797 | 173 | } |
174 | return $html; | |
175 | } | |
176 | ||
177 | // }}} | |
178 | // {{{ cat_pp | |
179 | ||
180 | function cat_pp($cat) | |
181 | { | |
182 | $trans = array( | |
183 | 'groupesx' => 'Groupes X' , | |
184 | 'binets' => 'Binets' , | |
185 | 'institutions' => 'Institutions' , | |
186 | 'promotions' => 'Promotions' | |
187 | ); | |
188 | ||
189 | return $trans[strtolower($cat)]; | |
190 | } | |
191 | ||
192 | // }}} | |
193 | ||
448c8cdc | 194 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8: |
0337d704 | 195 | ?> |