Builds basic statistics page for NLs.
authorStéphane Jacob <sj@m4x.org>
Thu, 3 Nov 2011 09:55:26 +0000 (10:55 +0100)
committerStéphane Jacob <sj@m4x.org>
Thu, 3 Nov 2011 09:57:37 +0000 (10:57 +0100)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
include/newsletter.inc.php
modules/axletter.php
modules/epletter.php
modules/newsletter.php
modules/xnetnl.php
templates/newsletter/index.tpl
templates/newsletter/statistics.tpl [new file with mode: 0644]

index 7733f02..9016bdd 100644 (file)
@@ -567,13 +567,38 @@ class NewsLetter
         }
     }
 
+    /** Get the prefix to use for all 'stat' pages of this NL.
+     */
+    public function statPrefix($enforce_xnet = true, $with_group = true)
+    {
+        if (!empty($GLOBALS['IS_XNET_SITE'])) {
+            if ($with_group) {
+                return $this->group . '/stat/nl';
+            } else {
+                return 'stat/nl';
+            }
+        }
+        switch ($this->group) {
+        case self::GROUP_XORG:
+            return 'stat/newsletter';
+        case self::GROUP_AX:
+            return 'ax/stat';
+        case self::GROUP_EP:
+            return 'epletter/stat';
+        default:
+            // Don't display groups NLs on X.org
+            assert(!$enforce_xnet);
+        }
+    }
+
     /** Get links for nl pages.
      */
     public function adminLinks()
     {
         return array(
             'index' => array('link' => $this->prefix(), 'title' => 'Archives'),
-            'admin' => array('link' => $this->adminPrefix(), 'title' => 'Administrer')
+            'admin' => array('link' => $this->adminPrefix(), 'title' => 'Administrer'),
+            'stats' => array('link' => $this->statPrefix(), 'title' => 'Statistiques')
         );
     }
 
index 4ebf134..a09cb72 100644 (file)
@@ -36,6 +36,7 @@ class AXLetterModule extends NewsletterModule
             'ax/admin/edit/cancel' => $this->make_hook('admin_nl_cancel', AUTH_PASSWD, 'user'),
             'ax/admin/edit/delete' => $this->make_hook('admin_nl_delete', AUTH_PASSWD, 'user'),
             'ax/admin/categories'  => $this->make_hook('admin_nl_cat',    AUTH_PASSWD, 'user'),
+            'ax/stat'              => $this->make_hook('stat_nl',         AUTH_PASSWD, 'user')
         );
     }
 
index f3667d3..c3799aa 100644 (file)
@@ -36,6 +36,7 @@ class EPLetterModule extends NewsletterModule
             'epletter/admin/edit/cancel' => $this->make_hook('admin_nl_cancel', AUTH_PASSWD, 'user'),
             'epletter/admin/edit/delete' => $this->make_hook('admin_nl_delete', AUTH_PASSWD, 'user'),
             'epletter/admin/categories'  => $this->make_hook('admin_nl_cat',    AUTH_PASSWD, 'user'),
+            'epletter/stat'              => $this->make_hook('stat_nl',         AUTH_PASSWD, 'user')
         );
     }
 
index 809caef..199bab6 100644 (file)
@@ -34,6 +34,7 @@ class NewsletterModule extends PLModule
             'admin/newsletter/categories'  => $this->make_hook('admin_nl_cat',    AUTH_PASSWD, 'admin'),
             'admin/newsletter/edit'        => $this->make_hook('admin_nl_edit',   AUTH_PASSWD, 'admin'),
             'admin/newsletter/edit/delete' => $this->make_hook('admin_nl_delete', AUTH_PASSWD, 'admin'),
+            'stat/newsletter'              => $this->make_hook('stat_nl',         AUTH_PASSWD, 'admin')
             // Automatic mailing is disabled for X.org NL
 //            'admin/newsletter/edit/cancel' => $this->make_hook('cancel', AUTH_PASSWD, 'admin'),
 //            'admin/newsletter/edit/valid'  => $this->make_hook('valid',  AUTH_PASSWD, 'admin'),
@@ -491,6 +492,21 @@ class NewsletterModule extends PLModule
         $table_editor->on_delete(null, null);
         $table_editor->apply($page, $action, $id);
     }
+
+    function handler_stat_nl($page)
+    {
+        $nl = $this->getNl();
+        if (!$nl) {
+            return PL_NOT_FOUND;
+        }
+        if (!$nl->mayEdit()) {
+            return PL_FORBIDDEN;
+        }
+
+        $page->setTitle('Statistiques - Newsletter');
+        $page->changeTpl('newsletter/statistics.tpl');
+        $page->assign_by_ref('nl', $nl);
+    }
 }
 
 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
index f8e9150..b326618 100644 (file)
@@ -36,6 +36,7 @@ class XnetNlModule extends NewsletterModule
             '%grp/admin/nl/edit/cancel' => $this->make_hook('admin_nl_cancel', AUTH_PASSWD, 'groupadmin'),
             '%grp/admin/nl/edit/valid'  => $this->make_hook('admin_nl_valid',  AUTH_PASSWD, 'groupadmin'),
             '%grp/admin/nl/categories'  => $this->make_hook('admin_nl_cat',    AUTH_PASSWD, 'groupadmin'),
+            '%grp/stat'                 => $this->make_hook('stat_nl',         AUTH_PASSWD, 'groupadmin')
         );
     }
 
index f9fe9df..74d3ce1 100644 (file)
@@ -67,9 +67,4 @@ Tu n'es actuellement pas inscrit à la {$nl->name}.
   {/foreach}
 </table>
 
-{if $nl->mayEdit()}
-<p>Il y a actuellement {$nl->subscriberCount()} inscrits aux envois, parmi lesquels {$nl->lostSubscriberCount()} n'ont aucune redirection active.</p>
-{/if}
-
-
 {* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}
diff --git a/templates/newsletter/statistics.tpl b/templates/newsletter/statistics.tpl
new file mode 100644 (file)
index 0000000..43fa8e6
--- /dev/null
@@ -0,0 +1,29 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2011 Polytechnique.org                             *}
+{*  http://opensource.polytechnique.org/                                  *}
+{*                                                                        *}
+{*  This program is free software; you can redistribute it and/or modify  *}
+{*  it under the terms of the GNU General Public License as published by  *}
+{*  the Free Software Foundation; either version 2 of the License, or     *}
+{*  (at your option) any later version.                                   *}
+{*                                                                        *}
+{*  This program is distributed in the hope that it will be useful,       *}
+{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}
+{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}
+{*  GNU General Public License for more details.                          *}
+{*                                                                        *}
+{*  You should have received a copy of the GNU General Public License     *}
+{*  along with this program; if not, write to the Free Software           *}
+{*  Foundation, Inc.,                                                     *}
+{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
+{*                                                                        *}
+{**************************************************************************}
+
+{include file="newsletter/header.tpl" current="stats"}
+
+<p>Il y a actuellement {$nl->subscriberCount()} inscrits aux envois, parmi lesquels {$nl->lostSubscriberCount()} n'ont aucune redirection active.</p>
+
+
+
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}