| 1 | <?php |
| 2 | /*************************************************************************** |
| 3 | * Copyright (C) 2003-2011 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 PlPage |
| 23 | { |
| 24 | public $nomenu = false; |
| 25 | |
| 26 | // {{{ function XnetPage() |
| 27 | |
| 28 | public function __construct() |
| 29 | { |
| 30 | parent::__construct(); |
| 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 | global $globals; |
| 37 | $this->assign('is_logged', S::logged()); |
| 38 | if ($globals->asso('id')) { |
| 39 | $this->assign('asso', $globals->asso()); |
| 40 | $this->setType($globals->asso('cat')); |
| 41 | $this->assign('is_admin', may_update()); |
| 42 | $this->assign('is_member', is_member()); |
| 43 | } |
| 44 | if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) { |
| 45 | $this->addJsLink('json2.js'); |
| 46 | } |
| 47 | $this->addJsLink('jquery.xorg.js'); |
| 48 | $this->addJsLink('overlib.js'); |
| 49 | $this->addJsLink('core.js'); |
| 50 | $this->addJsLink('xorg.js'); |
| 51 | $this->setTitle('Les associations polytechniciennes'); |
| 52 | } |
| 53 | |
| 54 | // }}} |
| 55 | // {{{ function run() |
| 56 | |
| 57 | public function run() |
| 58 | { |
| 59 | if (!$this->nomenu) { |
| 60 | $this->useMenu(); |
| 61 | } else { |
| 62 | $this->assign('menu', false); |
| 63 | } |
| 64 | $this->_run('xnet/skin.tpl'); |
| 65 | } |
| 66 | |
| 67 | // }}} |
| 68 | // {{{ function setType |
| 69 | |
| 70 | public function setType($type) |
| 71 | { |
| 72 | $this->assign('xnet_type', strtolower($type)); |
| 73 | } |
| 74 | |
| 75 | // }}} |
| 76 | // {{{ function useMenu |
| 77 | |
| 78 | private function useMenu() |
| 79 | { |
| 80 | global $globals; |
| 81 | |
| 82 | $menu = array(); |
| 83 | |
| 84 | $sub = array(); |
| 85 | $sub['tous les groupes'] = 'plan'; |
| 86 | $sub['documentation'] = 'Xnet'; |
| 87 | if (S::user()->type == 'xnet') { |
| 88 | $sub['mon compte'] = 'edit'; |
| 89 | $sub['mes préférences'] = $globals->xnet->xorg_baseurl . 'prefs'; |
| 90 | } |
| 91 | $sub['signaler un bug'] = array('href' => 'send_bug/'.$_SERVER['REQUEST_URI'], 'class' => 'popup_840x600'); |
| 92 | $menu["no_title"] = $sub; |
| 93 | |
| 94 | $perms = S::v('perms'); |
| 95 | $dim = $globals->asso('diminutif'); |
| 96 | if (S::logged() && $globals->asso()) { |
| 97 | $sub = array(); |
| 98 | $sub['présentation'] = "login/$dim/"; |
| 99 | if ($perms->hasFlag('groupannu')) { |
| 100 | $sub['annuaire du groupe'] = "$dim/annuaire"; |
| 101 | $sub['trombinoscope'] = "$dim/trombi"; |
| 102 | } |
| 103 | if ($perms->hasFlag('groupmember')) { |
| 104 | if ($globals->asso('forum')) { |
| 105 | $sub['forum'] = "$dim/forum"; |
| 106 | } |
| 107 | if ($globals->asso('mail_domain')) { |
| 108 | $sub['listes de diffusion'] = "$dim/lists"; |
| 109 | } |
| 110 | if ($globals->asso('has_nl')) { |
| 111 | $sub['newsletter'] = "$dim/nl"; |
| 112 | } |
| 113 | } |
| 114 | $sub['événement'] = "$dim/events"; |
| 115 | if ($perms->hasFlag('groupmember')) { |
| 116 | $sub['télépaiement'] = "$dim/payment"; |
| 117 | } |
| 118 | |
| 119 | $menu[$globals->asso('nom')] = $sub; |
| 120 | } |
| 121 | |
| 122 | if ($globals->asso() && is_object($perms) && $perms->hasFlag('groupadmin')) { |
| 123 | $sub = array(); |
| 124 | $sub['modifier l\'accueil'] = "$dim/edit"; |
| 125 | $sub['gérer les annonces'] = "$dim/admin/announces"; |
| 126 | if ($globals->asso('mail_domain')) { |
| 127 | $sub['envoyer un mail'] = "$dim/mail"; |
| 128 | $sub['créer une liste'] = "$dim/lists/create"; |
| 129 | $sub['créer un alias'] = "$dim/alias/create"; |
| 130 | } |
| 131 | if (!$globals->asso('has_nl')) { |
| 132 | $sub['créer la newsletter'] = "$dim/admin/nl/enable"; |
| 133 | } |
| 134 | if (S::admin()) { |
| 135 | $sub['gérer les groupes'] = array('href' => 'admin', 'style' => 'color: gray;'); |
| 136 | $sub['clear cache'] = array('href' => 'purge_cache?token=' . S::v('xsrf_token'), 'style' => 'color: gray;'); |
| 137 | } |
| 138 | $menu['Administrer'] = $sub; |
| 139 | } elseif (S::admin()) { |
| 140 | $sub = array(); |
| 141 | $sub['gérer les groupes'] = 'admin'; |
| 142 | $sub['clear cache'] = 'purge_cache?token=' . S::v('xsrf_token'); |
| 143 | $menu['Administrer'] = $sub; |
| 144 | } |
| 145 | |
| 146 | $this->assign('menu', $menu); |
| 147 | } |
| 148 | |
| 149 | // }}} |
| 150 | } |
| 151 | |
| 152 | // {{{ function list_all_my_groups |
| 153 | |
| 154 | function list_all_my_groups($params) |
| 155 | { |
| 156 | if (!S::logged()) { |
| 157 | return; |
| 158 | } |
| 159 | $res = XDB::iterRow('SELECT a.nom, a.diminutif |
| 160 | FROM groups AS a |
| 161 | INNER JOIN group_members AS m ON m.asso_id = a.id |
| 162 | WHERE m.uid = {?}', S::i('uid')); |
| 163 | $links = '<a href="exit">déconnexion</a>'; |
| 164 | $html = '<div>Mes groupes (' . $links . ') :</div>'; |
| 165 | while (list($nom, $mini) = $res->next()) { |
| 166 | $html .= "<span class='gp'>• <a href='login/$mini'>$nom</a></span>"; |
| 167 | } |
| 168 | return $html; |
| 169 | } |
| 170 | |
| 171 | // }}} |
| 172 | // {{{ cat_pp |
| 173 | |
| 174 | function cat_pp($cat) |
| 175 | { |
| 176 | $trans = array( |
| 177 | 'groupesx' => 'Groupes X' , |
| 178 | 'binets' => 'Binets' , |
| 179 | 'institutions' => 'Institutions' , |
| 180 | 'promotions' => 'Promotions' |
| 181 | ); |
| 182 | |
| 183 | return $trans[strtolower($cat)]; |
| 184 | } |
| 185 | |
| 186 | // }}} |
| 187 | |
| 188 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: |
| 189 | ?> |