From c2b4115d9c7b32b14d73d4633c8a8d62aac1ec66 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Fri, 22 Sep 2023 15:27:11 +0000 Subject: [PATCH] Bug 34889: Convert PatronSelfRegistrationAdditionalInstructions system preference to HTML customization This patch moves the PatronSelfRegistrationAdditionalInstructions system preference into HTML customizations, making it possible to have language- and library-specific content. To test you should have some content in the PatronSelfRegistrationAdditionalInstructions 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 previously in the PatronSelfRegistrationAdditionalInstructions preference is now stored there. - The HTML customization entry form should offer PatronSelfRegistrationAdditionalInstructions as a choice under "Display location." - Go to Administration -> System preferences and enable "PatronSelfRegistration." Set "PatronSelfRegistrationVerifyByEmail" to "Don't require." - Go to the OPAC and click "Register here." - Submit a new registration and confirm that the content that was previously stored in the system preference is shown correctly on the registration confirmation page. - Update and reinstall active translations (for instance fr-FR): - cd misc/translator/ - perl translate update fr-FR - perl translate install fr-FR - Enable the translation if necessary under Administration -> System preferences -> language. - Enable the "opaclanguagesdisplay" preference if necessary. - Edit the PatronSelfRegistrationAdditionalInstructions HTML customization and add unique content to the "fr-FR" tab. - Go to the OPAC and switch to your updated translation. Complete the online registration process again to confirm that the content you added for your translation shows up correctly on the confirmation page. - Go to Administration -> System preferences and confirm that the PatronSelfRegistrationAdditionalInstructions preference has been removed. Signed-off-by: David Nind Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi --- ...onalInstructions-to-additional-contents.pl | 32 +++++++++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 - .../en/modules/admin/preferences/opac.pref | 6 ---- .../en/modules/tools/additional-contents.tt | 2 +- .../modules/opac-registration-confirmation.tt | 7 +++- 5 files changed, 39 insertions(+), 9 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug-34889-move-PatronSelfRegistrationAdditionalInstructions-to-additional-contents.pl diff --git a/installer/data/mysql/atomicupdate/bug-34889-move-PatronSelfRegistrationAdditionalInstructions-to-additional-contents.pl b/installer/data/mysql/atomicupdate/bug-34889-move-PatronSelfRegistrationAdditionalInstructions-to-additional-contents.pl new file mode 100755 index 0000000000..442092df37 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug-34889-move-PatronSelfRegistrationAdditionalInstructions-to-additional-contents.pl @@ -0,0 +1,32 @@ +use Modern::Perl; + +return { + bug_number => "34889", + description => "Move PatronSelfRegistrationAdditionalInstructions to additional contents", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + # Get any existing value from the PatronSelfRegistrationAdditionalInstructions system preference + my ($patronselfregistrationadditionalinstructions) = $dbh->selectrow_array( + q| + SELECT value FROM systempreferences WHERE variable='PatronSelfRegistrationAdditionalInstructions'; + | + ); + if ($patronselfregistrationadditionalinstructions) { + + # 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', 'PatronSelfRegistrationAdditionalInstructions', 'PatronSelfRegistrationAdditionalInstructions', NULL, ?, ?, ?, CAST(NOW() AS date) )", + undef, "PatronSelfRegistrationAdditionalInstructions $lang", + $patronselfregistrationadditionalinstructions, $lang + ); + } + + # Remove old system preference + $dbh->do("DELETE FROM systempreferences WHERE variable='PatronSelfRegistrationAdditionalInstructions'"); + say $out "Bug 34889 update done"; + } + } + } diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 286093a8e6..c006d10cbe 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -571,7 +571,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('PatronSelfModificationBorrowerUnwantedField','',NULL,'Name the fields you don\'t want to display when a patron is editing their information via the OPAC.','free'), ('PatronSelfModificationMandatoryField','',NULL,'Define the required fields when a patron is editing their information via the OPAC','free'), ('PatronSelfRegistration','0',NULL,'If enabled, patrons will be able to register themselves via the OPAC.','YesNo'), -('PatronSelfRegistrationAdditionalInstructions','','','A free text field to display additional instructions to newly self registered patrons.','free'), ('PatronSelfRegistrationBorrowerMandatoryField','surname|firstname',NULL,'Choose the mandatory fields for a patron\'s account, when registering via the OPAC.','free'), ('PatronSelfRegistrationBorrowerUnwantedField','',NULL,'Name the fields you don\'t want to display when registering a new patron via the OPAC.','free'), ('PatronSelfRegistrationConfirmEmail', '0', NULL, 'Require users to confirm their email address by entering it twice.', 'YesNo'), 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 f6dc65cb3c..a68e7eaa2d 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 @@ -799,12 +799,6 @@ OPAC: type: modalselect source: borrowers exclusions: sort1|sort2|gonenoaddress|lost|flags - - - - "Display the following additional instructions for patrons who self register via the OPAC ( HTML is allowed ):" - - pref: PatronSelfRegistrationAdditionalInstructions - type: textarea - syntax: text/html - class: html - - pref: PatronSelfRegistrationEmailMustBeUnique 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 d8166c4999..57d81b7af0 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' ] %] + [% SET opac_available_options = [ 'OpacNavRight', 'opacheader', 'OpacCustomSearch', 'OpacMainUserBlock', 'opaccredits', 'OpacLoginInstructions', 'OpacNav', 'OpacNavBottom', 'OpacSuggestionInstructions', 'ArticleRequestsDisclaimerText', 'OpacMoreSearches', 'OpacMySummaryNote', 'OpacLibraryInfo', 'OpacMaintenanceNotice', 'OPACResultsSidebar', '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-registration-confirmation.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-registration-confirmation.tt index 9c103dbad9..be96685e41 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-registration-confirmation.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-registration-confirmation.tt @@ -4,6 +4,7 @@ [% SET OpacNavRight = AdditionalContents.get( location => "OpacNavRight", lang => news_lang, library => logged_in_user.branchcode || default_branch ) %] [% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] [% SET OpacNavBottom = AdditionalContents.get( location => "OpacNavBottom", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] +[% SET PatronSelfRegistrationAdditionalInstructions = AdditionalContents.get( location => "PatronSelfRegistrationAdditionalInstructions", lang => lang, library => branchcode || default_branch ) %] [% INCLUDE 'doc-head-open.inc' %] [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog [% INCLUDE 'doc-head-close.inc' %] @@ -69,7 +70,11 @@

[% END %] -
[% PatronSelfRegistrationAdditionalInstructions | $raw %]
+ [% IF ( PatronSelfRegistrationAdditionalInstructions ) %] +
+ [% PROCESS koha_news_block news => PatronSelfRegistrationAdditionalInstructions %] +
+ [% END %] -- 2.39.5