pending commit, finished during MQ/S download ...
[platal.git] / include / xorg / menu.inc.php
CommitLineData
0337d704 1<?php
2/***************************************************************************
50a40a33 3 * Copyright (C) 2003-2006 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
22// {{{ defines
23
24define('XOM_NO',0);
25define('XOM_CUSTOM', "Personnaliser");
26define('XOM_SERVICES', "Services");
27define('XOM_GROUPS', "Communauté X");
28define('XOM_ADMIN', "***");
29
30define('XOM_US', 'Polytechniciens');
31define('XOM_EXT', 'Visiteurs');
32
33define('XOM_INFOS', "Informations");
34
35// }}}
36// {{{ class XOrgMenu
37
38/**
39 * Class used for the left menu construction
40 *
41 * @category XOrgCore
42 * @package XOrgCore
43 * @author Pierre Habouzit <pierre.habouzit@m4x.org>
44 * @access public
45 */
46
47class XOrgMenu
48{
49 // {{{ properties
50
51 var $_ext = Array();
52 var $_int = Array();
53
54 // }}}
55 // {{{ constructor
56
57 function XOrgMenu()
58 {
a3a049fc 59 $this->_int[XOM_NO] = array();
60 $this->_int[XOM_CUSTOM] = array();
61 $this->_int[XOM_SERVICES] = array();
62 $this->_int[XOM_GROUPS] = array();
63 $this->_int[XOM_INFOS] = array();
64 $this->_int[XOM_ADMIN] = array();
0337d704 65
a3a049fc 66 $this->_ext[XOM_US] = array();
67 $this->_ext[XOM_EXT] = array();
68 $this->_ext[XOM_INFOS] = array();
0337d704 69 }
70
71 // }}}
72 // {{{ function addPublicEntry
73
74 function addPublicEntry($head, $prio, $text, $url)
75 {
76 $this->_ext[$head][] = Array($prio, 'text' => $text, 'url' => $url);
77 }
78
79 // }}}
80 // {{{ function addPrivateEntry
81
82 function addPrivateEntry($head, $prio, $text, $url)
83 {
84 $this->_int[$head][] = Array($prio, 'text' => $text, 'url' => $url);
85 }
86
87 // }}}
88 // {{{ function menu()
89
90 function menu()
91 {
cab08090 92 $res = S::logged() ? $this->_int : $this->_ext;
93 if (S::identified()) {
4a5fb34b 94 $res[XOM_NO][] = Array(0, 'text' => 'Déconnexion', 'url' => 'exit');
0337d704 95 } elseif (Cookie::has('ORGaccess')) {
4a5fb34b 96 $res[XOM_NO][] = Array(0, 'text' => 'Déconnexion totale', 'url' => 'exit/forget');
0337d704 97 }
cab08090 98 if (!S::has_perms()) {
0337d704 99 unset($res[XOM_ADMIN]);
100 }
101 foreach (array_keys($res) as $key) {
102 if (empty($res[$key])) {
103 unset($res[$key]);
104 } else {
105 sort($res[$key]);
106 }
107 }
108 return $res;
109 }
110
111 // }}}
112}
113
114// }}}
115
116// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
117?>