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

(-)a/Koha/SearchEngine/Zebra/QueryBuilder.pm (-3 / +23 lines)
Lines 30-38 sub build_query { Link Here
30
}
30
}
31
31
32
sub build_query_compat {
32
sub build_query_compat {
33
    # Because this passes directly on to C4::Search, we have no trouble being
33
    my $self = shift;
34
    # compatible.
34
    my ($operators, $operands, $indexes, $limits, $sort_by, $scan, $lang, $params) = @_;
35
    build_query(@_);
35
36
    my ($error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type)
37
      = $self->build_query(@_);
38
39
    # add OPAC 'hidelostitems'
40
    #if (C4::Context->preference('hidelostitems') == 1) {
41
    #    # either lost ge 0 or no value in the lost register
42
    #    $query ="($query) and ( (lost,st-numeric <= 0) or ( allrecords,AlwaysMatches='' not lost,AlwaysMatches='') )";
43
    #}
44
    #
45
    # add OPAC suppression - requires at least one item indexed with Suppress
46
    if ($params->{suppress}) {
47
        if ( $query_type eq 'pqf' ) {
48
            #$query = "($query) && -(suppress:1)"; #QP syntax
49
            $query = '@not '.$query.' @attr 14=1 @attr 1=9011 1'; #PQF syntax
50
        } else {
51
            $query = "($query) not Suppress=1";
52
        }
53
    }
54
55
    return ($error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type);
36
}
56
}
37
57
38
sub build_authorities_query {
58
sub build_authorities_query {
(-)a/opac/opac-search.pl (-32 / +24 lines)
Lines 532-539 my ($error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_ Link Here
532
532
533
my @results;
533
my @results;
534
534
535
my $suppress = 0;
536
if (C4::Context->preference('OpacSuppression')) {
537
    # OPAC suppression by IP address
538
    if (C4::Context->preference('OpacSuppressionByIPRange')) {
539
        my $IPAddress = $ENV{'REMOTE_ADDR'};
540
        my $IPRange = C4::Context->preference('OpacSuppressionByIPRange');
541
        $suppress = ($IPAddress !~ /^$IPRange/);
542
    }
543
    else {
544
        $suppress = 1;
545
    }
546
}
547
535
## I. BUILD THE QUERY
548
## I. BUILD THE QUERY
536
( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type) = $builder->build_query_compat(\@operators,\@operands,\@indexes,\@limits,\@sort_by, 0, $lang, { expanded_facet => $expanded_facet });
549
( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type)
550
  = $builder->build_query_compat(
551
    \@operators,
552
    \@operands,
553
    \@indexes,
554
    \@limits,
555
    \@sort_by,
556
    0,
557
    $lang,
558
    { expanded_facet => $expanded_facet, suppress => $suppress }
559
    );
537
560
538
sub _input_cgi_parse {
561
sub _input_cgi_parse {
539
    my @elements;
562
    my @elements;
Lines 553-588 $template->param ( QUERY_INPUTS => \@query_inputs ); Link Here
553
## parse the limit_cgi string and put it into a form suitable for <input>s
576
## parse the limit_cgi string and put it into a form suitable for <input>s
554
my @limit_inputs = $limit_cgi ? _input_cgi_parse($limit_cgi) : ();
577
my @limit_inputs = $limit_cgi ? _input_cgi_parse($limit_cgi) : ();
555
578
556
# add OPAC 'hidelostitems'
557
#if (C4::Context->preference('hidelostitems') == 1) {
558
#    # either lost ge 0 or no value in the lost register
559
#    $query ="($query) and ( (lost,st-numeric <= 0) or ( allrecords,AlwaysMatches='' not lost,AlwaysMatches='') )";
560
#}
561
#
562
# add OPAC suppression - requires at least one item indexed with Suppress
563
if (C4::Context->preference('OpacSuppression')) {
564
    # OPAC suppression by IP address
565
    if (C4::Context->preference('OpacSuppressionByIPRange')) {
566
        my $IPAddress = $ENV{'REMOTE_ADDR'};
567
        my $IPRange = C4::Context->preference('OpacSuppressionByIPRange');
568
        if ($IPAddress !~ /^$IPRange/)  {
569
            if ( $query_type eq 'pqf' ) {
570
                $query = '@not '.$query.' @attr 14=1 @attr 1=9011 1';
571
            } else {
572
                $query = "($query) not Suppress=1";
573
            }
574
        }
575
    }
576
    else {
577
        if ( $query_type eq 'pqf' ) {
578
            #$query = "($query) && -(suppress:1)"; #QP syntax
579
            $query = '@not '.$query.' @attr 14=1 @attr 1=9011 1'; #PQF syntax
580
        } else {
581
            $query = "($query) not Suppress=1";
582
        }
583
    }
584
}
585
586
$template->param ( LIMIT_INPUTS => \@limit_inputs );
579
$template->param ( LIMIT_INPUTS => \@limit_inputs );
587
$template->param ( OPACResultsSidebar => C4::Context->preference('OPACResultsSidebar'));
580
$template->param ( OPACResultsSidebar => C4::Context->preference('OPACResultsSidebar'));
588
581
589
- 

Return to bug 16660