74e0093f |
1 | <?php |
2 | /*************************************************************************** |
3 | * Copyright (C) 2003-2006 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 | class EventsModule extends PLModule |
23 | { |
24 | function handlers() |
25 | { |
26 | return array( |
27 | 'events/submit' => $this->make_hook('submit', AUTH_MDP), |
28 | ); |
29 | } |
30 | |
31 | function handler_submit(&$page) |
32 | { |
33 | global $globals; |
34 | $page->changeTpl('evenements.tpl'); |
35 | |
36 | $titre = Post::get('titre'); |
37 | $texte = Post::get('texte'); |
38 | $promo_min = Post::getInt('promo_min'); |
39 | $promo_max = Post::getInt('promo_max'); |
40 | $peremption = Post::getInt('peremption'); |
41 | $valid_mesg = Post::get('valid_mesg'); |
42 | $action = Post::get('action'); |
43 | |
44 | $page->assign('titre', $titre); |
45 | $page->assign('texte', $texte); |
46 | $page->assign('promo_min', $promo_min); |
47 | $page->assign('promo_max', $promo_max); |
48 | $page->assign('peremption', $peremption); |
49 | $page->assign('valid_mesg', $valid_mesg); |
50 | $page->assign('action', strtolower($action)); |
51 | |
52 | if ($action == 'Confirmer') { |
53 | $texte = preg_replace('/((http|ftp)+(s)?:\/\/[^<>\s]+)/i', |
54 | '<a href=\"\\0\">\\0</a>', $texte); |
55 | $texte = preg_replace('/([^,\s]+@[^,\s]+)/i', |
56 | '<a href=\"mailto:\\0\">\\0</a>', $texte); |
57 | require_once 'validations.inc.php'; |
58 | $evtreq = new EvtReq($titre, $texte, $promo_min, $promo_max, |
59 | $peremption, $valid_mesg, Session::getInt('uid')); |
60 | $evtreq->submit(); |
61 | $page->assign('ok', true); |
62 | } |
63 | |
64 | $select = ''; |
65 | for ($i = 1 ; $i < 30 ; $i++) { |
66 | $time = time() + 3600 * 24 * $i; |
67 | $p_stamp = date('Ymd', $time); |
68 | $year = date('Y', $time); |
69 | $month = date('m', $time); |
70 | $day = date('d', $time); |
71 | |
72 | $select .= "<option value=\"$p_stamp\""; |
73 | if ($p_stamp == strtr($peremption, array("-" => ""))) { |
74 | $select .= " selected='selected'"; |
75 | } |
76 | $select .= "> $day / $month / $year</option>\n"; |
77 | } |
78 | $page->assign('select',$select); |
79 | |
80 | return PL_OK; |
81 | } |
82 | } |
83 | |
84 | ?> |