Bugzilla – Attachment 101392 Details for
Bug 23794
Convert OpacMainUserBlock system preference to news block
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23794: Convert OpacMainUserBlock system preference to news block
Bug-23794-Convert-OpacMainUserBlock-system-prefere.patch (text/plain), 8.77 KB, created by
Bernardo Gonzalez Kriegel
on 2020-03-22 22:21:57 UTC
(
hide
)
Description:
Bug 23794: Convert OpacMainUserBlock system preference to news block
Filename:
MIME Type:
Creator:
Bernardo Gonzalez Kriegel
Created:
2020-03-22 22:21:57 UTC
Size:
8.77 KB
patch
obsolete
>From e7b71c53a7c2cb33921f4626177b7b8bc23953d0 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Wed, 11 Dec 2019 16:24:50 +0000 >Subject: [PATCH] Bug 23794: Convert OpacMainUserBlock system preference to > news block > >This patch builds on Bug 22318 to move the OpacMainUserBlock system >preference into the Koha news system, making it possible to have >language- and library-specific content. > >To test you should have some content in the OpacMainUserBlock system >preference. Apply the patch and run the database update process. > > - Go to the OPAC and confirm that the content which was previously in > the OpacMainUserBlock system preference now displays correctly where > it was before. > - In the staff client, go to Tools -> News and verify that the content > from OpacMainUserBlock is now stored in news items. There should be > one entry for each of the enabled translations in your system, for > instance 'opacmainuserblock_en', 'opacmainuserblock_fr-FR', > 'opacmainuserblock_cs-CZ' > - Go to Administration -> System preferences and confirm that the > OpacMainUserBlock preference has been removed. > >Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> >Works like a charm. >Don't forget to run ./translate update/install for your language(s) >after the patch >--- > C4/Auth.pm | 1 - > ..._23794-move-opacmainuserblock-to-news.perl | 30 +++++++++++++++++++ > installer/data/mysql/sysprefs.sql | 1 - > .../en/modules/admin/preferences/opac.pref | 6 ---- > .../prog/en/modules/tools/koha-news.tt | 2 +- > .../bootstrap/en/modules/opac-main.tt | 9 ++++-- > 6 files changed, 38 insertions(+), 11 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_23794-move-opacmainuserblock-to-news.perl > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index f3089f2ac9..0d0866e6c9 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -571,7 +571,6 @@ sub get_template_and_user { > OpacBrowser => C4::Context->preference("OpacBrowser"), > OpacCloud => C4::Context->preference("OpacCloud"), > OpacKohaUrl => C4::Context->preference("OpacKohaUrl"), >- OpacMainUserBlock => "" . C4::Context->preference("OpacMainUserBlock"), > OpacNav => "" . C4::Context->preference("OpacNav"), > OpacNavBottom => "" . C4::Context->preference("OpacNavBottom"), > OpacPasswordChange => C4::Context->preference("OpacPasswordChange"), >diff --git a/installer/data/mysql/atomicupdate/bug_23794-move-opacmainuserblock-to-news.perl b/installer/data/mysql/atomicupdate/bug_23794-move-opacmainuserblock-to-news.perl >new file mode 100644 >index 0000000000..ac0389f2b9 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_23794-move-opacmainuserblock-to-news.perl >@@ -0,0 +1,30 @@ >+$DBversion = 'XXX'; # will be replaced by the RM >+if( CheckVersion( $DBversion ) ) { >+ >+ # get list of installed translations >+ require C4::Languages; >+ my @langs; >+ my $tlangs = C4::Languages::getTranslatedLanguages(); >+ >+ foreach my $language ( @$tlangs ) { >+ foreach my $sublanguage ( @{$language->{'sublanguages_loop'}} ) { >+ push @langs, $sublanguage->{'rfc4646_subtag'}; >+ } >+ } >+ >+ # Get any existing value from the OpacMainUserBlock system preference >+ my ($opacmainuserblock) = $dbh->selectrow_array( q| >+ SELECT value FROM systempreferences WHERE variable='OpacMainUserBlock'; >+ |); >+ if( $opacmainuserblock ){ >+ foreach my $lang ( @langs ) { >+ print "Inserting OpacMainUserBlock contents into $lang news item...\n"; >+ # If there is a value in the OpacMainUserBlock preference, insert it into opac_news >+ $dbh->do("INSERT INTO opac_news (branchcode, lang, title, content ) VALUES (NULL, ?, '', ?)", undef, "OpacMainUserBlock_$lang", $opacmainuserblock); >+ } >+ } >+ # Remove the OpacMainUserBlock system preference >+ $dbh->do("DELETE FROM systempreferences WHERE variable='OpacMainUserBlock'"); >+ SetVersion ($DBversion); >+ print "Upgrade to $DBversion done (Bug 23794: Move contents of OpacMainUserBlock preference to Koha news system)\n"; >+} >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 612dcc20c6..e0af2923ad 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -406,7 +406,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('OpacLoginInstructions', '', '60|10', 'Instructions to display on the OPAC login form when a patron is not logged in', 'Textarea'), > ('OpacMaintenance','0','','If ON, enables maintenance warning in OPAC','YesNo'), > ('OpacMaintenanceNotice','','','A user-defined block of HTML to appear on screen when OpacMaintenace is enabled','Textarea'), >-('OpacMainUserBlock','Welcome to Koha...\r\n<hr>','70|10','A user-defined block of HTML in the main content area of the opac main page','Textarea'), > ('OpacMaxItemsToDisplay','50','','Max items to display at the OPAC on a biblio detail','Integer'), > ('OpacMoreSearches', '', NULL, 'Add additional elements to the OPAC more searches bar', 'Textarea'), > ('OPACMySummaryHTML','','70|10','Enter the HTML that will appear in a column on the \'my summary\' and \'my reading history\' tabs when a user is logged in to the OPAC. Enter {BIBLIONUMBER}, {TITLE}, {AUTHOR}, or {ISBN} in place of their respective variables in the HTML. Leave blank to disable.','Textarea'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >index 9c9b2b7f00..f8b1d457d2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >@@ -232,12 +232,6 @@ OPAC: > type: textarea > syntax: css > class: code >- - >- - "Show the following HTML in its own column on the main page of the OPAC:" >- - pref: OpacMainUserBlock >- type: textarea >- syntax: text/html >- class: code > - > - "Show the following HTML on the left hand column of the main page and patron account on the OPAC (generally navigation links):" > - pref: OpacNav >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt >index e73e613194..2ce2dd4de2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt >@@ -327,7 +327,7 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]</div> > [% END %] > [% FOREACH lang_lis IN lang_list %] > <optgroup label="[% lang_lis.language | html %]"> >- [% FOREACH location IN [ '', 'OpacNavRight', 'opacheader' ] %] >+ [% FOREACH location IN [ '', 'OpacNavRight', 'opacheader', 'OpacMainUserBlock' ] %] > [% IF ( location == '' ) %] > [% SET location_lang = lang_lis.language %] > [% location = BLOCK %]OPAC news[% END %] >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 e113357cca..56fd4b5bfd 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt >@@ -5,6 +5,8 @@ > [% USE Categories %] > [% USE Price %] > [% USE KohaNews %] >+[% SET OpacNavRight = KohaNews.get( location => "OpacNavRight", lang => lang, library => branchcode ) %] >+[% SET OpacMainUserBlock = KohaNews.get( location => "OpacMainUserBlock", lang => lang, library => branchcode ) %] > [% INCLUDE 'doc-head-open.inc' %] > <title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog</title> > [% INCLUDE 'doc-head-close.inc' %] >@@ -42,7 +44,6 @@ > </div> > [% END %] > >- [% 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) %] >@@ -150,7 +151,11 @@ > </div> > [% END %] > >- [% IF ( OpacMainUserBlock ) %]<div id="opacmainuserblock">[% OpacMainUserBlock | $raw %]</div>[% END %] >+ [% IF ( OpacMainUserBlock ) %] >+ <div id="opacmainuserblock"> >+ [% PROCESS koha_news_block news => OpacMainUserBlock %] >+ </div> >+ [% END %] > [% END %] > > </div> <!-- / .span 7/9 --> >-- >2.17.1
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 23794
:
99704
|
101392
|
104073
|
104847