From: Jonathan Druart Date: Wed, 5 Aug 2020 10:20:08 +0000 (+0200) Subject: Bug 6725: Make patron duplicate matching flexible X-Git-Url: http://git.equinoxoli.org/?p=koha.git;a=commitdiff_plain;h=883e86a571e4b3f957c463350584932c5cb0b906 Bug 6725: Make patron duplicate matching flexible This patch adds a new system preference PatronDuplicateMatchingAddFields to list the patron's attributes to use for deduplication. The default value is surname, firstname and dateofbirth to keep existing behaviour. Test plan: 0. Apply the patch and execute the update DB entry 1. Create a new patron with surname, firstname 2. Create another patron with the same surname, firstname values => Confirm you get the duplicate warning 3. Modify the syspref to edit the list of attributes used to dedup 4. Repeat 1 and 2 with different values and confirm that you get the behaviours you expect Note: This is only impacting the add patron form from the UI, not the import patrons tool. Signed-off-by: Kelly McElligott Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart --- diff --git a/installer/data/mysql/atomicupdate/bug_6725.perl b/installer/data/mysql/atomicupdate/bug_6725.perl new file mode 100644 index 0000000..9507062 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_6725.perl @@ -0,0 +1,11 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + + $dbh->do( q{ + INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES + ('PatronDuplicateMatchingAddFields','surname|firstname|dateofbirth', NULL,'A list of fields separated by "|" to deduplicate patrons when created','Free') + }); + + # Always end with this (adjust the bug info) + NewVersion( $DBversion, 6725, "Adds PatronDuplicateMatchingAddFields system preference"); +} diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index d1efc4b..3f5442c 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -482,6 +482,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('OverduesBlockRenewing','allow','allow|blockitem|block','If any of patron checked out documents is late, should renewal be allowed, blocked only on overdue items or blocked on whatever checked out document','Choice'), ('PatronAnonymizeDelay','',NULL,'Delay for anonymizing patrons', 'Integer'), ('PatronAutoComplete','1','Try|Don\'t try','to guess the patron being entered while typing a patron search for circulation or patron search. Only returns the first 10 results at a time.','YesNo'), +('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 Client','YesNo'), ('PatronRemovalDelay','',NULL,'Delay for removing anonymized patrons', 'Integer'), ('PatronSelfModificationBorrowerUnwantedField','',NULL,'Name the fields you don\'t want to display when a patron is editing their information via the OPAC.','free'), 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 30621ec..fa7a797 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 @@ -228,6 +228,12 @@ Patrons: housebound: "Housebound roles" additional: "Additional attributes and identifiers" messaging: "Patron messaging preferences" + - + - "The following database columns:" + - pref: PatronDuplicateMatchingAddFields + type: modalselect + source: borrowers + - "will be used deduplicate patrons." Patron relationships: - - "Guarantors can be the following of those they guarantee:" diff --git a/members/memberentry.pl b/members/memberentry.pl index 671ec5c..fd684c5 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -254,11 +254,10 @@ if ( $op eq 'insert' || $op eq 'modify' || $op eq 'save' || $op eq 'duplicate' ) # Test uniqueness of surname, firstname and dateofbirth if ( ( $op eq 'insert' ) and !$nodouble ) { + my @dup_fields = split '\|', C4::Context->preference('PatronDuplicateMatchingAddFields'); my $conditions; - $conditions->{surname} = $newdata{surname} if $newdata{surname}; - if ( $category_type ne 'I' ) { - $conditions->{firstname} = $newdata{firstname} if $newdata{firstname}; - $conditions->{dateofbirth} = $newdata{dateofbirth} if $newdata{dateofbirth}; + for my $f ( @dup_fields ) { + $conditions->{$f} = $newdata{$f} if $newdata{$f}; } $nodouble = 1; my $patrons = Koha::Patrons->search($conditions); # FIXME Should be search_limited?