View | Details | Raw Unified | Return to bug 6488
Collapse All | Expand All

(-)a/C4/Items.pm (-4 / +3 lines)
Lines 1531-1536 sub GetHiddenItemnumbers { Link Here
1531
    my @resultitems;
1531
    my @resultitems;
1532
1532
1533
    my $yaml = C4::Context->preference('OpacHiddenItems');
1533
    my $yaml = C4::Context->preference('OpacHiddenItems');
1534
    $yaml = "$yaml\n"; # YAML is anal on ending \n. Surplus does not hurt
1534
    my $hidingrules;
1535
    my $hidingrules;
1535
    eval {
1536
    eval {
1536
    	$hidingrules = YAML::Load($yaml);
1537
    	$hidingrules = YAML::Load($yaml);
Lines 1538-1544 sub GetHiddenItemnumbers { Link Here
1538
    if ($@) {
1539
    if ($@) {
1539
    	warn "Unable to parse OpacHiddenItems syspref : $@";
1540
    	warn "Unable to parse OpacHiddenItems syspref : $@";
1540
    	return ();
1541
    	return ();
1541
    } else {
1542
    }
1542
    my $dbh = C4::Context->dbh;
1543
    my $dbh = C4::Context->dbh;
1543
1544
1544
	# For each item
1545
	# For each item
Lines 1563-1571 sub GetHiddenItemnumbers { Link Here
1563
	    }
1564
	    }
1564
	}
1565
	}
1565
	return @resultitems;
1566
	return @resultitems;
1566
    }
1567
}
1567
1568
 }
