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 531-538 my ($error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_ Link Here
531
531
532
my @results;
532
my @results;
533
533
534
my $suppress = 0;
535
if (C4::Context->preference('OpacSuppression')) {
536
    # OPAC suppression by IP address
537
    if (C4::Context->preference('OpacSuppressionByIPRange')) {
538
        my $IPAddress = $ENV{'REMOTE_ADDR'};
539
        my $IPRange = C4::Context->preference('OpacSuppressionByIPRange');
540
        $suppress = ($IPAddress !~ /^$IPRange/);
541
    }
542
    else {
543
        $suppress = 1;
544
    }
545
}
546
534
## I. BUILD THE QUERY
547
## I. BUILD THE QUERY
535
( $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 });
548
( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type)
549
  = $builder->build_query_compat(
550
    \@operators,
551
    \@operands,
552
    \@indexes,
553
    \@limits,
554
    \@sort_by,
555
    0,
556
    $lang,
557
    { expanded_facet => $expanded_facet, suppress => $suppress }
558
    );
536
559
537
sub _input_cgi_parse {
560
sub _input_cgi_parse {
538
    my @elements;
561
    my @elements;
Lines 552-587 $template->param ( QUERY_INPUTS => \@query_inputs ); Link Here
552
## parse the limit_cgi string and put it into a form suitable for <input>s
575
## parse the limit_cgi string and put it into a form suitable for <input>s
553
my @limit_inputs = $limit_cgi ? _input_cgi_parse($limit_cgi) : ();
576
my @limit_inputs = $limit_cgi ? _input_cgi_parse($limit_cgi) : ();
554
577
555
# add OPAC 'hidelostitems'
556
#if (C4::Context->preference('hidelostitems') == 1) {
557
#    # either lost ge 0 or no value in the lost register
558
#    $query ="($query) and ( (lost,st-numeric <= 0) or ( allrecords,AlwaysMatches='' not lost,AlwaysMatches='') )";
559
#}
560
#
561
# add OPAC suppression - requires at least one item indexed with Suppress
562
if (C4::Context->preference('OpacSuppression')) {
563
    # OPAC suppression by IP address
564
    if (C4::Context->preference('OpacSuppressionByIPRange')) {
565
        my $IPAddress = $ENV{'REMOTE_ADDR'};
566
        my $IPRange = C4::Context->preference('OpacSuppressionByIPRange');
567
        if ($IPAddress !~ /^$IPRange/)  {
568
            if ( $query_type eq 'pqf' ) {
569
                $query = '@not '.$query.' @attr 14=1 @attr 1=9011 1';
570
            } else {
571
                $query = "($query) not Suppress=1";
572
            }
573
        }
574
    }
575
    else {
576
        if ( $query_type eq 'pqf' ) {
577
            #$query = "($query) && -(suppress:1)"; #QP syntax
578
            $query = '@not '.$query.' @attr 14=1 @attr 1=9011 1'; #PQF syntax
579
        } else {
580
            $query = "($query) not Suppress=1";
581
        }
582
    }
583
}
584
585
$template->param ( LIMIT_INPUTS => \@limit_inputs );
578
$template->param ( LIMIT_INPUTS => \@limit_inputs );
586
$template->param ( OPACResultsSidebar => C4::Context->preference('OPACResultsSidebar'));
579
$template->param ( OPACResultsSidebar => C4::Context->preference('OPACResultsSidebar'));
587
580
588
- 

Return to bug 16660