<?php
/***************************************************************************
- * Copyright (C) 2003-2006 Polytechnique.org *
+ * Copyright (C) 2003-2007 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
);
}
- function on_subscribe($forlife, $uid, $promo, $password)
- {
- require_once 'newsletter.inc.php';
- subscribe_nl($uid);
- }
-
function handler_nl(&$page, $action = null)
{
require_once 'newsletter.inc.php';
$page->assign('xorg_title','Polytechnique.org - Lettres mensuelles');
switch ($action) {
- case 'out': unsubscribe_nl(); break;
- case 'in': subscribe_nl(); break;
+ case 'out': Newsletter::unsubscribe(); break;
+ case 'in': Newsletter::subscribe(); break;
default: ;
}
- $page->assign('nls', get_nl_state());
- $page->assign('nl_list', get_nl_list());
+ $page->assign('nls', Newsletter::subscriptionState());
+ $page->assign('nl_list', Newsletter::listSent());
}
function handler_nl_show(&$page, $nid = 'last')
$page->changeTpl('newsletter/submit.tpl');
require_once 'newsletter.inc.php';
+ require_once 'wiki.inc.php';
+ wiki_require_page('Xorg.LettreMensuelle');
- if (Post::has('see')) {
+ if (Post::has('see') || (Post::has('valid') && (!trim(Post::v('title')) || !trim(Post::v('body'))))) {
+ if (!Post::has('see')) {
+ $page->trig("L'article doit avoir un titre et un contenu");
+ }
$art = new NLArticle(Post::v('title'), Post::v('body'), Post::v('append'));
$page->assign('art', $art);
} elseif (Post::has('valid')) {
$art->submit();
$page->assign('submited', true);
}
+ $page->addCssLink('nl.css');
}
function handler_admin_nl(&$page, $new = false) {
$page->changeTpl('newsletter/admin.tpl');
$page->assign('xorg_title','Polytechnique.org - Administration - Newsletter : liste');
require_once("newsletter.inc.php");
-
+
if($new) {
- insert_new_nl();
- pl_redirect("admin/newsletter");
+ Newsletter::create();
+ pl_redirect("admin/newsletter");
}
-
- $page->assign('nl_list', get_nl_slist());
+
+ $page->assign('nl_list', Newsletter::listAll());
}
-
+
function handler_admin_nl_edit(&$page, $nid = 'last', $aid = null, $action = 'edit') {
$page->changeTpl('newsletter/edit.tpl');
- $page->assign('xorg_title','Polytechnique.org - Administration - Newsletter : Edition');
+ $page->addCssLink('nl.css');
+ $page->assign('xorg_title','Polytechnique.org - Administration - Newsletter : Edition');
require_once("newsletter.inc.php");
-
+
$nl = new NewsLetter($nid);
-
+
if($action == 'delete') {
$nl->delArticle($aid);
pl_redirect("admin/newsletter/edit/$nid");
}
-
+
if($aid == 'update') {
$nl->_title = Post::v('title');
$nl->_title_mail= Post::v('title_mail');
pl_redirect('admin/newsletter/edit/' . $nl->_id);
}
}
-
+
if(Post::v('save')) {
$art = new NLArticle(Post::v('title'), Post::v('body'), Post::v('append'),
$aid, Post::v('cid'), Post::v('pos'));
$nl->saveArticle($art);
pl_redirect("admin/newsletter/edit/$nid");
}
-
+
if($action == 'edit' && $aid != 'update') {
$eaid = $aid;
if(Post::has('title')) {
}
$page->assign('art', $art);
}
-
+
$page->assign_by_ref('nl',$nl);
}
function handler_admin_nl_cat(&$page, $action = 'list', $id = null) {
- $page->assign('xorg_title','Polytechnique.org - Administration - Newsletter : Catégories');
- $page->assign('title', 'Gestion des catégories de la newsletter');
+ $page->assign('xorg_title','Polytechnique.org - Administration - Newsletter : Catégories');
+ $page->assign('title', 'Gestion des catégories de la newsletter');
$table_editor = new PLTableEditor('admin/newsletter/categories','newsletter_cat','cid');
- $table_editor->describe('titre','intitulé',true);
+ $table_editor->describe('titre','intitulé',true);
$table_editor->describe('pos','position',true);
$table_editor->apply($page, $action, $id);
- }
-
+ }
}
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
?>