2 /***************************************************************************
3 * Copyright (C) 2003-2006 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
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. *
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. *
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 *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 require_once("xorg.inc.php");
23 new_admin_page('admin/evenements.tpl');
24 $page->assign('xorg_title','Polytechnique.org - Administration - Evenements');
26 $arch = Env
::get('arch', 0);
27 $evid = Post
::getInt('evt_id');
28 $page->assign('arch', $arch);
30 switch(Post
::get('action')) {
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);
37 $globals->xdb
->execute('UPDATE evenements SET creation_date = creation_date, flags = CONCAT(flags,",valide") WHERE id = {?}', $evid);
41 $globals->xdb
->execute('UPDATE evenements SET creation_date = creation_date, flags = REPLACE(flags,"valide", "") WHERE id = {?}', $evid);
45 $globals->xdb
->execute('DELETE from evenements WHERE id = {?}', $evid);
49 $globals->xdb
->execute('UPDATE evenements SET creation_date = creation_date, flags = CONCAT(flags,",archive") WHERE id = {?}', $evid);
53 $globals->xdb
->execute('UPDATE evenements SET creation_date = creation_date, flags = REPLACE(flags,"archive","") WHERE id = {?}', $evid);
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);
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);
73 $select .= "<option value=\"$p_stamp\"" . (($p_stamp == strtr($peremption, array("-" => ""))) ?
" selected" : "")."> $day / $month / $year</option>\n";
75 $page->assign('select',$select);
80 if ($action != "Editer") {
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
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));