From a8d1ec11ebf178b8b308ead4d55838d473a8c79b Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Thu, 3 Nov 2011 10:55:26 +0100 Subject: [PATCH] Builds basic statistics page for NLs. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Jacob --- include/newsletter.inc.php | 27 ++++++++++++++++++++++++++- modules/axletter.php | 1 + modules/epletter.php | 1 + modules/newsletter.php | 16 ++++++++++++++++ modules/xnetnl.php | 1 + templates/newsletter/index.tpl | 5 ----- templates/newsletter/statistics.tpl | 29 +++++++++++++++++++++++++++++ 7 files changed, 74 insertions(+), 6 deletions(-) create mode 100644 templates/newsletter/statistics.tpl diff --git a/include/newsletter.inc.php b/include/newsletter.inc.php index 7733f02..9016bdd 100644 --- a/include/newsletter.inc.php +++ b/include/newsletter.inc.php @@ -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') ); } diff --git a/modules/axletter.php b/modules/axletter.php index 4ebf134..a09cb72 100644 --- a/modules/axletter.php +++ b/modules/axletter.php @@ -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') ); } diff --git a/modules/epletter.php b/modules/epletter.php index f3667d3..c3799aa 100644 --- a/modules/epletter.php +++ b/modules/epletter.php @@ -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') ); } diff --git a/modules/newsletter.php b/modules/newsletter.php index 809caef..199bab6 100644 --- a/modules/newsletter.php +++ b/modules/newsletter.php @@ -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: diff --git a/modules/xnetnl.php b/modules/xnetnl.php index f8e9150..b326618 100644 --- a/modules/xnetnl.php +++ b/modules/xnetnl.php @@ -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') ); } diff --git a/templates/newsletter/index.tpl b/templates/newsletter/index.tpl index f9fe9df..74d3ce1 100644 --- a/templates/newsletter/index.tpl +++ b/templates/newsletter/index.tpl @@ -67,9 +67,4 @@ Tu n'es actuellement pas inscrit à la {$nl->name}. {/foreach} -{if $nl->mayEdit()} -

Il y a actuellement {$nl->subscriberCount()} inscrits aux envois, parmi lesquels {$nl->lostSubscriberCount()} n'ont aucune redirection active.

-{/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 index 0000000..43fa8e6 --- /dev/null +++ b/templates/newsletter/statistics.tpl @@ -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"} + +

Il y a actuellement {$nl->subscriberCount()} inscrits aux envois, parmi lesquels {$nl->lostSubscriberCount()} n'ont aucune redirection active.

+ + + +{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} -- 2.1.4