Bugzilla – Attachment 95099 Details for
Bug 21249
Syspref to choose whether to search homebranch, holding branch or both for library groups in advanced search
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21249: New syspref controlling branch fields queried against selected library group value in advanced search
Bug-21249-New-syspref-controlling-branch-fields-qu.patch (text/plain), 8.22 KB, created by
Jonathan Druart
on 2019-11-06 11:21:16 UTC
(
hide
)
Description:
Bug 21249: New syspref controlling branch fields queried against selected library group value in advanced search
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2019-11-06 11:21:16 UTC
Size:
8.22 KB
patch
obsolete
>From 1fa8bc1a0341017f7d893c5cb5f613d309652429 Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Mon, 20 Aug 2018 21:49:43 +1200 >Subject: [PATCH] Bug 21249: New syspref controlling branch fields queried > against selected library group value in advanced search > >This commit allows librarians to choose whether they want to query the >homebranch, holdingbranch or homebranch AND holdingbranch when they set >a library group search condition in the staff client and OPAC advanced >searches. > >Test plan: >1. Apply patch and run ./updatedatabase.pl in the koha shell > >2. Restart memcached and plack > >3. In the staff client go to Administration->Global system preferences >and search for the systempreference: AdvancedSearchBranchFieldToUse and >notice by default it is set to 'homebranch and holdingbranch' > >4. Create a library group. Create a subgroup from the library group and add several library branches to the sub group. > >5. Note down the barcode of an item to use for testing searching. Make >sure the items homebranch and holdingbranch are different and the items >homebranch is a child of the sub group created in step 4 > >6. Perform an Advanced search in the staff client and write in the item >barcode as the keyword and select the sub group in the >'Location and availability' section. > >7. Submit the search query and notice the item with a homebranch >existing in the selected sub group is returned. This proves that >when the AdvancedSearchBranchFieldToUse syspref is set to 'homebranch and >holdingbranch' the homebranch value is checked. > >Also note at the top of the search result page the search query is listed: Results of search >with limit(s): '(homebranch: <branch1> or holdingbranch: <branch2> or homebranch: ><homebranch1> or holdingbranch: <branch2>)' > >8. Now edit the item making sure the homebranch branch is not in the >sub group, and making sure the holdingbranch is in the sub group. This is to test that holdingbranch is indeed being checked when >the AdvancedSearchBranchFieldToUse is set to >'homebranch and holdingbranch' > >9. Repeat step 6 and notice the item with a holdingbranch existing >in the selected library group is returned. > >10. Change the value of the AdvancedSearchBranchFieldToUse syspref to >'holdingbranch' and repeat step 6 and again notice the item with a >holdingbranch existing in the selected library group is returned. > >Also note the search query at the top of the page is: "Results of search >with limit(s): '(holdingbranch: <branch1> or holdingbranch: <branch2>)'" >this shows holdingbranch not homebranch is a condition in the query > >11. Change the value of the AdvancedSearchBranchFieldToUse syspref to >'homebranch' > >12. Change the item homebranch back to a branch that is in the sub group >and change the holdingbranch value to a library branch that is not in >the sub group. > >13. Repeat step 6 and notice the item with the homebranch in the >selected library group is returned, so we know the homebranch is being >checked. > >Also note the search query at the top of the page is: " Results of >search with limit(s): '(homebranch: <branch1> or homebranch: <branch2>)'" this shows homebranch not holdingbranch is a condition in the query. > >Sponsored-By: Brimbank Library > >Signed-off-by: Amandine Zocca <azocca@ville-montauban.fr> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > catalogue/search.pl | 15 +++++++++++++-- > .../bug_21249-Branch_to_limit_advanced_search_results.sql | 1 + > .../prog/en/modules/admin/preferences/searching.pref | 8 ++++++++ > opac/opac-search.pl | 15 +++++++++++++-- > 4 files changed, 35 insertions(+), 4 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_21249-Branch_to_limit_advanced_search_results.sql > >diff --git a/catalogue/search.pl b/catalogue/search.pl >index 89a5211b5c..4a6037de08 100755 >--- a/catalogue/search.pl >+++ b/catalogue/search.pl >@@ -412,11 +412,22 @@ my @nolimits = map uri_unescape($_), $cgi->multi_param('nolimit'); > my %is_nolimit = map { $_ => 1 } @nolimits; > @limits = grep { not $is_nolimit{$_} } @limits; > >+my $branchfield = C4::Context->preference('AdvancedSearchBranchFieldToUse'); >+ > if($params->{'multibranchlimit'}) { > my $search_group = Koha::Library::Groups->find( $params->{multibranchlimit} ); > my @libraries = $search_group->all_libraries; >- my $multibranch = '('.join( " or ", map { 'branch: ' . $_->branchcode } @libraries ) .')'; >- push @limits, $multibranch if ($multibranch ne '()'); >+ my $multihomebranch = '('.join( " or ", map { 'homebranch: ' . $_->id } @libraries ) .')'; >+ my $multiholdingbranch = '('.join( " or ", map { 'holdingbranch: ' . $_->id } @libraries ) .')'; >+ >+ if ( $branchfield eq "homebranch") { >+ push @limits, $multihomebranch if ( $multihomebranch ne '()'); >+ } elsif ( $branchfield eq "holdingbranch") { >+ push @limits, $multiholdingbranch if ( $multiholdingbranch ne '()'); >+ } else { >+ my $multihomeandholdingbranch = '('.join( " or ", map { 'homebranch: ' . $_->id, 'holdingbranch: ' . $_->id} @libraries ) .')'; >+ push @limits, $multihomeandholdingbranch if ($multihomeandholdingbranch ne '()'); >+ } > } > > my $available; >diff --git a/installer/data/mysql/atomicupdate/bug_21249-Branch_to_limit_advanced_search_results.sql b/installer/data/mysql/atomicupdate/bug_21249-Branch_to_limit_advanced_search_results.sql >new file mode 100644 >index 0000000000..08e6e38e01 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_21249-Branch_to_limit_advanced_search_results.sql >@@ -0,0 +1 @@ >+INSERT INTO systempreferences (variable, value, options, explanation, type) VALUES ('AdvancedSearchBranchFieldToUse', 'homebranch and holdingbranch', 'homebranch|holdingbranch|homebranch and holdingbranch', 'When a library or group of libraries is selected from the advanced search compare the selected branch value against this branch field(s) selected', 'choice'); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref >index 497447f5aa..e5b16eb945 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref >@@ -159,6 +159,14 @@ Searching: > az: from A to Z. > za: from Z to A. > - >+ - pref: AdvancedSearchBranchFieldToUse >+ default: homebranch and holdingbranch >+ choices: >+ homebranch: homebranch >+ holdingbranch: holdingbranch >+ homebranch and holdingbranch: homebranch and holdingbranch >+ - When a library or group of libraries is selected from the advanced search compare the selected branch value against this branch field(s) selected >+ - > - pref: displayFacetCount > type: boolean > default: no >diff --git a/opac/opac-search.pl b/opac/opac-search.pl >index ea78ca0b23..f98cb51ffa 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -500,11 +500,22 @@ if (@searchCategories > 0) { > > @limits = map { uri_unescape($_) } @limits; > >+my $branchfield = C4::Context->preference('AdvancedSearchBranchFieldToUse'); >+ > if($params->{'multibranchlimit'}) { > my $search_group = Koha::Library::Groups->find( $params->{multibranchlimit} ); > my @libraries = $search_group->all_libraries; >- my $multibranch = '('.join( " or ", map { 'branch: ' . $_->branchcode } @libraries ) .')'; >- push @limits, $multibranch if ($multibranch ne '()'); >+ my $multihomebranch = '('.join( " or ", map { 'homebranch: ' . $_->id } @libraries ) .')'; >+ my $multiholdingbranch = '('.join( " or ", map { 'holdingbranch: ' . $_->id } @libraries ) .')'; >+ >+ if ( $branchfield eq "homebranch" ) { >+ push @limits, $multihomebranch if ( $multihomebranch ne '()'); >+ } elsif ( $branchfield eq "holdingbranch") { >+ push @limits, $multiholdingbranch if ( $multiholdingbranch ne '()'); >+ } else { >+ my $multihomeandholdingbranch = '('.join( " or ", map { 'homebranch: ' . $_->id, 'holdingbranch: ' . $_->id} @libraries ) .')'; >+ push @limits, $multihomeandholdingbranch if ($multihomeandholdingbranch ne '()'); >+ } > } > > my $available; >-- >2.11.0
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 21249
:
78013
|
78014
|
78921
|
82138
|
83518
|
93345
|
93346
|
95099
|
95100
|
95101
|
103618
|
103619
|
103620
|
103621
|
103622
|
117220
|
117221
|
117222
|
117223
|
117224
|
120481
|
120567
|
120568
|
120569
|
120570
|
120571
|
120572
|
120575
|
120576
|
120577
|
120578
|
120579
|
120580