| 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 | require_once("xorg.inc.php"); |
| 23 | require_once("validations.inc.php"); |
| 24 | require_once("xorg.misc.inc.php"); |
| 25 | |
| 26 | new_skinned_page('nomusage.tpl', AUTH_MDP); |
| 27 | |
| 28 | $res = $globals->xdb->query( |
| 29 | "SELECT u.nom,u.nom_usage,u.flags,e.alias |
| 30 | FROM auth_user_md5 AS u |
| 31 | LEFT JOIN aliases AS e ON(u.user_id = e.id AND FIND_IN_SET('usage',e.flags)) |
| 32 | WHERE user_id={?}", Session::getInt('uid')); |
| 33 | |
| 34 | list($nom,$usage_old,$flags,$alias_old) = $res->fetchOneRow(); |
| 35 | $flags = new flagset($flags); |
| 36 | $page->assign('usage_old', $usage_old); |
| 37 | $page->assign('alias_old', $alias_old); |
| 38 | |
| 39 | $nom_usage = replace_accent(trim(Env::get('nom_usage'))); |
| 40 | $nom_usage = strtoupper($nom_usage); |
| 41 | $page->assign('usage_req', $nom_usage); |
| 42 | |
| 43 | if (Env::has('submit') && ($nom_usage != $usage_old)) { |
| 44 | // on vient de recevoir une requete, differente de l'ancien nom d'usage |
| 45 | if ($nom_usage == $nom) { |
| 46 | $page->assign('same', true); |
| 47 | } else { // le nom de mariage est distinct du nom à l'X |
| 48 | // on calcule l'alias pour l'afficher |
| 49 | $reason = Env::get('reason'); |
| 50 | if ($reason == 'other') |
| 51 | $reason = Env::get('other_reason'); |
| 52 | $myusage = new UsageReq(Session::getInt('uid'), $nom_usage, $reason); |
| 53 | $myusage->submit(); |
| 54 | $page->assign('myusage', $myusage); |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | $page->run(); |
| 59 | ?> |