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
for ( $searchengine ) {
34
for ( $searchengine ) {
Lines 213-223 my $cnt; Link Here
213
my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes") || "itemtypes";
214
my $advanced_search_types = C4::Context->preference("AdvancedSearchTypes") || "itemtypes";
214
my @advanced_search_types = split(/\|/, $advanced_search_types);
215
my @advanced_search_types = split(/\|/, $advanced_search_types);
215
216
217
my $hidingrules = {};
218
my $yaml = C4::Context->preference('OpacHiddenItems');
219
if ( $yaml =~ /\S/ ) {
220
    $yaml = "$yaml\n\n"; # YAML is anal on ending \n. Surplus does not hurt
221
    eval {
222
        $hidingrules = YAML::Load($yaml);
223
    };
224
    if ($@) {
225
        warn "Unable to parse OpacHiddenItems syspref : $@";
226
    }
227
}
228
216
foreach my $advanced_srch_type (@advanced_search_types) {
229
foreach my $advanced_srch_type (@advanced_search_types) {
230
    $advanced_srch_type =~ s/^\s*//;
231
    $advanced_srch_type =~ s/\s*$//;
217
   if ($advanced_srch_type eq 'itemtypes') {
232
   if ($advanced_srch_type eq 'itemtypes') {
218
   # itemtype is a special case, since it's not defined in authorized values
233
   # itemtype is a special case, since it's not defined in authorized values
219
        my @itypesloop;
234
        my @itypesloop;
220
	foreach my $thisitemtype ( sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'} } keys %$itemtypes ) {
235
	foreach my $thisitemtype ( sort {$itemtypes->{$a}->{'description'} cmp $itemtypes->{$b}->{'description'} } keys %$itemtypes ) {
236
            next if $hidingrules->{itype} && any { $_ eq $thisitemtype } @{$hidingrules->{itype}};
237
            next if $hidingrules->{itemtype} && any { $_ eq $thisitemtype } @{$hidingrules->{itemtype}};
221
	    my %row =(  number=>$cnt++,
238
	    my %row =(  number=>$cnt++,
222
		ccl => "$itype_or_itemtype,phr",
239
		ccl => "$itype_or_itemtype,phr",
223
                code => $thisitemtype,
240
                code => $thisitemtype,
Lines 234-239 foreach my $advanced_srch_type (@advanced_search_types) { Link Here
234
       my $advsearchtypes = GetAuthorisedValues($advanced_srch_type, '', 'opac');
251
       my $advsearchtypes = GetAuthorisedValues($advanced_srch_type, '', 'opac');
235
        my @authvalueloop;
252
        my @authvalueloop;
236
	for my $thisitemtype (@$advsearchtypes) {
253
	for my $thisitemtype (@$advsearchtypes) {
254
            my $hiding_key = lc $thisitemtype->{category};
255
            $hiding_key = "location" if $hiding_key eq 'loc';
256
            next if $hidingrules->{$hiding_key} && any { $_ eq $thisitemtype->{authorised_value} } @{$hidingrules->{$hiding_key}};
237
		my %row =(
257
		my %row =(
238
				number=>$cnt++,
258
				number=>$cnt++,
239
				ccl => $advanced_srch_type,
259
				ccl => $advanced_srch_type,
240
- 

Return to bug 12330