Bug 10798: make OPAC_SEARCH_LIMIT behaves better with search groups
[koha_fer] / C4 / Search.pm
index 3ca722c..748bb1c 100644 (file)
@@ -68,7 +68,6 @@ This module provides searching functions for Koha's bibliographic databases
   &searchResults
   &getRecords
   &buildQuery
-  &AddSearchHistory
   &GetDistinctValues
   &enabled_staff_search_views
   &PurgeSearchHistory
@@ -457,7 +456,7 @@ sub getRecords {
 
                     ## Check if it's an index scan
                     if ($scan) {
-                        my ( $term, $occ ) = $results[ $i - 1 ]->term($j);
+                        my ( $term, $occ ) = $results[ $i - 1 ]->display_term($j);
 
                  # here we create a minimal MARC record and hand it off to the
                  # template just like a normal result ... perhaps not ideal, but
@@ -859,6 +858,7 @@ sub _build_weighted_query {
           "Title-cover,ext,r1=\"$operand\"";    # exact title-cover
         $weighted_query .= " or ti,ext,r2=\"$operand\"";    # exact title
         $weighted_query .= " or Title-cover,phr,r3=\"$operand\"";    # phrase title
+        $weighted_query .= " or ti,wrdl,r4=\"$operand\"";    # words in title
           #$weighted_query .= " or any,ext,r4=$operand";               # exact any
           #$weighted_query .=" or kw,wrdl,r5=\"$operand\"";            # word list any
         $weighted_query .= " or wrdl,fuzzy,r8=\"$operand\""
@@ -961,6 +961,7 @@ sub getIndexes{
                     'Corporate-name-seealso',
                     'Country-publication',
                     'ctype',
+                    'curriculum',
                     'date-entered-on-file',
                     'Date-of-acquisition',
                     'Date-of-publication',
@@ -981,6 +982,8 @@ sub getIndexes{
                     'Host-item',
                     'id-other',
                     'Illustration-code',
+                    'Index-term-genre',
+                    'Index-term-uncontrolled',
                     'ISBN',
                     'isbn',
                     'ISSN',
@@ -994,8 +997,11 @@ sub getIndexes{
                     'lc-card',
                     'LC-card-number',
                     'lcn',
+                    'lex',
                     'llength',
                     'ln',
+                    'ln-audio',
+                    'ln-subtitle',
                     'Local-classification',
                     'Local-number',
                     'Match-heading',
@@ -1551,7 +1557,7 @@ sub buildQuery {
             $group_OR_limits{$k} .= " or " if $group_OR_limits{$k};
             $limit_desc      .= " or " if $group_OR_limits{$k};
             $group_OR_limits{$k} .= "$this_limit";
-            $limit_cgi       .= "&limit=$this_limit";
+            $limit_cgi       .= "&limit=" . uri_escape($this_limit);
             $limit_desc      .= " $this_limit";
         }
 
@@ -1559,7 +1565,7 @@ sub buildQuery {
         else {
             $limit .= " and " if $limit || $query;
             $limit      .= "$this_limit";
-            $limit_cgi  .= "&limit=$this_limit";
+            $limit_cgi  .= "&limit=" . uri_escape($this_limit);
             if ($this_limit =~ /^branch:(.+)/) {
                 my $branchcode = $1;
                 my $branchname = GetBranchName($branchcode);
@@ -2216,28 +2222,6 @@ sub enabled_staff_search_views
        );
 }
 
-sub AddSearchHistory{
-       my ($borrowernumber,$session,$query_desc,$query_cgi, $total)=@_;
-    my $dbh = C4::Context->dbh;
-
-    # Add the request the user just made
-    my $sql = "INSERT INTO search_history(userid, sessionid, query_desc, query_cgi, total, time) VALUES(?, ?, ?, ?, ?, NOW())";
-    my $sth   = $dbh->prepare($sql);
-    $sth->execute($borrowernumber, $session, $query_desc, $query_cgi, $total);
-       return $dbh->last_insert_id(undef, 'search_history', undef,undef,undef);
-}
-
-sub GetSearchHistory{
-       my ($borrowernumber,$session)=@_;
-    my $dbh = C4::Context->dbh;
-
-    # Add the request the user just made
-    my $query = "SELECT FROM search_history WHERE (userid=? OR sessionid=?)";
-    my $sth   = $dbh->prepare($query);
-       $sth->execute($borrowernumber, $session);
-    return  $sth->fetchall_hashref({});
-}
-
 sub PurgeSearchHistory{
     my ($pSearchhistory)=@_;
     my $dbh = C4::Context->dbh;