Bug 8761 Dont inadvertantly use slices
[koha.git] / opac / opac-search.pl
index 1e5a0d7..216de2f 100755 (executable)
@@ -369,6 +369,8 @@ if ($indexes[0] && !$indexes[1]) {
 my @operands;
 @operands = split("\0",$params->{'q'}) if $params->{'q'};
 
+$template->{VARS}->{querystring} = join(' ', @operands);
+
 # if a simple search, display the value in the search box
 if ($operands[0] && !$operands[1]) {
     $template->param(ms_value => $operands[0]);
@@ -449,7 +451,17 @@ my @limit_inputs = $limit_cgi ? _input_cgi_parse($limit_cgi) : ();
 #
 # add OPAC suppression - requires at least one item indexed with Suppress
 if (C4::Context->preference('OpacSuppression')) {
-    $query = "($query) not Suppress=1";
+    # OPAC suppression by IP address
+    if (C4::Context->preference('OpacSuppressionByIPRange')) {
+        my $IPAddress = $ENV{'REMOTE_ADDR'};
+        my $IPRange = C4::Context->preference('OpacSuppressionByIPRange');
+        if ($IPAddress !~ /^$IPRange/)  {
+            $query = "($query) not Suppress=1";
+        }
+    }
+    else {
+        $query = "($query) not Suppress=1";
+    }
 }
 
 $template->param ( LIMIT_INPUTS => \@limit_inputs );
@@ -609,7 +621,7 @@ for (my $i=0;$i<@servers;$i++) {
 
             if (!$borrowernumber || $borrowernumber eq '') {
                 # To a cookie (the user is not logged in)
-                if (($params->{'offset'}||'') eq '') {
+                if (!$offset) {
                     push @recentSearches, {
                                 "query_desc" => $query_desc_history || "unknown",
                                 "query_cgi"  => $query_cgi_history  || "unknown",
@@ -631,7 +643,7 @@ for (my $i=0;$i<@servers;$i++) {
             }
             else {
                 # To the session (the user is logged in)
-                if (($params->{'offset'}||'') eq '') {
+                if (!$offset) {
                     AddSearchHistory($borrowernumber, $cgi->cookie("CGISESSID"), $query_desc_history, $query_cgi_history, $total);
                     $template->param(ShowOpacRecentSearchLink => 1);
                 }
@@ -816,5 +828,7 @@ if (C4::Context->preference('GoogleIndicTransliteration')) {
         $template->param('GoogleIndicTransliteration' => 1);
 }
 
+$template->{VARS}->{DidYouMeanFromAuthorities} = C4::Context->preference('DidYouMeanFromAuthorities');
+
     $template->param( borrowernumber    => $borrowernumber);
 output_with_http_headers $cgi, $cookie, $template->output, $content_type;