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