MT 2298 : Fix hidelostitems
authorNahuel ANGELINETTI <nahuel.angelinetti@biblibre.com>
Tue, 10 Nov 2009 12:18:43 +0000 (13:18 +0100)
committerHenri-Damien LAURENT <henridamien.laurent@biblibre.com>
Thu, 12 Nov 2009 15:36:14 +0000 (16:36 +0100)
This patch fixes the opac search, and C4::Search to take care about hidelostitems for items, and not records.

C4/Search.pm
opac/opac-search.pl

index dce4e2d..59f0505 100644 (file)
@@ -1335,7 +1335,7 @@ Format results in a form suitable for passing to the template
 # IMO this subroutine is pretty messy still -- it's responsible for
 # building the HTML output for the template
 sub searchResults {
-    my ( $searchdesc, $hits, $results_per_page, $offset, $scan, @marcresults ) = @_;
+    my ( $searchdesc, $hits, $results_per_page, $offset, $scan, @marcresults, $hidelostitems ) = @_;
     my $dbh = C4::Context->dbh;
     my @newresults;
 
@@ -1525,6 +1525,7 @@ sub searchResults {
             foreach my $code ( keys %subfieldstosearch ) {
                 $item->{$code} = $field->subfield( $subfieldstosearch{$code} );
             }
+            
                        my $hbranch     = C4::Context->preference('HomeOrHoldingBranch') eq 'homebranch' ? 'homebranch'    : 'holdingbranch';
                        my $otherbranch = C4::Context->preference('HomeOrHoldingBranch') eq 'homebranch' ? 'holdingbranch' : 'homebranch';
             # set item's branch name, use HomeOrHoldingBranch syspref first, fall back to the other one
@@ -1699,8 +1700,13 @@ sub searchResults {
         $oldbiblio->{orderedcount}         = $ordered_count;
         $oldbiblio->{isbn} =~
           s/-//g;    # deleting - in isbn to enable amazon content
-        push( @newresults, $oldbiblio );
+        push( @newresults, $oldbiblio ) 
+            if(not $hidelostitems
+               or (($items_count > $itemlost_count ) 
+                    && $hidelostitems));
+        
     }
+    
     return @newresults;
 }
 
index 74f8fe5..558604a 100755 (executable)
@@ -412,11 +412,11 @@ for (my $i=0;$i<=@servers;$i++) {
                 # we want as specified by $offset and $results_per_page,
                 # we need to set the offset parameter of searchResults to 0
                 my @group_results = searchResults( $query_desc, $group->{'group_count'},$results_per_page, 0, $scan,
-                                                   @{ $group->{"RECORDS"} });
+                                                   @{ $group->{"RECORDS"} }, C4::Context->preference('hidelostitems'));
                 push @newresults, { group_label => $group->{'group_label'}, GROUP_RESULTS => \@group_results };
             }
         } else {
-            @newresults = searchResults( $query_desc,$hits,$results_per_page,$offset,$scan,@{$results_hashref->{$server}->{"RECORDS"}});
+            @newresults = searchResults( $query_desc,$hits,$results_per_page,$offset,$scan,@{$results_hashref->{$server}->{"RECORDS"}},, C4::Context->preference('hidelostitems'));
         }
                my $tag_quantity;
                if (C4::Context->preference('TagsEnabled') and