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