From 481ccf6872622e1d00ed92b82dd8abd6930b6931 Mon Sep 17 00:00:00 2001 From: Nahuel ANGELINETTI Date: Tue, 10 Nov 2009 13:18:43 +0100 Subject: [PATCH] MT 2298 : Fix hidelostitems This patch fixes the opac search, and C4::Search to take care about hidelostitems for items, and not records. --- C4/Search.pm | 10 ++++++++-- opac/opac-search.pl | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index dce4e2d76d..59f0505ec8 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -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; } diff --git a/opac/opac-search.pl b/opac/opac-search.pl index 74f8fe5ecf..558604a7e1 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -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 -- 2.39.5