284e2ca909b6c50429fc983e66660f4abd4b2318
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 class EventsModule
extends PLModule
27 'events/submit' => $this->make_hook('submit', AUTH_MDP
),
29 'nl/show' => $this->make_hook('nl', AUTH_COOKIE
),
33 function handler_submit(&$page)
36 $page->changeTpl('evenements.tpl');
38 $titre = Post
::get('titre');
39 $texte = Post
::get('texte');
40 $promo_min = Post
::getInt('promo_min');
41 $promo_max = Post
::getInt('promo_max');
42 $peremption = Post
::getInt('peremption');
43 $valid_mesg = Post
::get('valid_mesg');
44 $action = Post
::get('action');
46 $page->assign('titre', $titre);
47 $page->assign('texte', $texte);
48 $page->assign('promo_min', $promo_min);
49 $page->assign('promo_max', $promo_max);
50 $page->assign('peremption', $peremption);
51 $page->assign('valid_mesg', $valid_mesg);
52 $page->assign('action', strtolower($action));
54 if ($action == 'Confirmer') {
55 $texte = preg_replace('/((http|ftp)+(s)?:\/\/[^<>\s]+)/i',
56 '<a href=\"\\0\">\\0</a>', $texte);
57 $texte = preg_replace('/([^,\s]+@[^,\s]+)/i',
58 '<a href=\"mailto:\\0\">\\0</a>', $texte);
59 require_once 'validations.inc.php';
60 $evtreq = new EvtReq($titre, $texte, $promo_min, $promo_max,
61 $peremption, $valid_mesg, Session
::getInt('uid'));
63 $page->assign('ok', true
);
67 for ($i = 1 ; $i < 30 ; $i++
) {
68 $time = time() +
3600 * 24 * $i;
69 $p_stamp = date('Ymd', $time);
70 $year = date('Y', $time);
71 $month = date('m', $time);
72 $day = date('d', $time);
74 $select .= "<option value=\"$p_stamp\"";
75 if ($p_stamp == strtr($peremption, array("-" => ""))) {
76 $select .= " selected='selected'";
78 $select .= "> $day / $month / $year</option>\n";
80 $page->assign('select',$select);
85 function handler_nl(&$page, $nid = 'last')
87 $page->changeTpl('newsletter/show.tpl');
89 require_once 'newsletter.inc.php';
91 $nl = new NewsLetter($nid);
92 $page->assign_by_ref('nl', $nl);
94 if (Post
::has('send')) {
95 $nl->sendTo(Session
::get('prenom'), Session
::get('nom'),
96 Session
::get('bestalias'), Session
::get('femme'),
97 Session
::get('mail_fmt') != 'text');