Proof of concept:
[platal.git] / htdocs / orange.php
CommitLineData
0337d704 1<?php
2/***************************************************************************
50a40a33 3 * Copyright (C) 2003-2006 Polytechnique.org *
0337d704 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
22require_once("xorg.inc.php");
23require_once("validations.inc.php");
24require_once("xorg.misc.inc.php");
25
26new_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
33list($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
39if ($promo_sortie) {
b3094fc4 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 }
44 elseif ($promo_sortie < $promo + 3) {
45 $page->trig('Trop tôt');
46 }
47 elseif ($promo_sortie == $promo_sortie_old) {
48 $page->trig('Tu appartiens déjà à la promotion correspondante à cette année de sortie.');
49 }
50 elseif ($promo_sortie == $promo + 3) {
51 $globals->xdb->execute(
39b1d507 52 "UPDATE auth_user_md5 set promo_sortie={?}
53 WHERE user_id={?}",$promo_sortie,Session::getInt('uid'));
b3094fc4 54 $page->trig('Ton statut "orange" a été supprimé.');
55 $page->assign('promo_sortie_old', $promo_sortie);
56 }
57 else {
58 $page->assign('promo_sortie', $sortie_req = $promo_sortie);
59 }
0337d704 60
b3094fc4 61 if (Env::has('submit') && $sortie_req && ($promo_sortie_old != $sortie_req && $promo_sortie != $promo + 3)) {
62 $myorange = new OrangeReq(Session::getInt('uid'), $sortie_req);
63 $myorange->submit();
64 $page->assign('myorange', $myorange);
65 }
0337d704 66}
67
68$page->run();
b3094fc4 69# vim: set et sts=4 ts=4 sw=4:
0337d704 70?>