From a54646ff69a8ce954c12e5b9608117357501a4fb Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 21 Apr 2022 12:52:32 +0100 Subject: [PATCH] Bug 30576: Use DefaultPatronSearchFields in patron search This patch corrects the handling of the 'Standard' search field in patron searches such that it accurately reflects the contents of the DefaultPatronSearchFields system preference and falls back to a hard coded list instead of always using the hard coded list. To test: 1) Empty the contents of DefaultPatronSearchFields systempreference 2) Perform a patron search from the header search 3) Inspect the patrons API request and note that we search on the default fallback fields of firstname, surname, othernames, cardnumber and userid (and some extended attributes which are historically hard coded). 4) Navigate to the memebers-home by clicking the 'Patrons' button from the main page 5) Perform another search using the filters on the left with 'Standard' selected. 6) Note the same list of search fields used as above in the patrons API request. 7) Update the DefaultPatronSearchFields systempreference adding one or more borrower fields in a comma delimited list. 8) Repeat steps 2 -> 6 but this time upon inspecting the API request you should find that only the fields in your DefaultPatronSearchFields list are searched (along with the hard coded extended attributes list). 9) Signoff Signed-off-by: Jonathan Druart Signed-off-by: Jonathan Druart Signed-off-by: Nick Clemens Signed-off-by: Fridolin Somers --- .../intranet-tmpl/prog/en/includes/patron-search-header.inc | 5 ++--- koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc | 5 ++--- koha-tmpl/intranet-tmpl/prog/en/includes/patronfields.inc | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search-header.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search-header.inc index e7368bd8d2..5a1df7600e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search-header.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search-header.inc @@ -23,9 +23,8 @@

- [% pref_fields = Koha.Preference('DefaultPatronSearchFields').split(',') %] - [% default_fields = [ 'firstname,surname,othernames,cardnumber,userid', 'surname', 'cardnumber', 'email', 'borrowernumber', 'userid', 'phone', 'address', 'dateofbirth', 'sort1', 'sort2' ] %] - [% search_options = default_fields.merge(pref_fields).unique %] + [% SET standard = Koha.Preference('DefaultPatronSearchFields') || 'firstname,surname,othernames,cardnumber,userid' %] + [% SET search_options = [ standard, 'surname', 'cardnumber', 'email', 'borrowernumber', 'userid', 'phone', 'address', 'dateofbirth', 'sort1', 'sort2' ] %] [% FOREACH s_o IN search_options %] [% display_name = PROCESS patron_fields name=s_o %] [% NEXT IF !display_name %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patronfields.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patronfields.inc index 5e1c58f38e..416a5ae26c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patronfields.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patronfields.inc @@ -1,6 +1,6 @@ [%- BLOCK patron_fields -%] [%- SWITCH name -%] - [%- CASE 'firstname,surname,othernames,cardnumber,userid' -%]Standard + [%- CASE standard -%]Standard [%- CASE 'borrowernumber' -%]Borrowernumber [%- CASE 'cardnumber' -%]Card number [%- CASE 'surname' -%]Surname -- 2.39.5