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 | new_admin_page('admin/evenements.tpl'); |
d9a33f98 |
24 | $page->assign('xorg_title','Polytechnique.org - Administration - Evenements'); |
0337d704 |
25 | |
26 | $arch = Env::get('arch', 0); |
27 | $evid = Post::getInt('evt_id'); |
28 | $page->assign('arch', $arch); |
29 | |
30 | switch(Post::get('action')) { |
31 | case "Proposer": |
32 | $globals->xdb->execute('UPDATE evenements SET titre={?}, texte={?}, peremption={?}, promo_min={?}, promo_max={?} WHERE id = {?}', |
33 | Post::get('titre'), Post::get('texte'), Post::get('peremption'), Post::get('promo_min'), Post::get('promo_max'), $evid); |
34 | break; |
35 | |
36 | case "Valider": |
37 | $globals->xdb->execute('UPDATE evenements SET creation_date = creation_date, flags = CONCAT(flags,",valide") WHERE id = {?}', $evid); |
38 | break; |
39 | |
40 | case "Invalider": |
41 | $globals->xdb->execute('UPDATE evenements SET creation_date = creation_date, flags = REPLACE(flags,"valide", "") WHERE id = {?}', $evid); |
42 | break; |
43 | |
44 | case "Supprimer": |
45 | $globals->xdb->execute('DELETE from evenements WHERE id = {?}', $evid); |
46 | break; |
47 | |
48 | case "Archiver": |
49 | $globals->xdb->execute('UPDATE evenements SET creation_date = creation_date, flags = CONCAT(flags,",archive") WHERE id = {?}', $evid); |
50 | break; |
51 | |
52 | case "Desarchiver": |
53 | $globals->xdb->execute('UPDATE evenements SET creation_date = creation_date, flags = REPLACE(flags,"archive","") WHERE id = {?}', $evid); |
54 | break; |
55 | |
56 | case "Editer": |
57 | $res = $globals->xdb->query('SELECT titre, texte, peremption, promo_min, promo_max FROM evenements WHERE id={?}', $evid); |
58 | list($titre, $texte, $peremption, $promo_min, $promo_max) = $res->fetchOneRow(); |
59 | $page->assign('mode', 'edit'); |
60 | $page->assign('titre',$titre); |
61 | $page->assign('texte',$texte); |
62 | $page->assign('promo_min',$promo_min); |
63 | $page->assign('promo_max',$promo_max); |
64 | $page->assign('peremption',$peremption); |
65 | |
66 | $select = ""; |
67 | for ($i = 1 ; $i < 30 ; $i++) { |
68 | $p_stamp=date("Ymd",time()+3600*24*$i); |
69 | $year=substr($p_stamp,0,4); |
70 | $month=substr($p_stamp,4,2); |
71 | $day=substr($p_stamp,6,2); |
72 | |
73 | $select .= "<option value=\"$p_stamp\"" . (($p_stamp == strtr($peremption, array("-" => ""))) ? " selected" : "")."> $day / $month / $year</option>\n"; |
74 | } |
75 | $page->assign('select',$select); |
76 | |
77 | break; |
78 | } |
79 | |
80 | if ($action != "Editer") { |
81 | |
82 | $sql = "SELECT e.id, e.titre, e.texte, |
83 | DATE_FORMAT(e.creation_date,'%d/%m/%Y %T') AS creation_date, |
84 | DATE_FORMAT(e.peremption,'%d/%m/%Y') AS peremption, |
85 | e.promo_min, e.promo_max, |
86 | FIND_IN_SET('valide', e.flags) AS fvalide, |
87 | FIND_IN_SET('archive', e.flags) AS farch, |
88 | u.promo, u.nom, u.prenom, a.alias AS forlife |
89 | FROM evenements AS e |
90 | INNER JOIN auth_user_md5 AS u ON(e.user_id = u.user_id) |
91 | INNER JOIN aliases AS a ON (u.user_id = a.id AND a.type='a_vie') |
92 | WHERE ".($arch ? "" : "!")."FIND_IN_SET('archive',e.flags) |
93 | ORDER BY FIND_IN_SET('valide',e.flags), peremption"; |
94 | $page->assign('evs', $globals->xdb->iterator($sql)); |
95 | } |
96 | |
97 | $page->run(); |
98 | ?> |