Bugzilla – Attachment 98986 Details for
Bug 22880
Convert opacheader system preference to news block
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22880: (follow-up) Loose ends: Better DB update, global inclusion, etc.
Bug-22880-follow-up-Loose-ends-Better-DB-update-gl.patch (text/plain), 12.66 KB, created by
Lisette Scheer
on 2020-02-14 17:37:26 UTC
(
hide
)
Description:
Bug 22880: (follow-up) Loose ends: Better DB update, global inclusion, etc.
Filename:
MIME Type:
Creator:
Lisette Scheer
Created:
2020-02-14 17:37:26 UTC
Size:
12.66 KB
patch
obsolete
>From a6c6896445b2a460b635c0c7fd991d8a1b7c2cb7 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >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 <lisettes@latahlibrary.org> >--- > .../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 ) %] > <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> >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 ) %] > <div id="wrap"> > <div id="header-region" class="noprint"> > <div class="navbar navbar-inverse navbar-static-top"> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/maintenance.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/maintenance.tt >index b15bfbcf3e..6d5d4df0d9 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/maintenance.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/maintenance.tt >@@ -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"> >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 0150881623..e113357cca 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt >@@ -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) %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sci/sci-main.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/sci/sci-main.tt >index 4591c95c31..fb8996a95c 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sci/sci-main.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/sci/sci-main.tt >@@ -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 %] › 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"> >diff --git a/opac/opac-main.pl b/opac/opac-main.pl >index 4af6f1a818..de5ad8e945 100755 >--- a/opac/opac-main.pl >+++ b/opac/opac-main.pl >@@ -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, >diff --git a/t/db_dependent/sysprefs.t b/t/db_dependent/sysprefs.t >index c6853b9f98..f43f8e3d66 100755 >--- a/t/db_dependent/sysprefs.t >+++ b/t/db_dependent/sysprefs.t >@@ -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' > ); >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 22880
:
89517
|
90495
|
92207
|
92208
|
92592
|
92593
|
92594
|
92600
|
92601
|
92602
|
96209
|
96210
|
96219
|
98773
|
98775
|
98985
|
98986
|
98987
|
98988
|
98989
|
99362
|
99363
|
99364
|
99365
|
99366
|
99367
|
99490
|
99491
|
99492
|
99493
|
99494
|
99495
|
99496
|
99497
|
99498