Refuse empty articles
[platal.git] / modules / newsletter.php
index a24757a..8ede54a 100644 (file)
@@ -30,12 +30,6 @@ class NewsletterModule extends PLModule
             'admin/newsletter'             => $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'),
         );
     }
 
@@ -81,7 +75,10 @@ class NewsletterModule extends PLModule
 
         require_once 'newsletter.inc.php';
 
-        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,6 +88,7 @@ class NewsletterModule extends PLModule
             $art->submit();
             $page->assign('submited', true);
         }
+        $page->addCssLink('nl.css');
     }
 
     function handler_admin_nl(&$page, $new = false) {
@@ -161,40 +159,6 @@ class NewsletterModule extends PLModule
         $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;
-        }
-    }
 }
 
 ?>