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 <lisettes@latahlibrary.org>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Owen Leonard 2019-12-11 13:42:09 +00:00 committed by Martin Renvoize
parent 65a5d1298c
commit 12074faff9
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
9 changed files with 41 additions and 30 deletions

View File

@ -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'");

View File

@ -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'),

View File

@ -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 ) %]
<div id="wrap">
<div class="navbar navbar-inverse navbar-static-top">
<div class="navbar-inner">
@ -24,11 +27,11 @@
</div> <!-- /navbar-inner -->
</div> <!-- /navbar -->
[% IF ( opacheader ) %]
[% IF ( OpacHeader ) %]
<div class="container-fluid">
<div class="row-fluid">
<div id="opacheader">
[% opacheader | $raw %]
[% PROCESS koha_news_block news => OpacHeader %]
</div>
</div>
</div>

View File

@ -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 ) %]
<div id="wrap">
<div id="header-region" class="noprint">
<div class="navbar navbar-inverse navbar-static-top">

View File

@ -1,6 +1,8 @@
[% USE raw %]
[% USE Koha %]
[% USE KohaNews %]
[% INCLUDE 'doc-head-open.inc' %]
[% SET OpacHeader = KohaNews.get( location => "opacheader", lang => lang, library => branchcode, blocktitle => 0 ) %]
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog</title>
[% INCLUDE 'doc-head-close.inc' %]
[% BLOCK cssinclude %]
@ -21,8 +23,14 @@
[% END %]
</head>
<body id="opac_maintenance" class="opac">
[% IF ( opacheader ) %]
[% opacheader | $raw %]
[% IF ( OpacHeader ) %]
<div class="container-fluid">
<div class="row-fluid">
<div id="opacheader">
[% PROCESS koha_news_block news => OpacHeader %]
</div>
</div>
</div>
[% END %]
<div class="container-fluid">
<div class="row-fluid">

View File

@ -42,7 +42,7 @@
</div>
[% END %]
[% SET OpacNavRight = KohaNews.get( location => "OpacNavRight", lang => news_lang, library => branchcode ) %]
[% SET OpacNavRight = KohaNews.get( location => "OpacNavRight", lang => lang, library => branchcode ) %]
[% IF ( OpacNav || OpacNavBottom ) && (Koha.Preference( 'opacuserlogin' ) == 1 || OpacNavRight) %]
<div class="span7">
[% ELSIF (Koha.Preference( 'opacuserlogin' ) == 1 || OpacNavRight) %]

View File

@ -3,6 +3,7 @@
[%# Includes %]
[% USE Koha %]
[% USE KohaDates %]
[% USE KohaNews %]
[%# Helper template functions %]
[% BLOCK error_message %]
[% IF messages.BadBarcode %]
@ -17,7 +18,8 @@
<span>(There was a problem returning this item, please see library staff for assistance)</span>
[% END %]
[% END %]
[% PROCESS 'html_helpers.inc' %]
[% SET OpacHeader = KohaNews.get( location => "opacheader", lang => lang, library => branchcode, blocktitle => 0 ) %]
[% INCLUDE 'doc-head-open.inc' %]
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha [% END %] &rsaquo; Self check-in</title>
@ -71,15 +73,15 @@
</div> <!-- /.navbar-inner -->
</div> <!-- /.navbar -->
[% IF Koha.Preference( 'opacheader' ) %]
<div class="container-fluid">
<div class="row-fluid">
<div id="opacheader">
[% Koha.Preference( 'opacheader' ) | $raw %]
[% IF ( OpacHeader ) %]
<div class="container-fluid">
<div class="row-fluid">
<div id="opacheader">
[% PROCESS koha_news_block news => OpacHeader %]
</div>
</div>
</div>
</div>
[% END %]
[% END %]
<div class="main">
<div class="container-fluid">

View File

@ -48,10 +48,6 @@ $template->param(
casAuthentication => $casAuthentication,
);
# display news
# use cookie setting for language, bug default to syspref if it's not set
my ($theme, $news_lang, $availablethemes) = C4::Templates::themelanguage(C4::Context->config('opachtdocs'),'opac-main.tt','opac',$input);
my $homebranch;
if (C4::Context->userenv) {
$homebranch = C4::Context->userenv->{'branch'};
@ -74,7 +70,7 @@ if (defined $news_id){
$template->param( single_news_error => 1 );
}
} else {
@all_koha_news = &GetNewsToDisplay($news_lang,$homebranch);
@all_koha_news = &GetNewsToDisplay( $template->lang, $homebranch);
}
my $quote = GetDailyQuote(); # other options are to pass in an exact quote id or select a random quote each pass... see perldoc C4::Koha
@ -104,7 +100,6 @@ if ( $patron ) {
$template->param(
koha_news => @all_koha_news,
news_lang => $news_lang,
branchcode => $homebranch,
display_daily_quote => C4::Context->preference('QuoteOfTheDay'),
daily_quote => $quote,

View File

@ -27,19 +27,19 @@ my $schema = Koha::Database->new->schema;
$schema->storage->txn_begin;
my $dbh = C4::Context->dbh;
my $opacheader = C4::Context->preference('opacheader');
my $newopacheader = "newopacheader";
my $URLLinkText = C4::Context->preference('URLLinkText');
my $newURLLinkText = "newURLLinkText";
C4::Context->set_preference( 'OPACHEADER', $newopacheader );
is( C4::Context->preference('opacheader'), $newopacheader, 'The pref should have been set correctly' );
C4::Context->set_preference( 'URLLINKTEXT', $newURLLinkText );
is( C4::Context->preference('URLLinkText'), $newURLLinkText, 'The pref should have been set correctly' );
C4::Context->set_preference( 'opacheader', $opacheader );
is( C4::Context->preference('OPACHEADER'), $opacheader, 'A pref name should be case insensitive');
C4::Context->set_preference( 'URLLinkText', $URLLinkText );
is( C4::Context->preference('URLLINKTEXT'), $URLLinkText, 'A pref name should be case insensitive');
$ENV{OVERRIDE_SYSPREF_opacheader} = 'this is an override';
$ENV{OVERRIDE_SYSPREF_URLLinkText} = 'this is an override';
C4::Context->clear_syspref_cache();
is(
C4::Context->preference('opacheader'),
C4::Context->preference('URLLinkText'),
'this is an override',
'system preference value overridden from environment'
);