Bug 32612: (QA follow-up) Add BINMODE method to C4::SIP::Trapper
[koha-ffzg.git] / C4 / Search.pm
index 35b6fbf..e6ad8b6 100644 (file)
@@ -21,6 +21,7 @@ use C4::Biblio qw( TransformMarcToKoha GetMarcFromKohaField GetFrameworkCode Get
 use C4::Koha qw( getFacets GetVariationsOfISBN GetNormalizedUPC GetNormalizedEAN GetNormalizedOCLCNumber GetNormalizedISBN getitemtypeimagelocation );
 use Koha::DateUtils;
 use Koha::Libraries;
+use Koha::SearchEngine::QueryBuilder;
 use Lingua::Stem;
 use XML::Simple;
 use C4::XSLT qw( XSLTParse4Display );
@@ -33,6 +34,7 @@ use Koha::Logger;
 use Koha::Patrons;
 use Koha::Recalls;
 use Koha::RecordProcessor;
+use Koha::SearchFilters;
 use URI::Escape;
 use Business::ISBN;
 use MARC::Record;
@@ -1299,12 +1301,15 @@ sub buildQuery {
             $limit .= "$this_limit";
             $limit_desc .= " $this_limit";
         } elsif ( $this_limit =~ '^search_filter:' ) {
+            # Here we will get the query as a string, append to the limits, and pass through buildQuery
+            # again to clean the terms and handle nested filters
             $limit_cgi  .= "&limit=" . uri_escape_utf8($this_limit);
             my ($filter_id) = ( $this_limit =~ /^search_filter:(.*)$/ );
             my $search_filter = Koha::SearchFilters->find( $filter_id );
             next unless $search_filter;
-            my $expanded = $search_filter->expand_filter;
-            my ( $error, undef, undef, undef, undef, $fixed_limit, undef, undef, undef ) = buildQuery ( undef, undef, undef, $expanded, undef, undef, $lang);
+            my ($expanded_lim, $query_lim) = $search_filter->expand_filter;
+            push @$expanded_lim, $query_lim;
+            my ( $error, undef, undef, undef, undef, $fixed_limit, undef, undef, undef ) = buildQuery ( undef, undef, undef, $expanded_lim, undef, undef, $lang);
             $limit .= " and " if $limit || $query;
             $limit .= "$fixed_limit";
             $limit_desc .= " $limit";
@@ -1538,7 +1543,6 @@ sub buildQuery {
     }
     Koha::Logger->get->debug("QUERY BEFORE LIMITS: >$query<");
 
-
     # Normalize the query and limit strings
     # This is flawed , means we can't search anything with : in it
     # if user wants to do ccl or cql, start the query with that
@@ -2018,7 +2022,6 @@ sub searchResults {
                     fix_amps       => 1,
                     hidden_items   => \@hiddenitems,
                     xslt_variables => $xslt_variables,
-                    interface => $search_context->{'interface'}
                 }
             );
         }