| 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 | // {{{ defines |
| 23 | |
| 24 | define('XOM_NO',0); |
| 25 | define('XOM_CUSTOM', "Personnaliser"); |
| 26 | define('XOM_SERVICES', "Services"); |
| 27 | define('XOM_GROUPS', "Communauté X"); |
| 28 | define('XOM_ADMIN', "***"); |
| 29 | |
| 30 | define('XOM_US', 'Polytechniciens'); |
| 31 | define('XOM_EXT', 'Visiteurs'); |
| 32 | |
| 33 | define('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 | |
| 47 | class XOrgMenu |
| 48 | { |
| 49 | // {{{ properties |
| 50 | |
| 51 | var $_ext = Array(); |
| 52 | var $_int = Array(); |
| 53 | |
| 54 | // }}} |
| 55 | // {{{ constructor |
| 56 | |
| 57 | function XOrgMenu() |
| 58 | { |
| 59 | global $globals; |
| 60 | |
| 61 | $this->_int[XOM_NO] = Array(); |
| 62 | $this->_int[XOM_CUSTOM] = Array(); |
| 63 | $this->_int[XOM_SERVICES] = Array(); |
| 64 | $this->_int[XOM_GROUPS] = Array(); |
| 65 | $this->_int[XOM_INFOS] = Array(); |
| 66 | $this->_int[XOM_ADMIN] = Array(); |
| 67 | |
| 68 | $this->_ext[XOM_US] = Array(); |
| 69 | $this->_ext[XOM_EXT] = Array(); |
| 70 | $this->_ext[XOM_INFOS] = Array(); |
| 71 | } |
| 72 | |
| 73 | // }}} |
| 74 | // {{{ function addPublicEntry |
| 75 | |
| 76 | function addPublicEntry($head, $prio, $text, $url) |
| 77 | { |
| 78 | $this->_ext[$head][] = Array($prio, 'text' => $text, 'url' => $url); |
| 79 | } |
| 80 | |
| 81 | // }}} |
| 82 | // {{{ function addPrivateEntry |
| 83 | |
| 84 | function addPrivateEntry($head, $prio, $text, $url) |
| 85 | { |
| 86 | $this->_int[$head][] = Array($prio, 'text' => $text, 'url' => $url); |
| 87 | } |
| 88 | |
| 89 | // }}} |
| 90 | // {{{ function menu() |
| 91 | |
| 92 | function menu() |
| 93 | { |
| 94 | $res = logged() ? $this->_int : $this->_ext; |
| 95 | if (identified()) { |
| 96 | $res[XOM_NO][] = Array(0, 'text' => 'Déconnexion', 'url' => 'deconnexion.php'); |
| 97 | } elseif (Cookie::has('ORGaccess')) { |
| 98 | $res[XOM_NO][] = Array(0, 'text' => 'Déconnexion totale', 'url' => 'deconnexion.php?forget=1'); |
| 99 | } |
| 100 | if (!has_perms()) { |
| 101 | unset($res[XOM_ADMIN]); |
| 102 | } |
| 103 | foreach (array_keys($res) as $key) { |
| 104 | if (empty($res[$key])) { |
| 105 | unset($res[$key]); |
| 106 | } else { |
| 107 | sort($res[$key]); |
| 108 | } |
| 109 | } |
| 110 | return $res; |
| 111 | } |
| 112 | |
| 113 | // }}} |
| 114 | } |
| 115 | |
| 116 | // }}} |
| 117 | |
| 118 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker: |
| 119 | ?> |