From eca286349b07c8f32f94c9fc73ef58ec5bf91fa4 Mon Sep 17 00:00:00 2001 From: Martin Persson Date: Wed, 5 Aug 2015 16:16:50 +0200 Subject: [PATCH] Bug 14305: View arbitrary branch's news This patch adds an input named 'branch' to opac-main.pl that allows overriding the home library to view news from any branch. This is part of the 'Use Koha as a CMS' development. To reviewers: Does this create any security implications? The column is text; it is possbile to push SQL statemens into the DB via the opac-membership.pl page, but all the code there seems to use DBIx::Class and prepared statements. When attemped, accepting the changes were rejected because of the foreign key constraint placed on the main borrowers table. It is recommended to use this patch in conjunction with 11584 which adds a WYSIWYG editor to System Preferences. Test plan: * Make sure your Koha installation has multiple branches: * Log in to the Staff interface and select 'Koha administration' * Select 'Libraries and groups', the first item in the list * Add an extra branch named 'BRANCH1': * Press the 'New library' button * Set 'Library code' to 'BRANCH1' * Enter an arbitrary name * Press 'Submit' * Add at least two news items with different branches: * Log in to the Staff interface and select 'Tools' * Under 'Additional tools' select 'News' * On the 'Koha news' page, create a news item for all libraries: * Press the 'New entry' button * Set 'Library' to 'All libraries' and enter a title. * Press 'Submit' * On the 'Koha news' page, create a news item for one library: * Press the 'New entry' button * Set 'Library' to 'BRANCH1' and enter a title * Press 'Submit' * Add links to OPAC to select branch: * Select 'System preferences' and then the 'OPAC' tab * Scroll down to the 'OpacNav' preference and click 'Click to Edit' * Create two hyperlinks with a parameter named 'branch': * 'BRANCH1' * 'none' * Click 'Save all OPAC preferences' * Test OPAC: * By default, global news and news for home branch should show. * When clicking the 'BRANCH1' link, you should see global news plus news for the BRANCH1 branch. * When the parameter 'branch' is set but has no value, news from the home branch should be shown. Issues: Tricky to create a link to the same page which removes existing paramters. The user normally has a home branch set. We can override it with the parameter. If undefined, the home branch should be shown. Sponsored-by: Halland County Library http://bugs.koha-community.org/show_bug.cgi?id=14305 Changed 2015-12-14: Whitespace fix Signed-off-by: Mark Tompsett Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall --- opac/opac-main.pl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/opac/opac-main.pl b/opac/opac-main.pl index d586a7cb2b..776ae72eef 100755 --- a/opac/opac-main.pl +++ b/opac/opac-main.pl @@ -51,6 +51,9 @@ my $homebranch; if (C4::Context->userenv) { $homebranch = C4::Context->userenv->{'branch'}; } +if (defined $input->param('branch') and length $input->param('branch')) { + $homebranch = $input->param('branch'); +} my $all_koha_news = &GetNewsToDisplay($news_lang,$homebranch); my $koha_news_count = scalar @$all_koha_news; -- 2.39.5