From 12074faff9686f6c25126e39fcf1954e5faba009 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Wed, 11 Dec 2019 13:42:09 +0000 Subject: [PATCH] Bug 22880: (follow-up) Loose ends: Better DB update, global inclusion, etc. This patch makes a number of improvements and ties up some loose ends where the old system preference usage wasn't getting replaced. - Removes news-specific code for defining the language of news items queried for the OPAC home page. An identical language variable is already defined globally. Previous to this patch an 'opacheader' news item would only appear on the OPAC home page. Now it should appear on all OPAC pages. - Changes the database update so that 'opacheader' news items will be inserted with a default title, matching the interface's requirement that the title field be populated. - The database update will also now insert the old opacheader system preference contents into the news item for all active languages as defined in the 'opaclanguages' system preference. This helps match the previous behavior in which the opacheader contents were the same for all languages. - Adds support for the new opacheader news item to the self checkout, self check-in, and OPAC maintenance pages. - Updates sysprefs.t which was using the opacheader preference to test on. I've changed it to use URLLinkText instead. - Removes the addition of the opacheader system preference from the installation SQL file. Signed-off-by: Lisette Scheer Signed-off-by: Marcel de Rooy Signed-off-by: Martin Renvoize --- .../bug_22880-move-opacheader-to-news.perl | 7 +++++-- installer/data/mysql/sysprefs.sql | 1 - .../bootstrap/en/includes/masthead-sco.inc | 7 +++++-- .../bootstrap/en/includes/masthead.inc | 1 + .../bootstrap/en/modules/maintenance.tt | 12 ++++++++++-- .../bootstrap/en/modules/opac-main.tt | 2 +- .../bootstrap/en/modules/sci/sci-main.tt | 18 ++++++++++-------- opac/opac-main.pl | 7 +------ t/db_dependent/sysprefs.t | 16 ++++++++-------- 9 files changed, 41 insertions(+), 30 deletions(-) diff --git a/installer/data/mysql/atomicupdate/bug_22880-move-opacheader-to-news.perl b/installer/data/mysql/atomicupdate/bug_22880-move-opacheader-to-news.perl index 73bd289275..bddef51a80 100644 --- a/installer/data/mysql/atomicupdate/bug_22880-move-opacheader-to-news.perl +++ b/installer/data/mysql/atomicupdate/bug_22880-move-opacheader-to-news.perl @@ -8,8 +8,11 @@ if( CheckVersion( $DBversion ) ) { SELECT value FROM systempreferences WHERE variable='opacheader'; |); if( $opacheader ){ - # If there is a value in the opacheader preference, insert it into opac_news - $dbh->do("INSERT INTO opac_news (branchcode, lang, title, content ) VALUES (NULL, 'opacheader_$langs[0]', '', '$opacheader')"); + foreach my $lang ( @langs ) { + print "Inserting opacheader contents into $lang news item...\n"; + # If there is a value in the opacheader preference, insert it into opac_news + $dbh->do("INSERT INTO opac_news (branchcode, lang, title, content ) VALUES (NULL, ?, 'opacheader $lang', ?)", undef, "opacheader_$lang", $opacheader); + } } # Remove the opacheader system preference $dbh->do("DELETE FROM systempreferences WHERE variable='opacheader'"); diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 944b36db08..b565b7f0bf 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -382,7 +382,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('OPACFineNoRenewals','100','','Fine limit above which user cannot renew books via OPAC','Integer'), ('OPACFinesTab','1','','If OFF the patron fines tab in the OPAC is disabled.','YesNo'), ('OPACFRBRizeEditions','0','','If ON, the OPAC will query one or more ISBN web services for associated ISBNs and display an Editions tab on the details pages','YesNo'), -('opacheader','','70|10','Add HTML to be included as a custom header in the OPAC','Textarea'), ('OpacHiddenItems','','','This syspref allows to define custom rules for hiding specific items at the OPAC. See http://wiki.koha-community.org/wiki/OpacHiddenItems for more information.','Textarea'), ('OpacHiddenItemsExceptions','',NULL,'List of borrower categories, separated by |, that can see items otherwise hidden by OpacHiddenItems','Textarea'), ('OpacHighlightedWords','1','','If Set, then queried words are higlighted in OPAC','YesNo'), diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead-sco.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead-sco.inc index bc65bdbb1b..34d51cd62e 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead-sco.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead-sco.inc @@ -1,6 +1,9 @@ [% USE raw %] [% USE Koha %] +[% USE KohaNews %] +[% PROCESS 'html_helpers.inc' %] [% SET OpacLangSelectorMode = Koha.Preference('OpacLangSelectorMode') %] +[% SET OpacHeader = KohaNews.get( location => "opacheader", lang => lang, library => branchcode, blocktitle => 0 ) %]
- [% IF ( opacheader ) %] + [% IF ( OpacHeader ) %]
- [% opacheader | $raw %] + [% PROCESS koha_news_block news => OpacHeader %]
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc index f9192e67f4..84d884a64a 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc @@ -4,6 +4,7 @@ [% USE Categories %] [% USE KohaNews %] [% SET OpacLangSelectorMode = Koha.Preference('OpacLangSelectorMode') %] +[% SET OpacHeader = KohaNews.get( location => "opacheader", lang => lang, library => branchcode, blocktitle => 0 ) %]