2 /***************************************************************************
3 * Copyright (C) 2003-2004 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');
25 $arch = Env
::get('arch', 0);
26 $evid = Post
::getInt('evt_id');
27 $page->assign('arch', $arch);
29 switch(Post
::get('action')) {
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);
36 $globals->xdb
->execute('UPDATE evenements SET creation_date = creation_date, flags = CONCAT(flags,",valide") WHERE id = {?}', $evid);
40 $globals->xdb
->execute('UPDATE evenements SET creation_date = creation_date, flags = REPLACE(flags,"valide", "") WHERE id = {?}', $evid);
44 $globals->xdb
->execute('DELETE from evenements WHERE id = {?}', $evid);
48 $globals->xdb
->execute('UPDATE evenements SET creation_date = creation_date, flags = CONCAT(flags,",archive") WHERE id = {?}', $evid);
52 $globals->xdb
->execute('UPDATE evenements SET creation_date = creation_date, flags = REPLACE(flags,"archive","") WHERE id = {?}', $evid);
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);
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);
72 $select .= "<option value=\"$p_stamp\"" . (($p_stamp == strtr($peremption, array("-" => ""))) ?
" selected" : "")."> $day / $month / $year</option>\n";
74 $page->assign('select',$select);
79 if ($action != "Editer") {
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
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));