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