From 43312e4e921a863002a266b4a5b5f785e5b05072 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Fri, 29 Sep 2023 14:19:15 +0000 Subject: [PATCH] Bug 34894: Convert OpacSuppressionMessage system preference to HTML customization This patch moves the OpacSuppressionMessage system preference into HTML customizations, making it possible to have language- and library-specific content. To test you should have some content in the OpacSuppressionMessage system preference before applying the patch. Apply the patch and run the database update process. - In the staff interface, locate a bibliographic record and open it for editing. - Under tab 9, tag 942, change subfield n, "Suppress in OPAC", to "Yes" and save the record. - Go to the OPAC and try to navigate directly to the bibliographic detail page for that record: /cgi-bin/koha/opac-detail.pl?biblionumber=X - You should be redirectd to the "Blocked" page. Under the message "You are not authorized to view this record" you should see the content which was previously in the OpacSuppressionMessage system preference. - In the staff client, go to Tools -> HTML customizations and verify that the content from OpacSuppressionMessage is now stored there. - The HTML customization entry form should offer OpacSuppressionMessage as a choice under "Display location." - Update and reinstall active translations (for instance fr-FR): - perl misc/translator/translate update fr-FR - perl misc/translator/translate install fr-FR - Enable the translation if necessary under Administration -> System preferences -> language. - Enable the "opaclanguagesdisplay" preference if necessary. - Edit the OpacSuppressionMessage HTML customization and add unique content to the "fr-FR" tab. - Go to the OPAC and switch to your updated translation. Try to view the suppressed record again and confirm that the content you added for your translation shows up correctly. - Go to Administration -> System preferences and confirm that the OpacSuppressionMessage preference has been removed. --- ...ppressionMessage-to-additional-contents.pl | 31 +++++++++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 - .../en/modules/tools/additional-contents.tt | 2 +- .../bootstrap/en/modules/opac-blocked.tt | 4 ++- 4 files changed, 35 insertions(+), 3 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug-34894-move-OpacSuppressionMessage-to-additional-contents.pl diff --git a/installer/data/mysql/atomicupdate/bug-34894-move-OpacSuppressionMessage-to-additional-contents.pl b/installer/data/mysql/atomicupdate/bug-34894-move-OpacSuppressionMessage-to-additional-contents.pl new file mode 100755 index 0000000000..90e17c9afd --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug-34894-move-OpacSuppressionMessage-to-additional-contents.pl @@ -0,0 +1,31 @@ +use Modern::Perl; + +return { + bug_number => "34894", + description => "Move OpacSuppressionMessage to additional contents", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + # Get any existing value from the OpacSuppressionMessage system preference + my ($opacsuppressionmessage) = $dbh->selectrow_array( + q| + SELECT value FROM systempreferences WHERE variable='OpacSuppressionMessage'; + | + ); + if ($opacsuppressionmessage) { + + # Insert any values found from system preference into additional_contents + foreach my $lang ('default') { + $dbh->do( + "INSERT INTO additional_contents ( category, code, location, branchcode, title, content, lang, published_on ) VALUES ('html_customizations', 'OpacSuppressionMessage', 'OpacSuppressionMessage', NULL, ?, ?, ?, CAST(NOW() AS date) )", + undef, "OpacSuppressionMessage $lang", $opacsuppressionmessage, $lang + ); + } + + # Remove old system preference + $dbh->do("DELETE FROM systempreferences WHERE variable='OpacSuppressionMessage'"); + say $out "Bug 34894 update done"; + } + } + } diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 78f02829c0..c829be261a 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -521,7 +521,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('OPACSuggestionUnwantedFields',NULL,'','Define the hidden fields for a patron purchase suggestions made via OPAC.','multiple'), ('OpacSuppression','0','','Turn ON the OPAC Suppression feature, requires further setup, ask your system administrator for details','YesNo'), ('OpacSuppressionByIPRange','','','Restrict the suppression to IP adresses outside of the IP range','free'), -('OpacSuppressionMessage','','Display this message on the redirect page for suppressed biblios','70|10','Textarea'), ('OpacSuppressionRedirect','1','Redirect the opac detail page for suppressed records to an explanatory page (otherwise redirect to 404 error page)','','YesNo'), ('opacthemes','bootstrap','','Define the current theme for the OPAC interface.','Themes'), ('OpacTopissue','0',NULL,'If ON, enables the \'most popular items\' link on OPAC. Warning, this is an EXPERIMENTAL feature, turning ON may overload your server','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt index dbf97f69f0..ac7ff2e29e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt @@ -494,7 +494,7 @@ [% END %] [% END %] [% ELSE %] - [% SET available_options = [ 'OpacNavRight', 'opacheader', 'OpacCustomSearch', 'OpacMainUserBlock', 'opaccredits', 'OpacLoginInstructions', 'OpacNav', 'OpacNavBottom', 'OpacSuggestionInstructions', 'ArticleRequestsDisclaimerText', 'OpacMoreSearches', 'OpacMySummaryNote', 'OpacLibraryInfo', 'CatalogConcernHelp', 'CatalogConcernTemplate', 'CookieConsentBar', 'CookieConsentPopup' ] %] + [% SET available_options = [ 'OpacNavRight', 'opacheader', 'OpacCustomSearch', 'OpacMainUserBlock', 'opaccredits', 'OpacLoginInstructions', 'OpacNav', 'OpacNavBottom', 'OpacSuggestionInstructions', 'ArticleRequestsDisclaimerText', 'OpacMoreSearches', 'OpacMySummaryNote', 'OpacLibraryInfo', 'CatalogConcernHelp', 'CatalogConcernTemplate', 'CookieConsentBar', 'CookieConsentPopup', 'OpacSuppressionMessage' ] %] [% FOREACH l IN available_options.sort %] [% IF l == location %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-blocked.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-blocked.tt index 8520a26186..2c4c65f621 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-blocked.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-blocked.tt @@ -1,4 +1,6 @@ [% USE raw %] +[% USE AdditionalContents %] +[% SET OpacSuppressionMessage = AdditionalContents.get( location => "OpacSuppressionMessage", lang => lang, library => branchcode || default_branch ) %] [% INCLUDE 'doc-head-open.inc' %] Record blocked › @@ -33,7 +35,7 @@ <p>You are not authorized to view this record.</p> [% IF ( OpacSuppressionMessage ) %] <div id="opacsuppressionmessage"> - [% OpacSuppressionMessage | $raw %] + [% PROCESS koha_news_block news => OpacSuppressionMessage %] </div> [% END %] </div> -- 2.30.2