use php5-isms
[platal.git] / include / xnet / page.inc.php
1 <?php
2 /***************************************************************************
3 * Copyright (C) 2003-2006 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 require_once dirname(__FILE__).'/../../classes/page.php';
23
24 class XnetPage extends PlatalPage
25 {
26 // {{{ function XnetPage()
27
28 function XnetPage($tpl, $type=SKINNED)
29 {
30 $this->PlatalPage($tpl, $type);
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 if (!S::logged() && Get::has('auth')) {
37 XnetSession::doAuthX();
38 }
39 }
40
41 // }}}
42 // {{{ function run()
43
44 function run()
45 {
46 $this->_run('xnet/skin.tpl');
47 }
48
49 // }}}
50 // {{{ function setType
51
52 function setType($type)
53 {
54 $this->assign('xnet_type', strtolower($type));
55 }
56
57 // }}}
58 // {{{ function useMenu
59
60 function useMenu()
61 {
62 global $globals;
63
64 $menu = array();
65
66 if (S::logged()) {
67 $sub = array();
68 $sub['déconnexion'] = 'exit';
69 $menu['no_title'] = $sub;
70 }
71
72 $sub = array();
73 $sub['accueil'] = '';
74 $sub['liste des groupes'] = 'plan';
75 $sub['documentation'] = 'Xnet';
76 $menu["Menu Principal"] = $sub;
77
78 if (S::logged() && (is_member() || may_update())) {
79 $sub = array();
80 $dim = $globals->asso('diminutif');
81 $sub['présentation'] = "$dim/";
82 if (may_update() || $globals->asso('pub') == 'public') {
83 $sub['annuaire du groupe'] = "$dim/annuaire";
84 $sub['carte'] = "$dim/geoloc";
85 }
86 if ($globals->asso('mail_domain')) {
87 $sub['listes de diffusion'] = "$dim/lists";
88 $sub['envoyer un mail'] = "$dim/mail";
89 }
90 $sub['événement'] = "$dim/events";
91 $sub['télépaiement'] = "$dim/paiement";
92
93 $menu[$globals->asso('nom')] = $sub;
94 }
95
96 if (S::logged() && may_update()) {
97 $sub = array();
98 $sub['modifier l\'accueil'] = "$dim/edit";
99 if ($globals->asso('mail_domain')) {
100 $sub['créer une liste'] = "$dim/lists/create";
101 $sub['créer un alias'] = "$dim/alias/create";
102 }
103 if (S::has_perms()) {
104 $sub['gérer les groupes'] = 'admin';
105 }
106 $menu['Administrer'] = $sub;
107 } elseif (S::has_perms()) {
108 $sub = array();
109 $sub['gérer les groupes'] = 'admin';
110 $menu['Administrer'] = $sub;
111 }
112
113 $this->assign('menu', $menu);
114 }
115
116 // }}}
117 }
118
119 // {{{ function list_all_my_groups
120
121 function list_all_my_groups($params)
122 {
123 if (!S::logged()) {
124 return;
125 }
126 $res = XDB::iterRow(
127 "SELECT a.nom, a.diminutif
128 FROM groupex.asso AS a
129 INNER JOIN groupex.membres AS m ON m.asso_id = a.id
130 WHERE m.uid={?}", S::v('uid'));
131 $html = '<div>Mes groupes :</div>';
132 while (list($nom, $mini) = $res->next()) {
133 $html .= "<a class='gp' href='$mini/'>&bull; $nom</a>";
134 }
135 return $html;
136 }
137
138 // }}}
139 // {{{ cat_pp
140
141 function cat_pp($cat)
142 {
143 $trans = array(
144 'groupesx' => 'Groupes X' ,
145 'binets' => 'Binets' ,
146 'institutions' => 'Institutions' ,
147 'promotions' => 'Promotions'
148 );
149
150 return $trans[strtolower($cat)];
151 }
152
153 // }}}
154
155 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
156 ?>