From c017efc7760a51aebc5d89a2c005605ee5385510 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 12 Oct 2023 14:17:57 +0000 Subject: [PATCH] Bug 23798: Convert OpacMaintenanceNotice system preference to additional contents Content-Type: text/plain; charset=utf-8 This patch moves the OpacMaintenanceNotice system preference into HTML customizations, making it possible to have language-specific content. The patch modifies the OPAC maintenance page template so that the language selection menu can be shown correctly according to the OpacLangSelectorMode preference. To test you should have some content in the OpacMaintenanceNotice system preference before applying the patch. Apply the patch and run the database update process. - In the staff client, go to Tools -> HTML customizations and verify that the content from OpacMaintenanceNotice is now stored there. - The HTML customization entry form should offer OpacMaintenanceNotice 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. - Enable the "OpacMaintenance" system preference. - Edit the OpacMaintenanceNotice HTML customization and add unique content to the "fr-FR" tab. - Try to view any page in the OPAC. You should see the content you added to the OpacMaintenanceNotice HTML customization. - Switch to your updated translation. The page should redisplay with your translated content. - Go to Administration -> System preferences and search for "OpacMaintenanceNotice." The search should return no results. Signed-off-by: David Nind Signed-off-by: Marcel de Rooy --- ...aintenanceNotice-to-additional-contents.pl | 29 +++++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 - .../en/modules/admin/preferences/opac.pref | 8 +--- .../en/modules/tools/additional-contents.tt | 2 +- .../bootstrap/en/includes/opac-bottom.inc | 4 +- .../bootstrap/en/modules/maintenance.tt | 37 +++++++++++++++++-- opac/maintenance.pl | 13 +++++-- 7 files changed, 77 insertions(+), 17 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug-23798-move-OpacMaintenanceNotice-to-additional-contents.pl diff --git a/installer/data/mysql/atomicupdate/bug-23798-move-OpacMaintenanceNotice-to-additional-contents.pl b/installer/data/mysql/atomicupdate/bug-23798-move-OpacMaintenanceNotice-to-additional-contents.pl new file mode 100755 index 0000000000..3b3a151f0f --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug-23798-move-OpacMaintenanceNotice-to-additional-contents.pl @@ -0,0 +1,29 @@ +use Modern::Perl; + +return { + bug_number => "23798", + description => "Convert OpacMaintenanceNotice system preference to additional contents", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + # Get any existing value from the OpacMaintenanceNotice system preference + my ($opacmaintenancenotice) = $dbh->selectrow_array( + q| + SELECT value FROM systempreferences WHERE variable='OpacMaintenanceNotice'; + | + ); + if ($opacmaintenancenotice) { + + # Insert any values found from system preference into additional_contents + $dbh->do( + "INSERT INTO additional_contents ( category, code, location, branchcode, title, content, lang, published_on ) VALUES ('html_customizations', 'OpacMaintenanceNotice', 'OpacMaintenanceNotice', NULL, 'OpacMaintenanceNotice default', ?, 'default', CAST(NOW() AS date) )", + undef, $opacmaintenancenotice + ); + + # Remove old system preference + $dbh->do("DELETE FROM systempreferences WHERE variable='OpacMaintenanceNotice'"); + say $out "Bug 23798 update done"; + } + } + } diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 50ab4e1521..662ad8778f 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -484,7 +484,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('OpacLocationOnDetail','holding','holding|home|both|column','In the OPAC detail, display the shelving location on its own column or under a library columns.', 'Choice'), ('OPACMandatoryHoldDates', '', '|start|end|both', 'Define which hold dates are required on OPAC reserve form', 'Choice'), ('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'), ('OpacMaxItemsToDisplay','50','','Max items to display at the OPAC on a biblio detail','Integer'), ('OpacMetaDescription','','','This description will show in search engine results (160 characters).','Textarea'), ('OPACMySummaryHTML','','70|10','Enter the HTML that will appear in a column on the \'my summary\' and \'my checkout 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 39815ecf72..461f5273fe 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 @@ -55,13 +55,7 @@ OPAC: choices: 1: Show 0: "Don't show" - - "a warning that the OPAC is under maintenance, instead of the OPAC itself. Note: this shows the same warning as when the database needs to be upgraded, but unconditionally." - - - - 'Show the following HTML when OpacMaintenance is enabled:' - - pref: OpacMaintenanceNotice - type: textarea - syntax: text/html - class: code + - "a warning that the OPAC is under maintenance, instead of the OPAC itself. Note: this shows the same warning as when the database needs to be upgraded, but unconditionally. A custom message can be shown on OPAC maintenance page by creating an HTML customization in the OpacMaintenanceNotice region." - - "This description will show in search engine results (160 characters)." - pref: OpacMetaDescription 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 2e713d5d5b..ab5fbad1a4 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', 'CatalogConcernHelp', 'CatalogConcernTemplate', 'CookieConsentBar', 'CookieConsentPopup' ] %] + [% SET opac_available_options = [ 'OpacNavRight', 'opacheader', 'OpacCustomSearch', 'OpacMainUserBlock', 'opaccredits', 'OpacLoginInstructions', 'OpacNav', 'OpacNavBottom', 'OpacSuggestionInstructions', 'ArticleRequestsDisclaimerText', 'OpacMoreSearches', 'OpacMySummaryNote', 'OpacLibraryInfo', 'OpacMaintenanceNotice', 'CatalogConcernHelp', 'CatalogConcernTemplate', 'CookieConsentBar', 'CookieConsentPopup' ] %] [% FOREACH l IN opac_available_options.sort %] [% IF l == location %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc index c7ff522e02..943c862eab 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc @@ -55,8 +55,8 @@ [% IF OpacLangSelectorMode == 'both' || OpacLangSelectorMode == 'footer' %] - [% IF ( opaclanguagesdisplay ) %] - [% IF ( languages_loop && opaclanguagesdisplay ) %] + [% IF ( Koha.Preference('opaclanguagesdisplay') ) %] + [% IF ( languages_loop ) %] [% UNLESS ( one_language_enabled ) %]