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' => $this->make_hook('nl', AUTH_COOKIE
),
30 'nl/show' => $this->make_hook('nl_show', AUTH_COOKIE
),
31 'nl/submit' => $this->make_hook('nl_submit', AUTH_COOKIE
),
35 function handler_submit(&$page)
38 $page->changeTpl('evenements.tpl');
40 $titre = Post
::get('titre');
41 $texte = Post
::get('texte');
42 $promo_min = Post
::getInt('promo_min');
43 $promo_max = Post
::getInt('promo_max');
44 $peremption = Post
::getInt('peremption');
45 $valid_mesg = Post
::get('valid_mesg');
46 $action = Post
::get('action');
48 $page->assign('titre', $titre);
49 $page->assign('texte', $texte);
50 $page->assign('promo_min', $promo_min);
51 $page->assign('promo_max', $promo_max);
52 $page->assign('peremption', $peremption);
53 $page->assign('valid_mesg', $valid_mesg);
54 $page->assign('action', strtolower($action));
56 if ($action == 'Confirmer') {
57 $texte = preg_replace('/((http|ftp)+(s)?:\/\/[^<>\s]+)/i',
58 '<a href=\"\\0\">\\0</a>', $texte);
59 $texte = preg_replace('/([^,\s]+@[^,\s]+)/i',
60 '<a href=\"mailto:\\0\">\\0</a>', $texte);
61 require_once 'validations.inc.php';
62 $evtreq = new EvtReq($titre, $texte, $promo_min, $promo_max,
63 $peremption, $valid_mesg, Session
::getInt('uid'));
65 $page->assign('ok', true
);
69 for ($i = 1 ; $i < 30 ; $i++
) {
70 $time = time() +
3600 * 24 * $i;
71 $p_stamp = date('Ymd', $time);
72 $year = date('Y', $time);
73 $month = date('m', $time);
74 $day = date('d', $time);
76 $select .= "<option value=\"$p_stamp\"";
77 if ($p_stamp == strtr($peremption, array("-" => ""))) {
78 $select .= " selected='selected'";
80 $select .= "> $day / $month / $year</option>\n";
82 $page->assign('select',$select);
87 function handler_nl(&$page, $action = null
)
89 require_once 'newsletter.inc.php';
91 $page->changeTpl('newsletter/index.tpl');
92 $page->assign('xorg_title','Polytechnique.org - Lettres mensuelles');
95 case 'out': unsubscribe_nl(); break;
96 case 'in': subscribe_nl(); break;
100 $page->assign('nls', get_nl_state());
101 $page->assign_by_ref('nl_list', get_nl_list());
106 function handler_nl_show(&$page, $nid = 'last')
108 $page->changeTpl('newsletter/show.tpl');
110 require_once 'newsletter.inc.php';
112 $nl = new NewsLetter($nid);
113 $page->assign_by_ref('nl', $nl);
115 if (Post
::has('send')) {
116 $nl->sendTo(Session
::get('prenom'), Session
::get('nom'),
117 Session
::get('bestalias'), Session
::get('femme'),
118 Session
::get('mail_fmt') != 'text');
124 function handler_nl_submit(&$page)
126 $page->changeTpl('newsletter/submit.tpl');
128 require_once 'newsletter.inc.php';
130 if (Post
::has('see')) {
131 $art = new NLArticle(Post
::get('title'), Post
::get('body'), Post
::get('append'));
132 $page->assign('art', $art);
133 } elseif (Post
::has('valid')) {
134 require_once('validations.inc.php');
135 $art = new NLReq(Session
::getInt('uid'), Post
::get('title'),
136 Post
::get('body'), Post
::get('append'));
138 $page->assign('submited', true
);