From 5fc6bedaa714e8e49b0907f44a5ad32342402fbc 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 search for "OpacSuppression." The description of these preferences should show an updated message about using HTML customizations to create OpacSuppressionMessage content. Signed-off-by: David Nind Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- ...ppressionMessage-to-additional-contents.pl | 38 +++++++++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 - .../admin/preferences/cataloguing.pref | 5 +-- .../en/modules/tools/additional-contents.tt | 2 +- .../bootstrap/en/modules/opac-blocked.tt | 4 +- 5 files changed, 43 insertions(+), 7 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..55f9dd9453 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug-34894-move-OpacSuppressionMessage-to-additional-contents.pl @@ -0,0 +1,38 @@ +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 + $dbh->do( + "INSERT INTO additional_contents ( category, code, location, branchcode, published_on ) VALUES ('html_customizations', 'OpacSuppressionMessage', 'OpacSuppressionMessage', NULL, CAST(NOW() AS date) )" + ); + + my ($insert_id) = $dbh->selectrow_array( + "SELECT id FROM additional_contents WHERE category = 'html_customizations' AND code = 'OpacSuppressionMessage' AND location = 'OpacSuppressionMessage' LIMIT 1", + {} + ); + + $dbh->do( + "INSERT INTO additional_contents_localizations ( additional_content_id, title, content, lang ) VALUES ( ?, 'OpacSuppressionMessage default', ?, 'default' )", + undef, $insert_id, $opacsuppressionmessage + ); + + # 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 3e6715120d..58dee00d65 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -530,7 +530,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/admin/preferences/cataloguing.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref index 814ce6a904..ffd9b7e549 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref @@ -282,10 +282,7 @@ Cataloging: choices: 1: "an explanatory page ('This record is blocked')." 0: "the 404 error page ('Not found')." - - "
Display the following message on the redirect page for suppressed bibliographic records:" - - pref: OpacSuppressionMessage - type: textarea - class: code + - "
A custom message can be shown on the redirect page for suppressed bibliographic records by creating an HTML customization in the OpacSuppressionMessage region." - - pref: SeparateHoldings choices: 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 57d81b7af0..3f151c18cb 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 @@ -524,7 +524,7 @@ [% END %] [% END %] [% ELSE %] - [% SET opac_available_options = [ 'OpacNavRight', 'opacheader', 'OpacCustomSearch', 'OpacMainUserBlock', 'opaccredits', 'OpacLoginInstructions', 'OpacNav', 'OpacNavBottom', 'OpacSuggestionInstructions', 'ArticleRequestsDisclaimerText', 'OpacMoreSearches', 'OpacMySummaryNote', 'OpacLibraryInfo', 'OpacMaintenanceNotice', 'OPACResultsSidebar', 'CatalogConcernHelp', 'CatalogConcernTemplate', 'CookieConsentBar', 'CookieConsentPopup', 'PatronSelfRegistrationAdditionalInstructions' ] %] + [% SET opac_available_options = [ 'OpacNavRight', 'opacheader', 'OpacCustomSearch', 'OpacMainUserBlock', 'opaccredits', 'OpacLoginInstructions', 'OpacNav', 'OpacNavBottom', 'OpacSuggestionInstructions', 'ArticleRequestsDisclaimerText', 'OpacMoreSearches', 'OpacMySummaryNote', 'OpacLibraryInfo', 'OpacMaintenanceNotice', 'OPACResultsSidebar', 'OpacSuppressionMessage', 'CatalogConcernHelp', 'CatalogConcernTemplate', 'CookieConsentBar', 'CookieConsentPopup', 'PatronSelfRegistrationAdditionalInstructions' ] %] [% FOREACH l IN opac_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 b20a8c677e..c942a6f2c4 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 › @@ -28,7 +30,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.39.5