Bug 10862: (follow-up) make sure that queries that return only one result get recorded
authorJonathan Druart <jonathan.druart@biblibre.com>
Thu, 12 Sep 2013 09:52:43 +0000 (11:52 +0200)
committerGalen Charlton <gmc@esilibrary.com>
Mon, 5 May 2014 03:07:46 +0000 (03:07 +0000)
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
catalogue/search.pl
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/search-history.tt

index c449299..29f5c83 100755 (executable)
@@ -546,6 +546,30 @@ for (my $i=0;$i<@servers;$i++) {
         my @newresults = searchResults('intranet', $query_desc, $hits, $results_per_page, $offset, $scan,
                                        $results_hashref->{$server}->{"RECORDS"});
         $total = $total + $results_hashref->{$server}->{"hits"};
+
+        # Search history
+        if (C4::Context->preference('EnableSearchHistory')) {
+            unless ( $offset ) {
+                my $path_info = $cgi->url(-path_info=>1);
+                my $query_cgi_history = $cgi->url(-query=>1);
+                $query_cgi_history =~ s/^$path_info\?//;
+                $query_cgi_history =~ s/;/&/g;
+                my $query_desc_history = $query_desc;
+                $query_desc_history .= ", $limit_desc"
+                    if $limit_desc;
+
+                C4::Search::History::add({
+                    userid => $borrowernumber,
+                    sessionid => $cgi->cookie("CGISESSID"),
+                    query_desc => $query_desc_history,
+                    query_cgi => $query_cgi_history,
+                    total => $total,
+                    type => "biblio",
+                });
+            }
+            $template->param( EnableSearchHistory => 1 );
+        }
+
         ## If there's just one result, redirect to the detail page
         if ($total == 1) {         
             my $biblionumber = $newresults[0]->{biblionumber};
@@ -654,29 +678,6 @@ for (my $i=0;$i<@servers;$i++) {
             $template->param(searchdesc => 1,query_desc => $query_desc,limit_desc => $limit_desc);
         }
 
-        # Search history
-        if (C4::Context->preference('EnableSearchHistory')) {
-            unless ( $offset ) {
-                my $path_info = $cgi->url(-path_info=>1);
-                my $query_cgi_history = $cgi->url(-query=>1);
-                $query_cgi_history =~ s/^$path_info\?//;
-                $query_cgi_history =~ s/;/&/g;
-                my $query_desc_history = $query_desc;
-                $query_desc_history .= ", $limit_desc"
-                    if $limit_desc;
-
-                C4::Search::History::add({
-                    userid => $borrowernumber,
-                    sessionid => $cgi->cookie("CGISESSID"),
-                    query_desc => $query_desc_history,
-                    query_cgi => $query_cgi_history,
-                    total => $total,
-                    type => "biblio",
-                });
-            }
-            $template->param( EnableSearchHistory => 1 );
-        }
-
     } # end of the if local
 
     # asynchronously search the authority server
index ae48c1b..1c3c800 100644 (file)
@@ -1,3 +1,4 @@
+[% INCLUDE 'doc-head-open.inc' %]
 [% USE Koha %]
 [% USE KohaDates %]
 <title>Koha &rsaquo; Catalog &rsaquo; Search history</title>