From fe7bcfd48d07ecb7cecd80fd4fa2a10f8336362c Mon Sep 17 00:00:00 2001 From: Martin Persson Date: Wed, 16 Dec 2015 15:44:38 +0100 Subject: [PATCH] Bug 15385: News archive Adds ability to new old, expired news items in an archive. Test plan: * Add several news items, some of which should have an expired date. * Go to Global system preferences, Enable 'NewsArchiveEnabled'. * Go to the OPAC main page. The non-expired news should be shown. * A link should be shown in the lower right-hand side of the page, "Archived news". Click it. ALL news items should be shown. * Go back to Global system preferences, Disable 'NewsArchiveEnabled'. * No 'Archived news' link should be shown on the OPAC main page. * If you manually add '?id=all' to the OPAC main page URL, the standard page should be shown and the parameter ignored. Updates: * Renamed 'id' to 'news_id' (from update in 14272) Sponsored-By: Halland County Library --- installer/data/mysql/sysprefs.sql | 1 + .../intranet-tmpl/prog/en/modules/admin/preferences/tools.pref | 8 ++++++++ koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt | 3 +++ opac/opac-main.pl | 9 +++++++-- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 484b3cd..d9c1e4b 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -222,6 +222,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('minPasswordLength','3',NULL,'Specify the minimum length of a patron/staff password','free'), ('NewItemsDefaultLocation','','','If set, all new items will have a location of the given Location Code ( Authorized Value type LOC )',''), ('NewsAuthorDisplay','none','none|opac|staff|both','Display the author name for news items.','Choice'), +('NewsArchiveEnabled','0',NULL,'Enables users to view expired news items.','YesNo'), ('noissuescharge','5','','Define maximum amount withstanding before check outs are blocked','Integer'), ('noItemTypeImages','0',NULL,'If ON, disables item-type images','YesNo'), ('NoLoginInstructions', '', '60|10', 'Instructions to display on the OPAC login form when a patron is not logged in', 'Textarea'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/tools.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/tools.pref index 5a3ddce..30d5ad5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/tools.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/tools.pref @@ -21,3 +21,11 @@ Tools: staff: "Staff client only" both: "Both OPAC and staff client" - + - + - + - pref: NewsArchiveEnabled + choices: + yes: "Enable" + no: "Disable" + - the news archive for expired items. + - diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt index af67967..da65154 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt @@ -53,6 +53,9 @@ [% SET branchcode = Branches.GetLoggedInBranchcode() %] RSS feed for [% IF ( loggedinusername ) %][% Branches.GetName( branchcode ) %] and [% END %] system-wide library news. + + [% IF ( Koha.Preference( 'NewsArchiveEnabled' ) ) %] + Archived news[% END %] [% END %] diff --git a/opac/opac-main.pl b/opac/opac-main.pl index 3d32e2c..e2434c9 100755 --- a/opac/opac-main.pl +++ b/opac/opac-main.pl @@ -55,8 +55,13 @@ if (C4::Context->userenv) { my $news_id = $input->param('news_id'); my ($all_koha_news, $koha_news_count); if (defined $news_id && length $news_id) { - $all_koha_news = [ get_opac_new($news_id) ]; - $koha_news_count = 1; + if ($news_id eq 'all' && C4::Context->preference('NewsArchiveEnabled')) { + $all_koha_news = get_opac_news(undef, $news_lang, $homebranch); + $koha_news_count = scalar @$all_koha_news; + } else { + $all_koha_news = [ get_opac_new($news_id) ]; + $koha_news_count = 1; + } } else { $all_koha_news = GetNewsToDisplay($news_lang, $homebranch); $koha_news_count = scalar @$all_koha_news; -- 2.1.4