first reimport from platal
[platal.git] / htdocs / orange.php
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');
45 else
46 $page->assign('promo_sortie', $sortie_req = $promo_sortie);
47
48 if (Env::has('submit') && $sortie_req && ($promo_sortie_old != $sortie_req)) {
49 $myorange = new OrangeReq(Session::getInt('uid'), $sortie_req);
50 $myorange->submit();
51 $page->assign('myorange', $myorange);
52 }
53 }
54
55 $page->run();
56 ?>