View | Details | Raw Unified | Return to bug 12330
Collapse All | Expand All

(-)a/opac/opac-search.pl (-1 / +20 lines)
Lines 28-33 use Modern::Perl; Link Here
28
# to perform, etc.
28
# to perform, etc.
29
## load Koha modules
29
## load Koha modules
30
use C4::Context;
30
use C4::Context;
31
use List::MoreUtils q/any/;
31
32
32
my $searchengine = C4::Context->preference("SearchEngine");
33
my $searchengine = C4::Context->preference("SearchEngine");
33
if ( $searchengine =~ /^Solr$/ ) {
34
if ( $searchengine =~ /^Solr$/ ) {
Lines 210-220 my $cnt; Link Here
210
my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes") || "itemtypes";
211
my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes") || "itemtypes";
211
my @advanced_search_types = split(/\|/, $advanced_search_types);
212
my @advanced_search_types = split(/\|/, $advanced_search_types);
212
213
214
my $hidingrules = {};
215
my $yaml = C4::Context->preference('OpacHiddenItems');
216
if ( $yaml =~ /\S/ ) {
217
    $yaml = "$yaml\n\n"; # YAML expects trailing newline. Surplus does not hurt.
218
    eval {
219
        $hidingrules = YAML::Load($yaml);
220
    };
221
    if ($@) {
222
        warn "Unable to parse OpacHiddenItems syspref : $@";
223
    }
224
}
225
213
foreach my $advanced_srch_type (@advanced_search_types) {
226
foreach my $advanced_srch_type (@advanced_search_types) {
227
    $advanced_srch_type =~ s/^\s*//;
228
    $advanced_srch_type =~ s/\s*$//;
214
   if ($advanced_srch_type eq 'itemtypes') {
229
   if ($advanced_srch_type eq 'itemtypes') {
215
   # itemtype is a special case, since it's not defined in authorized values
230
   # itemtype is a special case, since it's not defined in authorized values
216
        my @itypesloop;
231
        my @itypesloop;
217
	foreach my $thisitemtype ( sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'} } keys %$itemtypes ) {
232
	foreach my $thisitemtype ( sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'} } keys %$itemtypes ) {
233
            next if $hidingrules->{itype} && any { $_ eq $thisitemtype } @{$hidingrules->{itype}};
234
            next if $hidingrules->{itemtype} && any { $_ eq $thisitemtype } @{$hidingrules->{itemtype}};
218
	    my %row =(  number=>$cnt++,
235
	    my %row =(  number=>$cnt++,
219
		ccl => "$itype_or_itemtype,phr",
236
		ccl => "$itype_or_itemtype,phr",
220
                code => $thisitemtype,
237
                code => $thisitemtype,
Lines 231-236 foreach my $advanced_srch_type (@advanced_search_types) { Link Here
231
       my $advsearchtypes = GetAuthorisedValues($advanced_srch_type, '', 'opac');
248
       my $advsearchtypes = GetAuthorisedValues($advanced_srch_type, '', 'opac');
232
        my @authvalueloop;
249
        my @authvalueloop;
233
	for my $thisitemtype (@$advsearchtypes) {
250
	for my $thisitemtype (@$advsearchtypes) {
251
            my $hiding_key = lc $thisitemtype->{category};
252
            $hiding_key = "location" if $hiding_key eq 'loc';
253
            next if $hidingrules->{$hiding_key} && any { $_ eq $thisitemtype->{authorised_value} } @{$hidingrules->{$hiding_key}};
234
		my %row =(
254
		my %row =(
235
				number=>$cnt++,
255
				number=>$cnt++,
236
				ccl => $advanced_srch_type,
256
				ccl => $advanced_srch_type,
237
- 

Return to bug 12330