I should have merged before last commit...
[platal.git] / modules / newsletter.php
index 7ea958e..809caef 100644 (file)
@@ -216,14 +216,36 @@ class NewsletterModule extends PLModule
         $page->assign('nl_list', $nl->listAllIssues());
     }
 
-    function handler_admin_nl_groups($page)
+    function handler_admin_nl_groups($page, $sort = 'id', $order = 'ASC')
     {
         require_once 'newsletter.inc.php';
 
+        static $titles = array(
+            'id'         => 'Id',
+            'group_name' => 'Groupe',
+            'name'       => 'Titre',
+            'custom_css' => 'CSS spécifique',
+            'criteria'   => 'Critères actifs'
+        );
+        static $next_orders = array(
+            'ASC'  => 'DESC',
+            'DESC' => 'ASC'
+        );
+
+        if (!array_key_exists($sort, $titles)) {
+            $sort = 'id';
+        }
+        if (!in_array($order, array('ASC', 'DESC'))) {
+            $order = 'ASC';
+        }
+
         $page->changeTpl('newsletter/admin_all.tpl');
         $page->setTitle('Administration - Newsletters : Liste des Newsletters');
-
-        $page->assign('nls', Newsletter::getAll());
+        $page->assign('nls', Newsletter::getAll($sort, $order));
+        $page->assign('sort', $sort);
+        $page->assign('order', $order);
+        $page->assign('next_order', $next_orders[$order]);
+        $page->assign('titles', $titles);
     }
 
     function handler_admin_nl_edit($page, $nid = 'last', $aid = null, $action = 'edit') {
@@ -247,6 +269,7 @@ class NewsletterModule extends PLModule
 
         // Convert NLIssue error messages to human-readable errors
         $error_msgs = array(
+            NLIssue::ERROR_INVALID_REPLY_TO => "L'adresse de réponse est invalide.",
             NLIssue::ERROR_INVALID_SHORTNAME => "Le nom court est invalide ou vide.",
             NLIssue::ERROR_INVALID_UFC => "Le filtre des destinataires est invalide.",
             NLIssue::ERROR_TOO_LONG_UFC => "Le nombre de matricules AX renseigné est trop élevé.",
@@ -261,6 +284,7 @@ class NewsletterModule extends PLModule
             $issue->title_mail = Post::s('title_mail');
             $issue->head       = Post::s('head');
             $issue->signature  = Post::s('signature');
+            $issue->reply_to   = Post::s('reply_to');
 
             if ($issue->isEditable()) {
                 // Date and shortname may only be modified for pending NLs, otherwise all links get broken.