1569
1568
1570
=head3 get_item_authorised_values
1569
=head3 get_item_authorised_values
1571
1570
(-)a/C4/Search.pm (-11 / +20 lines)
Lines 1413-1423 Format results in a form suitable for passing to the template Link Here
1413
# IMO this subroutine is pretty messy still -- it's responsible for
1413
# IMO this subroutine is pretty messy still -- it's responsible for
1414
# building the HTML output for the template
1414
# building the HTML output for the template
1415
sub searchResults {
1415
sub searchResults {
1416
    my ( $search_context, $searchdesc, $hits, $results_per_page, $offset, $scan, @marcresults, $hidelostitems ) = @_;
1416
    my ( $search_context, $searchdesc, $hits, $results_per_page, $offset, $scan, $marcresults ) = @_;
1417
    my $dbh = C4::Context->dbh;
1417
    my $dbh = C4::Context->dbh;
1418
    my @newresults;
1418
    my @newresults;
1419
1419
1420
    $search_context = 'opac' unless $search_context eq 'opac' or $search_context eq 'intranet';
1420
    $search_context = 'opac' if !$search_context || $search_context ne 'intranet';
1421
    my ($is_opac, $hidelostitems);
1422
    if ($search_context eq 'opac') {
1423
        $hidelostitems = C4::Context->preference('hidelostitems');
1424
        $is_opac       = 1;
1425
    }
1421
1426
1422
    #Build branchnames hash
1427
    #Build branchnames hash
1423
    #find branchname
1428
    #find branchname
Lines 1484-1490 sub searchResults { Link Here
1484
1489
1485
    # loop through all of the records we've retrieved
1490
    # loop through all of the records we've retrieved
1486
    for ( my $i = $offset ; $i <= $times - 1 ; $i++ ) {
1491
    for ( my $i = $offset ; $i <= $times - 1 ; $i++ ) {
1487
        my $marcrecord = MARC::File::USMARC::decode( $marcresults[$i] );
1492
        my $marcrecord = MARC::File::USMARC::decode( $marcresults->[$i] );
1488
        $fw = $scan
1493
        $fw = $scan
1489
             ? undef
1494
             ? undef
1490
             : $bibliotag < 10
1495
             : $bibliotag < 10
Lines 1576-1586 sub searchResults { Link Here
1576
        my $other_count           = 0;
1581
        my $other_count           = 0;
1577
        my $wthdrawn_count        = 0;
1582
        my $wthdrawn_count        = 0;
1578
        my $itemlost_count        = 0;
1583
        my $itemlost_count        = 0;
1584
        my $hideatopac_count      = 0;
1579
        my $itembinding_count     = 0;
1585
        my $itembinding_count     = 0;
1580
        my $itemdamaged_count     = 0;
1586
        my $itemdamaged_count     = 0;
1581
        my $item_in_transit_count = 0;
1587
        my $item_in_transit_count = 0;
1582
        my $can_place_holds       = 0;
1588
        my $can_place_holds       = 0;
1583
	my $item_onhold_count     = 0;
1589
        my $item_onhold_count     = 0;
1584
        my $items_count           = scalar(@fields);
1590
        my $items_count           = scalar(@fields);
1585
        my $maxitems =
1591
        my $maxitems =
1586
          ( C4::Context->preference('maxItemsinSearchResults') )
1592
          ( C4::Context->preference('maxItemsinSearchResults') )
Lines 1597-1605 sub searchResults { Link Here
1597
            }
1603
            }
1598
1604
1599
	        # Hidden items
1605
	        # Hidden items
1600
	        my @items = ($item);
1606
            if ($is_opac) {
1601
	        my (@hiddenitems) = GetHiddenItemnumbers(@items);
1607
	            my @hiddenitems = GetHiddenItemnumbers($item);
1602
    	    $item->{'hideatopac'} = 1 if (@hiddenitems); 
1608
    	        $item->{'hideatopac'} = @hiddenitems; 
1609
            }
1603
1610
1604
            my $hbranch     = C4::Context->preference('HomeOrHoldingBranch') eq 'homebranch' ? 'homebranch'    : 'holdingbranch';
1611
            my $hbranch     = C4::Context->preference('HomeOrHoldingBranch') eq 'homebranch' ? 'homebranch'    : 'holdingbranch';
1605
            my $otherbranch = C4::Context->preference('HomeOrHoldingBranch') eq 'homebranch' ? 'holdingbranch' : 'homebranch';
1612
            my $otherbranch = C4::Context->preference('HomeOrHoldingBranch') eq 'homebranch' ? 'holdingbranch' : 'homebranch';
Lines 1683-1688 sub searchResults { Link Here
1683
                    $wthdrawn_count++        if $item->{wthdrawn};
1690
                    $wthdrawn_count++        if $item->{wthdrawn};
1684
                    $itemlost_count++        if $item->{itemlost};
1691
                    $itemlost_count++        if $item->{itemlost};
1685
                    $itemdamaged_count++     if $item->{damaged};
1692
                    $itemdamaged_count++     if $item->{damaged};
1693
                    $hideatopac_count++      if $item->{hideatopac};
1686
                    $item_in_transit_count++ if $transfertwhen ne '';
1694
                    $item_in_transit_count++ if $transfertwhen ne '';
1687
		    $item_onhold_count++     if $reservestatus eq 'Waiting';
1695
		    $item_onhold_count++     if $reservestatus eq 'Waiting';
1688
                    $item->{status} = $item->{wthdrawn} . "-" . $item->{itemlost} . "-" . $item->{damaged} . "-" . $item->{notforloan};
1696
                    $item->{status} = $item->{wthdrawn} . "-" . $item->{itemlost} . "-" . $item->{damaged} . "-" . $item->{notforloan};
Lines 1721-1726 sub searchResults { Link Here
1721
                }
1729
                }
1722
            }
1730
            }
1723
        }    # notforloan, item level and biblioitem level
1731
        }    # notforloan, item level and biblioitem level
1732
1733
        next if $is_opac       && $hideatopac_count >= $items_count;
1734
        next if $hidelostitems && $itemlost_count   >= $items_count;
1735
1724
        my ( $availableitemscount, $onloanitemscount, $otheritemscount );
1736
        my ( $availableitemscount, $onloanitemscount, $otheritemscount );
1725
        $maxitems =
1737
        $maxitems =
1726
          ( C4::Context->preference('maxItemsinSearchResults') )
1738
          ( C4::Context->preference('maxItemsinSearchResults') )
Lines 1807-1816 sub searchResults { Link Here
1807
            $oldbiblio->{'alternateholdings_count'} = $alternateholdingscount;
1819
            $oldbiblio->{'alternateholdings_count'} = $alternateholdingscount;
1808
        }
1820
        }
