Bugzilla – Attachment 78013 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-.patch (text/plain), 8.43 KB, created by
Alex Buckley
on 2018-08-20 11:48:22 UTC
(
hide
)
Description:
Bug 21249 - New syspref controlling branch fields queried against selected library group value in advanced search
Filename:
MIME Type:
Creator:
Alex Buckley
Created:
2018-08-20 11:48:22 UTC
Size:
8.43 KB
patch
obsolete
>From e65d12d6f6c3790318e20f7ef34332ae91096ea5 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 (if you do not already have one) and add >several library branches to the 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 branch of the library group created in step 4 > >5. Perform an Advanced search in the staff client and write in the >keyword as the barcode of the item and select the library group in the >'Location and availability' section. > >6. Submit the search query and notice the item with a homebranch >existing in the selected library 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>)' > >7. Now edit the item making sure the homebranch branch is not in the >library group, and making sure the holdingbranch is in the library >group. This is to test that holdingbranch is indeed being checked when >the AdvancedSearchBranchFieldToUse is set to >'AdvancedSearchBranchFieldToUse'. > >8. Repeat step 5 and 6 and notice the item with a holdingbranch existing >in the selected library group is returned. This proves that when the >AdvancedSearchBranchFieldToUse syspref is set to 'homebranch and >holdingbranch' the holdingbranch is checked. > >9. Change the value of the AdvancedSearchBranchFieldToUse syspref to >'holdingbranch' and repeat step 8 and again notice the item with a >holdingbranch existing in the selected library group is returned so we >know the holdingbranch is being chcked when the 'holdingbranch' value >for the syspref is set. > >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 > >10. Change the homebranch back to a branch that is in the library group >and change the holdingbranch value to a library branch that is not in >the library group. > >11. Repeat step 5 and 6 and notice the item with the homebranch in the >selected library group is returned, so we know the homebranch is being >checked when the 'homebranch' value for the syspref is set. > >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 >--- > catalogue/search.pl | 16 +++++++++++++--- > ...bug_21249-Branch_to_limit_advanced_search_results.sql | 2 ++ > .../prog/en/modules/admin/preferences/searching.pref | 8 ++++++++ > opac/opac-search.pl | 12 +++++++++++- > 4 files changed, 34 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 e776c7e..e1f6aba 100755 >--- a/catalogue/search.pl >+++ b/catalogue/search.pl >@@ -397,12 +397,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 $multihomebranch = '('.join( " or ", map { 'homebranch: ' . $_->id } @libraries ) .')'; >- my $multiholdingbranch = '('.join( " or ", map { 'holdingbranch: ' . $_->id } @libraries ) .')'; >- push @limits, $multihomebranch . " or " . $multiholdingbranch if ($multihomebranch && $multiholdingbranch 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 0000000..4ee7aa7 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_21249-Branch_to_limit_advanced_search_results.sql >@@ -0,0 +1,2 @@ >+INSERT INTO systempreferences (variable, value, options, explanation, type) VALUES ('AdvancedSearchBranchToLimit', '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 ad28e82..ac591a4 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 >@@ -151,6 +151,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 04d3c02..71488c2 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -490,12 +490,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 $multihomebranch = '('.join( " or ", map { 'homebranch: ' . $_->id } @libraries ) .')'; > my $multiholdingbranch = '('.join( " or ", map { 'holdingbranch: ' . $_->id } @libraries ) .')'; >- push @limits, $multihomebranch . " or " . $multiholdingbranch if ($multihomebranch && $multiholdingbranch ne '()'); >+ >+ 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.1.4
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