Bugzilla – Attachment 29585 Details for
Bug 12330
hide item types, collections, locations on advanced search if hidden by opachiddenitems
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12330: OpacHiddenItems not affecting Advanced Search
Bug-12330-OpacHiddenItems-not-affecting-Advanced-S.patch (text/plain), 4.03 KB, created by
Marcel de Rooy
on 2014-07-09 14:11:34 UTC
(
hide
)
Description:
Bug 12330: OpacHiddenItems not affecting Advanced Search
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2014-07-09 14:11:34 UTC
Size:
4.03 KB
patch
obsolete
>From 7559cc56042c43f4a8dd66adf693f6ebec42ac58 Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Thu, 29 May 2014 18:31:03 -0400 >Subject: [PATCH] Bug 12330: OpacHiddenItems not affecting Advanced Search >Content-Type: text/plain; charset=utf-8 > >This patch affects only the area displayed on Advanced Search >by setting the AdvancedSearchTypes OPAC system preference >accordingly. Prior to this patch, no filtering based on >OpacHiddenItems was done. This patch determines if itemtypes, >collections, or shelving locations are hidden and prevents >them from being shown. > >TEST PLAN >--------- > 1) Back up your DB (always handy) > 2) Set the Searching system preference AdvancedSearchTypes to: > 'itemtypes|ccode|loc' (without the single quotes). > 3) Set the OPAC system preference OpacHiddenItems to include the > lines: > itype: [{list of itemtype codes separated by commas}] > location: [{list of comma delimited shelving location codes}] > ccode: [{list of comma delimited collection codes}] > Make sure to exclude one value for each, so there will be at > least one known thing on each tab. > 4) Open the OPAC. > 5) Click on 'Advanced Search' > -- three tabs appear: Itemtypes, Collection, Shelving location > -- Everything is visible > 6) Set the Searching system preference AdvancedSearchTypes to: > 'itemtypes | ccode | loc' (without the single quotes). > 7) Refresh the OPAC. > -- There will be three tabs, but ugliness ensues. > 8) Apply the patch > 9) Refresh the OPAC. > -- You will see: Itemtypes, Collection, Shelving location > -- Only excluded values from OpacHiddenItems will be seen. >10) Run koha qa test tools > >Signed-off-by: Nicole C. Engard <nengard@bywatersolutions.com> >All tests pass > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Small rewording in comment only. >--- > opac/opac-search.pl | 20 ++++++++++++++++++++ > 1 files changed, 20 insertions(+), 0 deletions(-) > >diff --git a/opac/opac-search.pl b/opac/opac-search.pl >index cc6beb7..2360b88 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -28,6 +28,7 @@ use Modern::Perl; > # to perform, etc. > ## load Koha modules > use C4::Context; >+use List::MoreUtils q/any/; > > my $searchengine = C4::Context->preference("SearchEngine"); > if ( $searchengine =~ /^Solr$/ ) { >@@ -210,11 +211,27 @@ my $cnt; > my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes") || "itemtypes"; > my @advanced_search_types = split(/\|/, $advanced_search_types); > >+my $hidingrules = {}; >+my $yaml = C4::Context->preference('OpacHiddenItems'); >+if ( $yaml =~ /\S/ ) { >+ $yaml = "$yaml\n\n"; # YAML expects trailing newline. Surplus does not hurt. >+ eval { >+ $hidingrules = YAML::Load($yaml); >+ }; >+ if ($@) { >+ warn "Unable to parse OpacHiddenItems syspref : $@"; >+ } >+} >+ > foreach my $advanced_srch_type (@advanced_search_types) { >+ $advanced_srch_type =~ s/^\s*//; >+ $advanced_srch_type =~ s/\s*$//; > if ($advanced_srch_type eq 'itemtypes') { > # itemtype is a special case, since it's not defined in authorized values > my @itypesloop; > foreach my $thisitemtype ( sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'} } keys %$itemtypes ) { >+ next if $hidingrules->{itype} && any { $_ eq $thisitemtype } @{$hidingrules->{itype}}; >+ next if $hidingrules->{itemtype} && any { $_ eq $thisitemtype } @{$hidingrules->{itemtype}}; > my %row =( number=>$cnt++, > ccl => "$itype_or_itemtype,phr", > code => $thisitemtype, >@@ -231,6 +248,9 @@ foreach my $advanced_srch_type (@advanced_search_types) { > my $advsearchtypes = GetAuthorisedValues($advanced_srch_type, '', 'opac'); > my @authvalueloop; > for my $thisitemtype (@$advsearchtypes) { >+ my $hiding_key = lc $thisitemtype->{category}; >+ $hiding_key = "location" if $hiding_key eq 'loc'; >+ next if $hidingrules->{$hiding_key} && any { $_ eq $thisitemtype->{authorised_value} } @{$hidingrules->{$hiding_key}}; > my %row =( > number=>$cnt++, > ccl => $advanced_srch_type, >-- >1.7.7.6
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 12330
:
28565
|
28566
|
28570
| 29585 |
29586