From 42df7fa8d32b209083a983b4eaccc018c80018bd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Barrois?= Date: Thu, 5 May 2011 21:48:55 +0200 Subject: [PATCH 1/1] Enable category edition for newsletters. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Raphaël Barrois --- modules/axletter.php | 1 + modules/epletter.php | 1 + modules/newsletter.php | 21 ++++++++++++++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/modules/axletter.php b/modules/axletter.php index 2c8a8d8..a9f4596 100644 --- a/modules/axletter.php +++ b/modules/axletter.php @@ -35,6 +35,7 @@ class AXLetterModule extends NewsletterModule 'ax/admin/edit/valid' => $this->make_hook('admin_nl_valid', AUTH_MDP), 'ax/admin/edit/cancel' => $this->make_hook('admin_nl_cancel', AUTH_MDP), 'ax/admin/edit/delete' => $this->make_hook('admin_nl_delete', AUTH_MDP), + 'ax/admin/categories' => $this->make_hook('admin_nl_cat', AUTH_MDP), ); } diff --git a/modules/epletter.php b/modules/epletter.php index ac4ef72..0cb1c0f 100644 --- a/modules/epletter.php +++ b/modules/epletter.php @@ -35,6 +35,7 @@ class EPLetterModule extends NewsletterModule 'epletter/admin/edit/valid' => $this->make_hook('admin_nl_valid', AUTH_MDP), 'epletter/admin/edit/cancel' => $this->make_hook('admin_nl_cancel', AUTH_MDP), 'epletter/admin/edit/delete' => $this->make_hook('admin_nl_delete', AUTH_MDP), + 'epletter/admin/categories' => $this->make_hook('admin_nl_cat', AUTH_MDP), ); } diff --git a/modules/newsletter.php b/modules/newsletter.php index 3accf5f..02efc32 100644 --- a/modules/newsletter.php +++ b/modules/newsletter.php @@ -431,11 +431,30 @@ class NewsletterModule extends PLModule } function handler_admin_nl_cat($page, $action = 'list', $id = null) { + $nl = $this->getNl(); + if (!$nl) { + return PL_NOT_FOUND; + } + + if (!$nl->mayEdit()) { + return PL_FORBIDDEN; + } + $page->setTitle('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 = new PLTableEditor($nl->adminPrefix() . '/categories', 'newsletter_cat','cid'); $table_editor->describe('title','intitulé',true); $table_editor->describe('pos','position',true); + if ($nl->group == Newsletter::GROUP_XORG) { + $table_editor->add_option_table('newsletters', 'newsletters.id = t.nlid'); + $table_editor->add_option_field('newsletters.name', 'newsletter_name', 'Newsletter', null, 'nlid'); + $table_editor->describe('nlid', 'ID NL', true); + } else { + $table_editor->force_field_value('nlid', $nl->id); + $table_editor->describe('nlid', 'nlid', false); + } + // Prevent deletion. + $table_editor->on_delete(null, null); $table_editor->apply($page, $action, $id); } } -- 2.1.4