@@ -, +, @@ news block - 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. --- C4/Auth.pm | 1 - .../bug_23794-move-opacmainuserblock-to-news.perl | 30 ++++++++++++++++++++++ installer/data/mysql/sysprefs.sql | 1 - .../prog/en/modules/admin/preferences/opac.pref | 6 ----- .../prog/en/modules/tools/koha-news.tt | 2 +- .../opac-tmpl/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 --- a/C4/Auth.pm +++ a/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"), --- a/installer/data/mysql/atomicupdate/bug_23794-move-opacmainuserblock-to-news.perl +++ a/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"; +} --- a/installer/data/mysql/sysprefs.sql +++ a/installer/data/mysql/sysprefs.sql @@ -403,7 +403,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
','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'), --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -233,12 +233,6 @@ OPAC: 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 type: textarea --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt +++ a/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 %] [% END %] [% FOREACH lang_lis IN lang_list %] - [% FOREACH location IN [ '', 'OpacNavRight', 'opacheader' ] %] + [% FOREACH location IN [ '', 'OpacNavRight', 'opacheader', 'OpacMainUserBlock' ] %] [% IF ( location == '' ) %] [% SET location_lang = lang_lis.language %] [% location = BLOCK %]OPAC news[% END %] --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt +++ a/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' %] [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog [% INCLUDE 'doc-head-close.inc' %] @@ -42,7 +44,6 @@ [% END %] - [% SET OpacNavRight = KohaNews.get( location => "OpacNavRight", lang => lang, library => branchcode ) %] [% IF ( OpacNav || OpacNavBottom ) && (Koha.Preference( 'opacuserlogin' ) == 1 || OpacNavRight) %]
[% ELSIF (Koha.Preference( 'opacuserlogin' ) == 1 || OpacNavRight) %] @@ -150,7 +151,11 @@
[% END %] - [% IF ( OpacMainUserBlock ) %]
[% OpacMainUserBlock | $raw %]
[% END %] + [% IF ( OpacMainUserBlock ) %] +
+ [% PROCESS koha_news_block news => OpacMainUserBlock %] +
+ [% END %] [% END %] --