Commit | Line | Data |
---|---|---|
0337d704 | 1 | <?php |
2 | /*************************************************************************** | |
5e1513f6 | 3 | * Copyright (C) 2003-2011 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 | { |
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 | } |
b7bad73e | 44 | $this->addJsLink('jquery.xorg.js'); |
e97df22e | 45 | $this->addJsLink('overlib.js'); |
e5b254d5 | 46 | $this->addJsLink('core.js'); |
4c92db48 | 47 | $this->addJsLink('xorg.js'); |
ff996dd2 | 48 | $this->setTitle('Les associations polytechniciennes'); |
0337d704 | 49 | } |
50 | ||
51 | // }}} | |
52 | // {{{ function run() | |
53 | ||
2b1ee50b | 54 | public function run() |
0337d704 | 55 | { |
d83a1b04 | 56 | if (!$this->nomenu) { |
57 | $this->useMenu(); | |
3b2d1a55 SJ |
58 | } else { |
59 | $this->assign('menu', false); | |
d83a1b04 | 60 | } |
0337d704 | 61 | $this->_run('xnet/skin.tpl'); |
62 | } | |
63 | ||
64 | // }}} | |
65 | // {{{ function setType | |
66 | ||
2b1ee50b | 67 | public function setType($type) |
0337d704 | 68 | { |
69 | $this->assign('xnet_type', strtolower($type)); | |
70 | } | |
71 | ||
72 | // }}} | |
73 | // {{{ function useMenu | |
74 | ||
2b1ee50b | 75 | private function useMenu() |
0337d704 | 76 | { |
77 | global $globals; | |
78 | ||
79 | $menu = array(); | |
80 | ||
59ff13cf | 81 | $sub = array(); |
01c0448f | 82 | $sub['tous les groupes'] = 'plan'; |
27455960 | 83 | $sub['documentation'] = 'Xnet'; |
05023b9f | 84 | if (S::user()->type == 'xnet') { |
f15d1307 | 85 | $sub['mon compte'] = 'member/edit'; |
05023b9f | 86 | } |
b206cca9 | 87 | $sub['signaler un bug'] = array('href' => 'send_bug/'.$_SERVER['REQUEST_URI'], 'class' => 'popup_840x600'); |
6b4707eb | 88 | $menu["no_title"] = $sub; |
eaf30d86 | 89 | |
2c86d368 | 90 | $perms = S::v('perms'); |
8e18295f | 91 | $dim = $globals->asso('diminutif'); |
5372c4d7 | 92 | if (S::logged() && $globals->asso()) { |
0337d704 | 93 | $sub = array(); |
a7de4ef7 | 94 | $sub['présentation'] = "login/$dim/"; |
2c86d368 | 95 | if ($perms->hasFlag('groupannu')) { |
2e94d2b8 | 96 | $sub['annuaire du groupe'] = "$dim/annuaire"; |
28929cf0 | 97 | $sub['trombinoscope'] = "$dim/trombi"; |
2b105fb6 | 98 | } |
2c86d368 | 99 | if ($perms->hasFlag('groupmember')) { |
4f355064 | 100 | if ($globals->asso('forum')) { |
101 | $sub['forum'] = "$dim/forum"; | |
102 | } | |
103 | if ($globals->asso('mail_domain')) { | |
104 | $sub['listes de diffusion'] = "$dim/lists"; | |
105 | } | |
c40a0fb3 RB |
106 | if ($globals->asso('has_nl')) { |
107 | $sub['newsletter'] = "$dim/nl"; | |
108 | } | |
0337d704 | 109 | } |
a7de4ef7 | 110 | $sub['événement'] = "$dim/events"; |
2c86d368 | 111 | if ($perms->hasFlag('groupmember')) { |
a7de4ef7 | 112 | $sub['télépaiement'] = "$dim/payment"; |
3cabafae | 113 | } |
0337d704 | 114 | |
115 | $menu[$globals->asso('nom')] = $sub; | |
116 | } | |
117 | ||
c7c7321e | 118 | if ($globals->asso() && is_object($perms) && $perms->hasFlag('groupadmin')) { |
0337d704 | 119 | $sub = array(); |
2e94d2b8 | 120 | $sub['modifier l\'accueil'] = "$dim/edit"; |
a7de4ef7 | 121 | $sub['gérer les annonces'] = "$dim/admin/announces"; |
0337d704 | 122 | if ($globals->asso('mail_domain')) { |
3cabafae | 123 | $sub['envoyer un mail'] = "$dim/mail"; |
a7de4ef7 | 124 | $sub['créer une liste'] = "$dim/lists/create"; |
125 | $sub['créer un alias'] = "$dim/alias/create"; | |
0337d704 | 126 | } |
dd70cd28 | 127 | if (S::admin()) { |
a7de4ef7 | 128 | $sub['gérer les groupes'] = array('href' => 'admin', 'style' => 'color: gray;'); |
85909256 | 129 | $sub['clear cache'] = array('href' => 'purge_cache?token=' . S::v('xsrf_token'), 'style' => 'color: gray;'); |
59ff13cf | 130 | } |
131 | $menu['Administrer'] = $sub; | |
dd70cd28 | 132 | } elseif (S::admin()) { |
8383ee06 | 133 | $sub = array(); |
a7de4ef7 | 134 | $sub['gérer les groupes'] = 'admin'; |
85909256 | 135 | $sub['clear cache'] = 'purge_cache?token=' . S::v('xsrf_token'); |
8383ee06 | 136 | $menu['Administrer'] = $sub; |
0337d704 | 137 | } |
138 | ||
139 | $this->assign('menu', $menu); | |
140 | } | |
141 | ||
142 | // }}} | |
0337d704 | 143 | } |
144 | ||
b76f0797 | 145 | // {{{ function list_all_my_groups |
146 | ||
147 | function list_all_my_groups($params) | |
148 | { | |
149 | if (!S::logged()) { | |
150 | return; | |
151 | } | |
34ade5a6 | 152 | $res = XDB::iterRow('SELECT a.nom, a.diminutif |
eb41eda9 FB |
153 | FROM groups AS a |
154 | INNER JOIN group_members AS m ON m.asso_id = a.id | |
34ade5a6 | 155 | WHERE m.uid = {?}', S::i('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'>• <a href='login/$mini'>$nom</a></span>"; |
b76f0797 | 160 | } |
161 | return $html; | |
162 | } | |
163 | ||
164 | // }}} | |
165 | // {{{ cat_pp | |
166 | ||
167 | function 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 | ?> |