X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fnewsletter.php;h=4a3c75c56d919407bfa8bbd18f0c7e645637275e;hb=2af95f6f349a10ea8814b5d4a95bb571d649357a;hp=4eae2c05c310bd26869927e90a58e1bf116bd8eb;hpb=bc0903c71a064931efd8677b246e7f31c194fb82;p=platal.git diff --git a/modules/newsletter.php b/modules/newsletter.php index 4eae2c0..4a3c75c 100644 --- a/modules/newsletter.php +++ b/modules/newsletter.php @@ -1,6 +1,6 @@ $this->make_hook('admin_nl', AUTH_MDP, 'admin'), 'admin/newsletter/categories' => $this->make_hook('admin_nl_cat', AUTH_MDP, 'admin'), 'admin/newsletter/edit' => $this->make_hook('admin_nl_edit', AUTH_MDP, 'admin'), - - 'ax' => $this->make_hook('ax', AUTH_COOKIE), - 'ax/show' => $this->make_hook('ax_show', AUTH_COOKIE), - 'ax/submit' => $this->make_hook('ax_submit', AUTH_MDP), - 'ax/edit' => $this->make_hook('ax_submit', AUTH_MDP), - 'admin/axletter/rights' => $this->make_hook('admin_ax_rights', AUTH_MDP, 'admin'), ); } @@ -80,8 +74,13 @@ class NewsletterModule extends PLModule $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')) { @@ -91,33 +90,35 @@ class NewsletterModule extends PLModule $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) { Newsletter::create(); pl_redirect("admin/newsletter"); } - + $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'); @@ -131,14 +132,14 @@ class NewsletterModule extends PLModule 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')) { @@ -149,52 +150,19 @@ class NewsletterModule extends PLModule } $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); } - - function handler_ax(&$page, $action = null) - { - require_once 'newsletter.inc.php'; - - $page->changeTpl('newsletter/ax.tpl'); - $page->assign('xorg_title','Polytechnique.org - Envois de l\'AX'); - - switch ($action) { - case 'out': AXLetter::unsubscribe(); break; - case 'in': AXLetter::subscribe(); break; - default: ; - } - - $perm = AXLetter::hasPerms(); - if ($perm) { - $waiting = AXLetter::awaiting(); - if ($waiting) { - $new = new AXLetter($waiting); - $page->assign('new', $new); - } - } - $page->assign('axs', AXLetter::subscriptionState()); - $page->assign('ax_list', AXLetter::listSent()); - $page->assign('ax_rights', AXLetter::hasPerms()); - } - - function handler_ax_submit(&$page) - { - require_once('newsletter.inc.php'); - if (!AXLetter::hasPerms()) { - return PL_FORBIDDEN; - } - } } +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?>