0337d704 |
1 | <?php |
2 | /*************************************************************************** |
3 | * Copyright (C) 2003-2004 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('orange.tpl', AUTH_MDP); |
27 | |
28 | $res = $globals->xdb->query( |
29 | "SELECT u.promo,u.promo_sortie |
30 | FROM auth_user_md5 AS u |
31 | WHERE user_id={?}", Session::getInt('uid')); |
32 | |
33 | list($promo,$promo_sortie_old) = $res->fetchOneRow(); |
34 | $page->assign('promo_sortie_old', $promo_sortie_old); |
35 | $page->assign('promo', $promo); |
36 | |
37 | $promo_sortie = Env::get('promo_sortie'); |
38 | |
39 | if ($promo_sortie) { |
40 | $sortie_req = false; |
41 | if (!is_numeric($promo_sortie) || $promo_sortie < 1000 || $promo_sortie > 9999) |
42 | $page->trig('L\'année de sortie doit être un nombre de quatre chiffres'); |
43 | elseif ($promo_sortie < $promo + 3) |
44 | $page->trig('Trop tôt'); |
9fee7b84 |
45 | elseif ($promo_sortie == $promo_sortie_old) |
46 | $page->trig('Tu appartiens déjà à la promotion correspondante à cette année de sortie.'); |
47 | elseif ($promo_sortie == $promo + 3) |
48 | { |
49 | $globals->xdb->execute( |
50 | "UPDATE auth_user_md5 set promo_sortie={?} |
51 | WHERE user_id={?}",$promo_sortie,Session::getInt('uid')); |
52 | $page->trig('Ton statut "orange" a été supprimé.'); |
53 | $page->assign('promo_sortie_old', $promo_sortie); |
54 | } |
0337d704 |
55 | else |
56 | $page->assign('promo_sortie', $sortie_req = $promo_sortie); |
57 | |
9fee7b84 |
58 | if (Env::has('submit') && $sortie_req && ($promo_sortie_old != $sortie_req && $promo_sortie != $promo + 3)) { |
0337d704 |
59 | $myorange = new OrangeReq(Session::getInt('uid'), $sortie_req); |
60 | $myorange->submit(); |
61 | $page->assign('myorange', $myorange); |
62 | } |
63 | } |
64 | |
65 | $page->run(); |
66 | ?> |