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( |
1a828cd4 |
27 | 'events' => $this->make_hook('ev', AUTH_COOKIE), |
d1c97e42 |
28 | 'rss' => $this->make_hook('rss', AUTH_PUBLIC), |
0535ed02 |
29 | 'send_bug' => $this->make_hook('bug', AUTH_COOKIE), |
1a828cd4 |
30 | 'events/submit' => $this->make_hook('ev_submit', AUTH_MDP), |
92423144 |
31 | 'admin/events' => $this->make_hook('admin_events', AUTH_MDP, 'admin'), |
b829e258 |
32 | |
dc767839 |
33 | 'ajax/tips' => $this->make_hook('tips', AUTH_COOKIE, '', NO_AUTH), |
34 | 'admin/tips' => $this->make_hook('admin_tips', AUTH_MDP, 'admin'), |
35 | |
164ca57a |
36 | 'nl' => $this->make_hook('nl', AUTH_COOKIE), |
37 | 'nl/show' => $this->make_hook('nl_show', AUTH_COOKIE), |
383eaddd |
38 | 'nl/submit' => $this->make_hook('nl_submit', AUTH_MDP), |
92423144 |
39 | 'admin/newsletter' => $this->make_hook('admin_nl', AUTH_MDP, 'admin'), |
40 | 'admin/newsletter/categories' => $this->make_hook('admin_nl_cat', AUTH_MDP, 'admin'), |
41 | 'admin/newsletter/edit' => $this->make_hook('admin_nl_edit', AUTH_MDP, 'admin'), |
74e0093f |
42 | ); |
43 | } |
44 | |
8d8f7607 |
45 | function on_subscribe($forlife, $uid, $promo, $password) |
46 | { |
47 | require_once 'newsletter.inc.php'; |
48 | subscribe_nl($uid); |
49 | } |
50 | |
dc767839 |
51 | function get_tips($exclude = null) |
52 | { |
53 | $exclude = is_null($exclude) ? '' : ' AND id != ' . $exclude . ' '; |
54 | $priority = rand(0, 510); |
55 | do { |
56 | $priority = (int)($priority/2); |
57 | $res = XDB::query("SELECT * |
58 | FROM tips |
59 | WHERE (peremption = '0000-00-00' OR peremption > CURDATE()) |
60 | AND (promo_min = 0 OR promo_min <= {?}) |
61 | AND (promo_max = 0 OR promo_max >= {?}) |
62 | AND (priorite >= {?}) |
5d617d8d |
63 | AND (state = 'active') |
dc767839 |
64 | $exclude |
65 | ORDER BY RAND() |
66 | LIMIT 1", |
67 | S::i('promo'), S::i('promo'), $priority); |
68 | } while ($priority && !$res->numRows()); |
69 | if (!$res->numRows()) { |
70 | return null; |
71 | } |
72 | return $res->fetchOneAssoc(); |
73 | } |
74 | |
0535ed02 |
75 | function handler_bug(&$page) |
76 | { |
987f1bd2 |
77 | $page->changeTpl('bug.tpl',SIMPLE); |
78 | $page->addJsLink('close_on_esc.js'); |
79 | if (Env::has('send')) { |
80 | $page->assign('bug_sent',1); |
1e33266a |
81 | $mymail = new PlMailer(); |
987f1bd2 |
82 | $mymail->setFrom('"'.S::v('prenom').' '.S::v('nom').'" <'.S::v('bestalias').'@polytechnique.org>'); |
83 | $mymail->addTo('support+platal@polytechnique.org'); |
84 | $mymail->setSubject('Plat/al '.Env::v('task_type').' : '.Env::v('item_summary')); |
85 | $mymail->setTxtBody(Env::v('detailed_desc')); |
86 | $mymail->send(); |
87 | } |
0535ed02 |
88 | } |
89 | |
096f0dca |
90 | function handler_ev(&$page, $action = 'list', $eid = null, $pound = null) |
1a828cd4 |
91 | { |
1a828cd4 |
92 | $page->changeTpl('login.tpl'); |
dc767839 |
93 | $page->addJsLink('ajax.js'); |
94 | $page->assign('tips', $this->get_tips()); |
95 | |
08cce2ff |
96 | $res = XDB::query('SELECT date, naissance FROM auth_user_md5 |
cab08090 |
97 | WHERE user_id={?}', S::v('uid')); |
1a828cd4 |
98 | list($date, $naissance) = $res->fetchOneRow(); |
99 | |
089a5801 |
100 | // incitation à mettre à jour la fiche |
1a828cd4 |
101 | |
102 | $d2 = mktime(0, 0, 0, substr($date, 5, 2), substr($date, 8, 2), |
103 | substr($date, 0, 4)); |
104 | if( (time() - $d2) > 60 * 60 * 24 * 400 ) { |
105 | // si fiche date de + de 400j; |
106 | $page->assign('fiche_incitation', $date); |
107 | } |
108 | |
109 | // Souhaite bon anniversaire |
110 | |
111 | if (substr($naissance, 5) == date('m-d')) { |
112 | $page->assign('birthday', date('Y') - substr($naissance, 0, 4)); |
113 | } |
114 | |
089a5801 |
115 | // incitation à mettre une photo |
1a828cd4 |
116 | |
08cce2ff |
117 | $res = XDB::query('SELECT COUNT(*) FROM photo |
cab08090 |
118 | WHERE uid={?}', S::v('uid')); |
1a828cd4 |
119 | $page->assign('photo_incitation', $res->fetchOneCell() == 0); |
120 | |
089a5801 |
121 | // Incitation à se géolocaliser |
1a828cd4 |
122 | require_once 'geoloc.inc.php'; |
cab08090 |
123 | $res = localize_addresses(S::v('uid', -1)); |
1a828cd4 |
124 | $page->assign('geoloc_incitation', count($res)); |
125 | |
1a828cd4 |
126 | // ajout du lien RSS |
cab08090 |
127 | if (S::has('core_rss_hash')) { |
162370e7 |
128 | $page->setRssLink('Polytechnique.org :: News', |
129 | '/rss/'.S::v('forlife') .'/'.S::v('core_rss_hash').'/rss.xml'); |
1a828cd4 |
130 | } |
131 | |
132 | // cache les evenements lus et raffiche les evenements a relire |
4e61caea |
133 | if ($action == 'read' && $eid) { |
eadff9f9 |
134 | XDB::execute('DELETE evenements_vus.* |
135 | FROM evenements_vus AS ev |
136 | INNER JOIN evenements AS e ON e.id = ev.evt_id |
137 | WHERE peremption < NOW()'); |
08cce2ff |
138 | XDB::execute('REPLACE INTO evenements_vus VALUES({?},{?})', |
096f0dca |
139 | $eid, S::v('uid')); |
140 | pl_redirect('events#'.$pound); |
1a828cd4 |
141 | } |
142 | |
4e61caea |
143 | if ($action == 'unread' && $eid) { |
08cce2ff |
144 | XDB::execute('DELETE FROM evenements_vus |
eadff9f9 |
145 | WHERE evt_id = {?} AND user_id = {?}', |
4e61caea |
146 | $eid, S::v('uid')); |
096f0dca |
147 | pl_redirect('events#newsid'.$eid); |
1a828cd4 |
148 | } |
149 | |
150 | // affichage des evenements |
089a5801 |
151 | // annonces promos triées par présence d'une limite sur les promos |
1a828cd4 |
152 | // puis par dates croissantes d'expiration |
cab08090 |
153 | $promo = S::v('promo'); |
1a828cd4 |
154 | $sql = "SELECT e.id,e.titre,e.texte,a.user_id,a.nom,a.prenom,a.promo,l.alias AS forlife |
2f678da1 |
155 | FROM evenements AS e |
156 | INNER JOIN auth_user_md5 AS a ON e.user_id=a.user_id |
157 | INNER JOIN aliases AS l ON ( a.user_id=l.id AND l.type='a_vie' ) |
158 | LEFT JOIN evenements_vus AS ev ON (e.id = ev.evt_id AND ev.user_id = {?}) |
1a828cd4 |
159 | WHERE FIND_IN_SET(e.flags, 'valide') AND peremption >= NOW() |
160 | AND (e.promo_min = 0 || e.promo_min <= {?}) |
161 | AND (e.promo_max = 0 || e.promo_max >= {?}) |
162 | AND ev.user_id IS NULL |
163 | ORDER BY (e.promo_min != 0 AND e.promo_max != 0) DESC, e.peremption"; |
164 | $page->assign('evenement', |
cab08090 |
165 | XDB::iterator($sql, S::v('uid'), |
1a828cd4 |
166 | $promo, $promo) |
167 | ); |
168 | |
169 | $sql = "SELECT e.id,e.titre, ev.user_id IS NULL AS nonlu |
170 | FROM evenements AS e |
171 | LEFT JOIN evenements_vus AS ev ON (e.id = ev.evt_id AND ev.user_id = {?}) |
172 | WHERE FIND_IN_SET(e.flags, 'valide') AND peremption >= NOW() |
173 | AND (e.promo_min = 0 || e.promo_min <= {?}) |
174 | AND (e.promo_max = 0 || e.promo_max >= {?}) |
175 | ORDER BY (e.promo_min != 0 AND e.promo_max != 0) DESC, e.peremption"; |
176 | $page->assign('evenement_summary', |
cab08090 |
177 | XDB::iterator($sql, S::v('uid'), |
1a828cd4 |
178 | $promo, $promo) |
179 | ); |
1a828cd4 |
180 | } |
181 | |
d1c97e42 |
182 | function handler_rss(&$page, $user = null, $hash = null) |
183 | { |
184 | require_once 'rss.inc.php'; |
185 | |
186 | $uid = init_rss('rss.tpl', $user, $hash); |
187 | |
188 | $rss = XDB::iterator( |
189 | 'SELECT e.id, e.titre, e.texte, e.creation_date, |
190 | IF(u2.nom_usage = "", u2.nom, u2.nom_usage) AS nom, u2.prenom, u2.promo |
191 | FROM auth_user_md5 AS u |
192 | INNER JOIN evenements AS e ON ( (e.promo_min = 0 || e.promo_min <= u.promo) |
193 | AND (e.promo_max = 0 || e.promo_max >= u.promo) ) |
194 | INNER JOIN auth_user_md5 AS u2 ON (u2.user_id = e.user_id) |
195 | WHERE u.user_id = {?} AND FIND_IN_SET(e.flags, "valide") |
196 | AND peremption >= NOW()', $uid); |
197 | $page->assign('rss', $rss); |
198 | } |
199 | |
1a828cd4 |
200 | function handler_ev_submit(&$page) |
74e0093f |
201 | { |
74e0093f |
202 | $page->changeTpl('evenements.tpl'); |
203 | |
5e2307dc |
204 | $titre = Post::v('titre'); |
205 | $texte = Post::v('texte'); |
206 | $promo_min = Post::i('promo_min'); |
207 | $promo_max = Post::i('promo_max'); |
208 | $peremption = Post::i('peremption'); |
209 | $valid_mesg = Post::v('valid_mesg'); |
210 | $action = Post::v('action'); |
74e0093f |
211 | |
d1c97e42 |
212 | if (($promo_min > $promo_max && $promo_max != 0)|| |
2086ab7f |
213 | ($promo_min != 0 && ($promo_min <= 1900 || $promo_min >= 2020)) || |
214 | ($promo_max != 0 && ($promo_max <= 1900 || $promo_max >= 2020))) |
215 | { |
216 | $page->trig("L'intervalle de promotions n'est pas valide"); |
217 | $action = null; |
218 | } |
219 | |
edd50750 |
220 | require_once('url_catcher.inc.php'); |
221 | $texte_catch_url = url_catcher($texte); |
222 | |
74e0093f |
223 | $page->assign('titre', $titre); |
224 | $page->assign('texte', $texte); |
edd50750 |
225 | $page->assign('texte_html', $texte_catch_url); |
74e0093f |
226 | $page->assign('promo_min', $promo_min); |
227 | $page->assign('promo_max', $promo_max); |
228 | $page->assign('peremption', $peremption); |
229 | $page->assign('valid_mesg', $valid_mesg); |
230 | $page->assign('action', strtolower($action)); |
231 | |
232 | if ($action == 'Confirmer') { |
edd50750 |
233 | $texte = $texte_catch_url; |
74e0093f |
234 | require_once 'validations.inc.php'; |
235 | $evtreq = new EvtReq($titre, $texte, $promo_min, $promo_max, |
cab08090 |
236 | $peremption, $valid_mesg, S::v('uid')); |
74e0093f |
237 | $evtreq->submit(); |
238 | $page->assign('ok', true); |
239 | } |
240 | |
241 | $select = ''; |
242 | for ($i = 1 ; $i < 30 ; $i++) { |
243 | $time = time() + 3600 * 24 * $i; |
244 | $p_stamp = date('Ymd', $time); |
245 | $year = date('Y', $time); |
246 | $month = date('m', $time); |
247 | $day = date('d', $time); |
248 | |
249 | $select .= "<option value=\"$p_stamp\""; |
250 | if ($p_stamp == strtr($peremption, array("-" => ""))) { |
251 | $select .= " selected='selected'"; |
252 | } |
253 | $select .= "> $day / $month / $year</option>\n"; |
254 | } |
255 | $page->assign('select',$select); |
74e0093f |
256 | } |
b829e258 |
257 | |
dc767839 |
258 | function handler_tips(&$page, $tips = null) |
259 | { |
260 | $page->changeTpl('include/tips.tpl', NO_SKIN); |
261 | $page->assign('tips', $this->get_tips($tips)); |
262 | } |
263 | |
264 | function handler_admin_tips(&$page, $action = 'list', $id = null) |
265 | { |
266 | $page->assign('xorg_title', 'Polytechnique.org - Administration - Astuces'); |
267 | $page->assign('title', 'Gestion des Astuces'); |
268 | $table_editor = new PLTableEditor('admin/tips', 'tips', 'id'); |
269 | $table_editor->describe('peremption', 'date de péremption', true); |
270 | $table_editor->describe('promo_min', 'promo. min (0 aucune)', false); |
271 | $table_editor->describe('promo_max', 'promo. max (0 aucune)', false); |
272 | $table_editor->describe('titre', 'titre', true); |
5d617d8d |
273 | $table_editor->describe('state', 'actif', true); |
dc767839 |
274 | $table_editor->describe('text', 'texte (html) de l\'astuce', false); |
275 | $table_editor->describe('priorite', 'priorité (0=min, 256=max)', false); |
276 | $table_editor->apply($page, $action, $id); |
277 | } |
278 | |
164ca57a |
279 | function handler_nl(&$page, $action = null) |
280 | { |
281 | require_once 'newsletter.inc.php'; |
282 | |
283 | $page->changeTpl('newsletter/index.tpl'); |
284 | $page->assign('xorg_title','Polytechnique.org - Lettres mensuelles'); |
285 | |
286 | switch ($action) { |
287 | case 'out': unsubscribe_nl(); break; |
288 | case 'in': subscribe_nl(); break; |
289 | default: ; |
290 | } |
291 | |
292 | $page->assign('nls', get_nl_state()); |
1a013db7 |
293 | $page->assign('nl_list', get_nl_list()); |
164ca57a |
294 | } |
295 | |
296 | function handler_nl_show(&$page, $nid = 'last') |
b829e258 |
297 | { |
298 | $page->changeTpl('newsletter/show.tpl'); |
299 | |
300 | require_once 'newsletter.inc.php'; |
301 | |
302 | $nl = new NewsLetter($nid); |
303 | $page->assign_by_ref('nl', $nl); |
304 | |
305 | if (Post::has('send')) { |
cab08090 |
306 | $nl->sendTo(S::v('prenom'), S::v('nom'), |
307 | S::v('bestalias'), S::v('femme'), |
91f42324 |
308 | S::v('mail_fmt') != 'texte'); |
b829e258 |
309 | } |
b829e258 |
310 | } |
164ca57a |
311 | |
312 | function handler_nl_submit(&$page) |
313 | { |
314 | $page->changeTpl('newsletter/submit.tpl'); |
315 | |
316 | require_once 'newsletter.inc.php'; |
317 | |
318 | if (Post::has('see')) { |
5e2307dc |
319 | $art = new NLArticle(Post::v('title'), Post::v('body'), Post::v('append')); |
164ca57a |
320 | $page->assign('art', $art); |
321 | } elseif (Post::has('valid')) { |
322 | require_once('validations.inc.php'); |
5e2307dc |
323 | $art = new NLReq(S::v('uid'), Post::v('title'), |
324 | Post::v('body'), Post::v('append')); |
164ca57a |
325 | $art->submit(); |
326 | $page->assign('submited', true); |
327 | } |
164ca57a |
328 | } |
92423144 |
329 | |
506a46ed |
330 | function handler_admin_events(&$page, $action = 'list', $eid = null) |
331 | { |
92423144 |
332 | $page->changeTpl('admin/evenements.tpl'); |
333 | $page->assign('xorg_title','Polytechnique.org - Administration - Evenements'); |
506a46ed |
334 | $page->register_modifier('hde', 'html_entity_decode'); |
335 | |
336 | $arch = $action == 'archives'; |
337 | $page->assign('action', $action); |
338 | |
01248e3a |
339 | if (Post::v('action') == "Proposer" && $eid) { |
2086ab7f |
340 | $promo_min = Post::i('promo_min'); |
341 | $promo_max = Post::i('promo_max'); |
342 | if ($promo_min > $promo_max || |
343 | ($promo_min != 0 && ($promo_min <= 1900 || $promo_min >= 2020)) || |
344 | ($promo_max != 0 && ($promo_max <= 1900 || $promo_max >= 2020))) |
345 | { |
346 | $page->trig("L'intervalle de promotions $promo_min -> $promo_max n'est pas valide"); |
347 | $action = 'edit'; |
348 | } else { |
349 | XDB::execute('UPDATE evenements |
350 | SET titre={?}, texte={?}, peremption={?}, promo_min={?}, promo_max={?} |
351 | WHERE id = {?}', |
352 | Post::v('titre'), Post::v('texte'), Post::v('peremption'), |
353 | Post::v('promo_min'), Post::v('promo_max'), $eid); |
354 | } |
92423144 |
355 | } |
506a46ed |
356 | |
357 | if ($action == 'edit') { |
358 | $res = XDB::query('SELECT titre, texte, peremption, promo_min, promo_max |
359 | FROM evenements |
360 | WHERE id={?}', $eid); |
361 | list($titre, $texte, $peremption, $promo_min, $promo_max) = $res->fetchOneRow(); |
362 | $page->assign('titre',$titre); |
363 | $page->assign('texte',$texte); |
364 | $page->assign('promo_min',$promo_min); |
365 | $page->assign('promo_max',$promo_max); |
366 | $page->assign('peremption',$peremption); |
367 | |
368 | $select = ""; |
369 | for ($i = 1 ; $i < 30 ; $i++) { |
370 | $p_stamp=date("Ymd",time()+3600*24*$i); |
371 | $year=substr($p_stamp,0,4); |
372 | $month=substr($p_stamp,4,2); |
373 | $day=substr($p_stamp,6,2); |
374 | |
375 | $select .= "<option value=\"$p_stamp\"" |
376 | . (($p_stamp == strtr($peremption, array("-" => ""))) ? " selected" : "") |
377 | . "> $day / $month / $year</option>\n"; |
378 | } |
379 | $page->assign('select',$select); |
380 | } else { |
381 | switch ($action) { |
382 | case 'delete': |
383 | XDB::execute('DELETE from evenements |
384 | WHERE id = {?}', $eid); |
385 | break; |
386 | |
387 | case "archive": |
388 | XDB::execute('UPDATE evenements |
389 | SET creation_date = creation_date, flags = CONCAT(flags,",archive") |
390 | WHERE id = {?}', $eid); |
391 | break; |
392 | |
393 | case "unarchive": |
394 | XDB::execute('UPDATE evenements |
395 | SET creation_date = creation_date, flags = REPLACE(flags,"archive","") |
396 | WHERE id = {?}', $eid); |
397 | $action = 'archives'; |
398 | $arch = true; |
399 | break; |
400 | |
401 | case "valid": |
402 | XDB::execute('UPDATE evenements |
403 | SET creation_date = creation_date, flags = CONCAT(flags,",valide") |
404 | WHERE id = {?}', $eid); |
405 | break; |
406 | |
407 | case "unvalid": |
408 | XDB::execute('UPDATE evenements |
409 | SET creation_date = creation_date, flags = REPLACE(flags,"valide", "") |
410 | WHERE id = {?}', $eid); |
411 | break; |
412 | } |
413 | |
414 | $pid = ($eid && $action == 'preview') ? $eid : -1; |
415 | $sql = "SELECT e.id, e.titre, e.texte,e.id = $pid AS preview, |
92423144 |
416 | DATE_FORMAT(e.creation_date,'%d/%m/%Y %T') AS creation_date, |
417 | DATE_FORMAT(e.peremption,'%d/%m/%Y') AS peremption, |
418 | e.promo_min, e.promo_max, |
419 | FIND_IN_SET('valide', e.flags) AS fvalide, |
420 | FIND_IN_SET('archive', e.flags) AS farch, |
421 | u.promo, u.nom, u.prenom, a.alias AS forlife |
422 | FROM evenements AS e |
423 | INNER JOIN auth_user_md5 AS u ON(e.user_id = u.user_id) |
424 | INNER JOIN aliases AS a ON (u.user_id = a.id AND a.type='a_vie') |
425 | WHERE ".($arch ? "" : "!")."FIND_IN_SET('archive',e.flags) |
506a46ed |
426 | ORDER BY FIND_IN_SET('valide',e.flags), e.peremption DESC"; |
92423144 |
427 | $page->assign('evs', XDB::iterator($sql)); |
428 | } |
506a46ed |
429 | $page->assign('arch', $arch); |
92423144 |
430 | } |
431 | |
432 | function handler_admin_nl(&$page, $new = false) { |
163eddd2 |
433 | $page->changeTpl('newsletter/admin.tpl'); |
92423144 |
434 | $page->assign('xorg_title','Polytechnique.org - Administration - Newsletter : liste'); |
435 | require_once("newsletter.inc.php"); |
436 | |
437 | if($new) { |
438 | insert_new_nl(); |
439 | pl_redirect("admin/newsletter"); |
440 | } |
441 | |
1a013db7 |
442 | $page->assign('nl_list', get_nl_slist()); |
92423144 |
443 | } |
444 | |
445 | function handler_admin_nl_edit(&$page, $nid = 'last', $aid = null, $action = 'edit') { |
163eddd2 |
446 | $page->changeTpl('newsletter/edit.tpl'); |
92423144 |
447 | $page->assign('xorg_title','Polytechnique.org - Administration - Newsletter : Edition'); |
448 | require_once("newsletter.inc.php"); |
449 | |
450 | $nl = new NewsLetter($nid); |
451 | |
452 | if($action == 'delete') { |
453 | $nl->delArticle($aid); |
454 | pl_redirect("admin/newsletter/edit/$nid"); |
455 | } |
456 | |
457 | if($aid == 'update') { |
ed76a506 |
458 | $nl->_title = Post::v('title'); |
8269d2d6 |
459 | $nl->_title_mail= Post::v('title_mail'); |
ed76a506 |
460 | $nl->_date = Post::v('date'); |
461 | $nl->_head = Post::v('head'); |
462 | $nl->_shortname = strlen(Post::v('shortname')) ? Post::v('shortname') : null; |
463 | if (preg_match('/^[-a-z0-9]*$/i', $nl->_shortname) && !is_numeric($nl->_shortname)) { |
464 | $nl->save(); |
465 | } else { |
466 | $page->trig('Le nom de la NL n\'est pas valide'); |
467 | pl_redirect('admin/newsletter/edit/' . $nl->_id); |
468 | } |
92423144 |
469 | } |
470 | |
471 | if(Post::v('save')) { |
472 | $art = new NLArticle(Post::v('title'), Post::v('body'), Post::v('append'), |
473 | $aid, Post::v('cid'), Post::v('pos')); |
474 | $nl->saveArticle($art); |
475 | pl_redirect("admin/newsletter/edit/$nid"); |
476 | } |
477 | |
ed76a506 |
478 | if($action == 'edit' && $aid != 'update') { |
92423144 |
479 | $eaid = $aid; |
480 | if(Post::has('title')) { |
481 | $art = new NLArticle(Post::v('title'), Post::v('body'), Post::v('append'), |
482 | $eaid, Post::v('cid'), Post::v('pos')); |
483 | } else { |
484 | $art = ($eaid == 'new') ? new NLArticle() : $nl->getArt($eaid); |
485 | } |
486 | $page->assign('art', $art); |
487 | } |
488 | |
489 | $page->assign_by_ref('nl',$nl); |
490 | } |
491 | function handler_admin_nl_cat(&$page, $action = 'list', $id = null) { |
92423144 |
492 | $page->assign('xorg_title','Polytechnique.org - Administration - Newsletter : Catégories'); |
493 | $page->assign('title', 'Gestion des catégories de la newsletter'); |
494 | $table_editor = new PLTableEditor('admin/newsletter/categories','newsletter_cat','cid'); |
495 | $table_editor->describe('titre','intitulé',true); |
496 | $table_editor->describe('pos','position',true); |
497 | $table_editor->apply($page, $action, $id); |
498 | } |
499 | |
74e0093f |
500 | } |
501 | |
502 | ?> |