migrate newsletter/show.php => nl/show
[platal.git] / modules / events.php
CommitLineData
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
22class EventsModule extends PLModule
23{
24 function handlers()
25 {
26 return array(
27 'events/submit' => $this->make_hook('submit', AUTH_MDP),
b829e258 28
29 'nl/show' => $this->make_hook('nl', AUTH_COOKIE),
74e0093f 30 );
31 }
32
33 function handler_submit(&$page)
34 {
35 global $globals;
36 $page->changeTpl('evenements.tpl');
37
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');
45
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));
53
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'));
62 $evtreq->submit();
63 $page->assign('ok', true);
64 }
65
66 $select = '';
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);
73
74 $select .= "<option value=\"$p_stamp\"";
75 if ($p_stamp == strtr($peremption, array("-" => ""))) {
76 $select .= " selected='selected'";
77 }
78 $select .= "> $day / $month / $year</option>\n";
79 }
80 $page->assign('select',$select);
81
82 return PL_OK;
83 }
b829e258 84
85 function handler_nl(&$page, $nid = 'last')
86 {
87 $page->changeTpl('newsletter/show.tpl');
88
89 require_once 'newsletter.inc.php';
90
91 $nl = new NewsLetter($nid);
92 $page->assign_by_ref('nl', $nl);
93
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');
98 }
99
100 return PL_OK;
101 }
74e0093f 102}
103
104?>