1809
1821
1810
        push( @newresults, $oldbiblio )
1822
        push( @newresults, $oldbiblio );
1811
            if(not $hidelostitems
1812
               or (($items_count > $itemlost_count )
1813
                    && $hidelostitems));
1814
    }
1823
    }
1815
1824
1816
    return @newresults;
1825
    return @newresults;
(-)a/catalogue/search.pl (-1 / +1 lines)
Lines 547-553 for (my $i=0;$i<@servers;$i++) { Link Here
547
        $hits = $results_hashref->{$server}->{"hits"};
547
        $hits = $results_hashref->{$server}->{"hits"};
548
        my $page = $cgi->param('page') || 0;
548
        my $page = $cgi->param('page') || 0;
549
        my @newresults = searchResults('intranet', $query_desc, $hits, $results_per_page, $offset, $scan,
549
        my @newresults = searchResults('intranet', $query_desc, $hits, $results_per_page, $offset, $scan,
550
                                       @{$results_hashref->{$server}->{"RECORDS"}});
550
                                       $results_hashref->{$server}->{"RECORDS"});
551
        $total = $total + $results_hashref->{$server}->{"hits"};
551
        $total = $total + $results_hashref->{$server}->{"hits"};
552
        ## If there's just one result, redirect to the detail page
552
        ## If there's just one result, redirect to the detail page
553
        if ($total == 1) {         
553
        if ($total == 1) {         
(-)a/cataloguing/addbooks.pl (-1 / +1 lines)
Lines 86-92 if ($query) { Link Here
86
    # format output
86
    # format output
87
    # SimpleSearch() give the results per page we want, so 0 offet here
87
    # SimpleSearch() give the results per page we want, so 0 offet here
88
    my $total = @{$marcresults};
88
    my $total = @{$marcresults};
89
    my @newresults = searchResults( 'intranet', $query, $total, $results_per_page, 0, 0, @{$marcresults} );
89
    my @newresults = searchResults( 'intranet', $query, $total, $results_per_page, 0, 0, $marcresults );
90
    $template->param(
90
    $template->param(
91
        total          => $total_hits,
91
        total          => $total_hits,
92
        query          => $query,
92
        query          => $query,
(-)a/opac/opac-search.pl (-3 / +2 lines)
Lines 468-479 for (my $i=0;$i<@servers;$i++) { Link Here
468
                # we want as specified by $offset and $results_per_page,
468
                # we want as specified by $offset and $results_per_page,
469
                # we need to set the offset parameter of searchResults to 0
469
                # we need to set the offset parameter of searchResults to 0
470
                my @group_results = searchResults( 'opac', $query_desc, $group->{'group_count'},$results_per_page, 0, $scan,
470
                my @group_results = searchResults( 'opac', $query_desc, $group->{'group_count'},$results_per_page, 0, $scan,
471
                                                   @{ $group->{"RECORDS"} }, C4::Context->preference('hidelostitems'));
471
                                                   $group->{"RECORDS"});
472
                push @newresults, { group_label => $group->{'group_label'}, GROUP_RESULTS => \@group_results };
472
                push @newresults, { group_label => $group->{'group_label'}, GROUP_RESULTS => \@group_results };
473
            }
473
            }
474
        } else {
474
        } else {
475
            @newresults = searchResults('opac', $query_desc, $hits, $results_per_page, $offset, $scan,
475
            @newresults = searchResults('opac', $query_desc, $hits, $results_per_page, $offset, $scan,
476
                                        @{$results_hashref->{$server}->{"RECORDS"}},, C4::Context->preference('hidelostitems'));
476
                                        $results_hashref->{$server}->{"RECORDS"});
477
        }
477
        }
478
		my $tag_quantity;
478
		my $tag_quantity;
479
		if (C4::Context->preference('TagsEnabled') and
479
		if (C4::Context->preference('TagsEnabled') and
480
- 

Return to bug 6488