From a6c6896445b2a460b635c0c7fd991d8a1b7c2cb7 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 --- .../bug_22880-move-opacheader-to-news.perl | 7 +++++-- installer/data/mysql/sysprefs.sql | 1 - .../opac-tmpl/bootstrap/en/includes/masthead-sco.inc | 7 +++++-- koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc | 2 +- .../opac-tmpl/bootstrap/en/modules/maintenance.tt | 12 ++++++++++-- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt | 2 +- .../opac-tmpl/bootstrap/en/modules/sci/sci-main.tt | 18 ++++++++++-------- opac/opac-main.pl | 7 +------ t/db_dependent/sysprefs.t | 16 ++++++++-------- 9 files changed, 41 insertions(+), 31 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 b460731238..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, ?, '', ?)", undef, "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 cfa295e197..ac9b574bf8 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -380,7 +380,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 5b42784680..d59f8764e9 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc @@ -4,7 +4,7 @@ [% USE Categories %] [% USE KohaNews %] [% SET OpacLangSelectorMode = Koha.Preference('OpacLangSelectorMode') %] -[% SET OpacHeader = KohaNews.get( location => "opacheader", lang => news_lang, library => branchcode, blocktitle => 0 ) %] +[% SET OpacHeader = KohaNews.get( location => "opacheader", lang => lang, library => branchcode, blocktitle => 0 ) %]