Bug 13188: Add PatronSelfModificationMandatoryField system preference
authorLucas Gass <lucas@bywatersolutions.com>
Tue, 19 Jan 2021 22:39:57 +0000 (22:39 +0000)
committerFridolin Somers <fridolin.somers@biblibre.com>
Tue, 14 Dec 2021 19:46:22 +0000 (09:46 -1000)
TEST PLAN:
1. Apply patch, updatedatabase, restart_all
2. In the  PatronSelfRegistrationBorrowerMandatoryField add the field password.
3. Go to the self registration page on make sure password is required.
4. Now go to the OPAC modification page, make some changes and attempt to submit. It should work.
5. Go to PatronSelfModificationMandatoryField and select some fields.
6. The columns you selected should now be required.
7. On the PatronSelfModificationMandatoryField page, make sure the select all and clear all buttons work.

Signed-off-by: Kelly McElligott <kelly@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
installer/data/mysql/atomicupdate/bug_13188_add_PatronSelfModificationMandatoryField_syspref.perl [new file with mode: 0644]
installer/data/mysql/mandatory/sysprefs.sql
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref
opac/opac-memberentry.pl

diff --git a/installer/data/mysql/atomicupdate/bug_13188_add_PatronSelfModificationMandatoryField_syspref.perl b/installer/data/mysql/atomicupdate/bug_13188_add_PatronSelfModificationMandatoryField_syspref.perl
new file mode 100644 (file)
index 0000000..9462d3b
--- /dev/null
@@ -0,0 +1,7 @@
+$DBversion = 'XXX'; # will be replaced by the RM
+if( CheckVersion( $DBversion ) ) {
+   $dbh->do(q{
+    INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('PatronSelfModificationMandatoryField','', NULL,'Define the required fields when a patron is editing their information via the OPAC.','multiple');
+    });
+    NewVersion($DBversion, 13188, "Allow configuration of required fields when a patron is editing their information via the OPAC");
+}
index 68877bb..b25a180 100644 (file)
@@ -514,6 +514,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
 ('PatronDuplicateMatchingAddFields','surname|firstname|dateofbirth', NULL,'A list of fields separated by "|" to deduplicate patrons when created','Free'),
 ('patronimages','0',NULL,'Enable patron images for the staff interface','YesNo'),
 ('PatronRemovalDelay','',NULL,'Delay for removing anonymized patrons', 'Integer'),
+('PatronSelfModificationMandatoryField','',NULL,'Name the fields you don\'t want to be required when a patron is editing their information via the OPAC.','free'),
 ('PatronSelfModificationBorrowerUnwantedField','',NULL,'Name the fields you don\'t want to display 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'),
index 00a1cf9..b34fb9d 100644 (file)
@@ -818,6 +818,12 @@ OPAC:
             - "days after account creation."
             - "<br><strong>NOTE:</strong> This system preference requires the <code>misc/cronjobs/cleanup_database.pl</code> cronjob. Ask your system administrator to schedule it."
         -
+            - "The following <a href='http://schema.koha-community.org/__VERSION__/tables/borrowers.html' target='blank'>database columns</a> must be filled in on the patron modification screen:"
+            - pref: PatronSelfModificationMandatoryField
+              type: modalselect
+              source: borrowers
+              exclusions: password|cardnumber|dateexpiry|categorycode
+        -
             - "The following <a href='http://schema.koha-community.org/__VERSION__/tables/borrowers.html' target='blank'>database columns</a> must be filled in on the patron entry screen:"
             - pref: PatronSelfRegistrationBorrowerMandatoryField
               type: modalselect
index 5fab449..03c25fd 100755 (executable)
@@ -391,7 +391,8 @@ sub GetMandatoryFields {
 
     my %mandatory_fields;
 
-    my $BorrowerMandatoryField =
+    my $BorrowerMandatoryField = $action eq 'edit' || $action eq 'update' ?
+      C4::Context->preference("PatronSelfModificationMandatoryField") :
       C4::Context->preference("PatronSelfRegistrationBorrowerMandatoryField");
 
     my @fields = split( /\|/, $BorrowerMandatoryField );