From c64dd80f20d7f6fce9805a3c457d4df63adce972 Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Mon, 22 Jul 2019 16:06:47 +0000 Subject: [PATCH] Bug 12949: (follow-up) Disable syspref by default Implemented fixes based on test feedback: * Set the GuarantorsMustBeLinkedToPatronAccount syspref to 0 (disabled) by default * When syspref is enabled and a guarantee is updated to an 'Adult' their borrowers.guarantorid, borrowers.contactname, borrowers.contactfirstname, borrowers.relationship are reset to NULL. Updated test plan: 1. Create an adult patron (make sure to set a first and last name) and select 'Add child' and save the child record 2. Run the following database query, and notice there are values for guarantorid, contactname, contactfirstname, relationship: SELECT guarantorid, contactname, contactfirstname, relationship FROM borrowers WHERE borrowernumber=; 3. On the child record select More > Update child to adult patron. 4. Select a new adult patron category and save 5. Notice guarantor information is still displayed on the new adults record 6. Repeat step 2 and notice guarantorid is empty/NULL and contactname and contactfirstname, relationship are unchanged 7. Now create a child record with an unlinked guarantor: In the patron home page select 'New patron'. Note: Make sure the patron category you select is of category type 'Child' 8. In the guarantor area of the patron creation page input a firstname and surname and don't select 'Set to patron' and save/submit the page 9. Repeat step 2 making the borrowernumber you enter the borrowernumber of the patron you made in step 8 and notice guarantorid is empty and contactname and contactfirstname are not empty. i.e. our guarantor is not linked to a Koha patron 10. Notice guarantor information is shown on the patron summary page of our user 11. Repeat step 3,4,5 and notice guarantor information is still displayed 12. Apply patch 13. Navigate to installer/data/mysql directory Enter the Koha shell: sudo koha-shell Run: ./updatedatabase.pl 14. In staff client visit Administration > Global System preferences and search for GuarantorsMustBeLinkedToPatronAccount syspref and confirm it is enabled 15. Repeat steps 1-5 and notice that the guarantor information is not displayed on the new adult's record also in the database confirm the guarantorid, contactname, contactfirstname, relationship are set to NULL. 16. Repeat steps 7-10 and notice that the guarantor information is not displayed on the new adult's record 17. Set GuarantorsMustBeLinkedToPatronAccount syspref to disabled 18. Repeat steps 1-5 and confirm the guarantor information is displayed on the new adult's record (i.e. setting GuarantorsMustBeLinkedToPatronAccount syspref to disabled keeps the current Koha behaviour) also check in the database and confirm that guarantorid is NULL, and contactname, contactfirstname and relationship are not NULL. 19. Repeat steps 7-10 and confirm the guarantor information is displayed Also check in the database and confirm the guarantorid is NULL and contactname, contactfirstname and relationship are not NULL 20. Sign off Sponsored-By: Brimbank Library, Australia --- ...g_12949-add_syspref_to_control_display_of_unlinked_guarantor.sql | 2 +- installer/data/mysql/sysprefs.sql | 2 +- .../intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref | 2 +- members/memberentry.pl | 5 +++++ members/update-child.pl | 6 ++++++ 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/installer/data/mysql/atomicupdate/bug_12949-add_syspref_to_control_display_of_unlinked_guarantor.sql b/installer/data/mysql/atomicupdate/bug_12949-add_syspref_to_control_display_of_unlinked_guarantor.sql index bfe39a0..eaafb11 100644 --- a/installer/data/mysql/atomicupdate/bug_12949-add_syspref_to_control_display_of_unlinked_guarantor.sql +++ b/installer/data/mysql/atomicupdate/bug_12949-add_syspref_to_control_display_of_unlinked_guarantor.sql @@ -1 +1 @@ -INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('GuarantorsMustBeLinkedToPatronAccount', 1, NULL, 'When adding a guarantor to a borrower Koha will enforce that the guarantor must be linked to a patron account', 'YesNo'); +INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('GuarantorsMustBeLinkedToPatronAccount', 0, NULL, 'If enabled when adding a guarantor to a borrower Koha will enforce that the guarantor must be linked to a patron account', 'YesNo'); diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 4555258..4039f4a 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -199,7 +199,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('GoogleOpenIDConnectDefaultBranch', '','','This branch code will be used to create Google OpenID Connect patrons.','Textarea'), ('GoogleOpenIDConnectDefaultCategory','','','This category code will be used to create Google OpenID Connect patrons.','Textarea'), ('GoogleOpenIDConnectDomain', '', NULL, 'Restrict Google OpenID Connect to this domain (or subdomains of this domain). Leave blank for all Google domains', 'Free'), -('GuarantorsMustBeLinkedToPatronAccount', 1, NULL, 'When adding a guarantor to a borrower Koha will enforce that the guarantor must be linked to a patron account', 'YesNo'), +('GuarantorsMustBeLinkedToPatronAccount', 0, NULL, 'If enabled when adding a guarantor to a borrower Koha will enforce that the guarantor must be linked to a patron account', 'YesNo'), ('hidelostitems','0','','If ON, disables display of\"lost\" items in OPAC.','YesNo'), ('HidePatronName','0','','If this is switched on, patron\'s cardnumber will be shown instead of their name on the holds and catalog screens','YesNo'), ('hide_marc','0',NULL,'If ON, disables display of MARC fields, subfield codes & indicators (still shows data)','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref index 617524d..bf399a6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref @@ -232,7 +232,7 @@ Patrons: choices: yes: 'Enable' no: 'Disable' - - When adding a guarantor to a borrower Koha will enforce that the guarantor must be linked to a patron account + - If enabled when adding a guarantor to a borrower Koha will enforce that the guarantor must be linked to a patron account Privacy: - diff --git a/members/memberentry.pl b/members/memberentry.pl index 2f84d92..fd6493b 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -532,6 +532,11 @@ if ((!$nok) and $nodouble and ($op eq 'insert' or $op eq 'save')){ my $borrowercategory = Koha::Patron::Categories->find($newdata{categorycode}); if (( $borrowercategory->category_type ne 'C' ) && ( $borrowercategory->category_type ne 'P' )) { $newdata{guarantorid} = ''; + if (C4::Context->preference('GuarantorsMustBeLinkedToPatronAccount')) { + $newdata{contactname} = ''; + $newdata{contactfirstname} = ''; + $newdata{relationship} = ''; + } } $patron->set(\%newdata)->store if scalar(keys %newdata) > 1; # bug 4508 - avoid crash if we're not diff --git a/members/update-child.pl b/members/update-child.pl index b0aff0d..2afdc62 100755 --- a/members/update-child.pl +++ b/members/update-child.pl @@ -85,6 +85,12 @@ elsif ( $op eq 'update' ) { die "You are doing something wrong updating this child" unless $adult_category; $patron->guarantorid(undef); + if (C4::Context->preference('GuarantorsMustBeLinkedToPatronAccount')) { + $patron->contactname(undef); + $patron->contactfirstname(undef); + $patron->relationship(undef); + } + $patron->categorycode($adult_category->categorycode); $patron->store; -- 2.1.4