From b7e12e9c76722f144a54acf6b61d1f9d70a80672 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
---
...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 6aed5a753e..066b820edc 100644
--- a/installer/data/mysql/mandatory/sysprefs.sql
+++ b/installer/data/mysql/mandatory/sysprefs.sql
@@ -565,7 +565,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 be8620a2fa..ddc74adc28 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
@@ -809,12 +809,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 e7df348e3b..33aee81158 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
@@ -496,7 +496,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', 'PatronSelfRegistrationAdditionalInstructions' ] %]
[% FOREACH l IN 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 dc5e3a7388..83455b592e 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' %]
@@ -74,7 +75,11 @@