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