Bugzilla – Attachment 152451 Details for
Bug 23817
Normalize phone number when searching patrons
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23817: Include all phone numbers
Bug-23817-Include-all-phone-numbers.patch (text/plain), 3.61 KB, created by
Emily Lamancusa (emlam)
on 2023-06-16 18:43:52 UTC
(
hide
)
Description:
Bug 23817: Include all phone numbers
Filename:
MIME Type:
Creator:
Emily Lamancusa (emlam)
Created:
2023-06-16 18:43:52 UTC
Size:
3.61 KB
patch
obsolete
>From 78df5ad63ba0c34a141e89d6ca7d4587cece5832 Mon Sep 17 00:00:00 2001 >From: David Cook <dcook@prosentient.com.au> >Date: Fri, 2 Jun 2023 02:52:04 +0000 >Subject: [PATCH] Bug 23817: Include all phone numbers > >Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov> >--- > Koha/REST/V1/Patrons.pm | 25 ++++++++++++------- > .../prog/en/includes/patron-search.inc | 3 +-- > 2 files changed, 17 insertions(+), 11 deletions(-) > >diff --git a/Koha/REST/V1/Patrons.pm b/Koha/REST/V1/Patrons.pm >index 28e186ad7d..9fd60e02e6 100644 >--- a/Koha/REST/V1/Patrons.pm >+++ b/Koha/REST/V1/Patrons.pm >@@ -472,23 +472,23 @@ sub guarantors_can_see_checkouts { > > sub _parse_dbic_query_for_dt { > my ($q_params,$collector) = @_; >+ my %allowed_keys = ( >+ 'me.phone' => 1, >+ 'me.phonepro' => 1, >+ 'me.B_phone' => 1, >+ 'me.altcontactphone' => 1, >+ 'me.mobile' => 1, >+ ); > if(ref($q_params) && ref($q_params) eq 'HASH') { > foreach my $key (keys %{$q_params}) { >- #FIXME: The table preference is always required so we might want to handle other scenarios... >- if ($key eq 'me.phone'){ >+ if ($allowed_keys{$key}){ > my $query = $q_params->{$key}; > if ($query->{'like'}){ > my $like = $query->{'like'}; > #NOTE: Remove the hashref, and add a data structure to add to the WHERE clause via the attributes... > delete $q_params->{$key}; >- my $collection = \["regexp_replace(me.phone,?,?) LIKE ?","[^0-9]","",$like]; >+ my $collection = \["regexp_replace($key,?,?) LIKE ?","[^0-9]","",$like]; > push(@$collector,$collection); >- #NOTE: Rewrite the query to use a subquery where we can perform phone number normalization (but it's slow) >- #$q_params->{$key} = { >- # '-in' => \["SELECT phone FROM borrowers WHERE regexp_replace(phone,?,?) LIKE ?","[^0-9]","",$query->{'like'}], >- #}; >- #NOTE: Technically, you could replace the whole hashref, but that would nuke any OR query in the same hashref >- #return \["regexp_replace(me.phone,?,?) LIKE ?","[^0-9]","",$query->{'like'}]; > } > } > else { >@@ -506,6 +506,13 @@ sub _parse_dbic_query_for_dt { > } > } > >+=head3 preprocess_dbic_for_datatables >+ >+Method for preprocessing DBIC queries sent from DataTables, so a WHERE >+clause can be injected into the query if one doesn't already exist. >+ >+=cut >+ > sub preprocess_dbic_for_datatables { > my ($c,$q_params,$attributes) = @_; > my @collector = (); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >index f62bb64ebc..fd2eb7c994 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >@@ -308,10 +308,9 @@ > if ( !search_fields ) { > search_fields = "[% Koha.Preference('DefaultPatronSearchFields') || 'firstname,middle_name,surname,othernames,cardnumber,userid' | html %]"; > } >- if (search_fields == 'phone'){ >+ if (search_fields == 'phone,phonepro,B_phone,altcontactphone,mobile'){ > patterns = [pattern.replace(/[^\+0-9]/g,'')]; > } >- > let subquery_and = []; > patterns.forEach(function(pattern,i){ > let sub_or = []; >-- >2.34.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 23817
:
140610
|
140648
|
145219
|
145221
|
151961
|
151962
|
152450
| 152451