Lines 82-99
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
Link Here
|
82 |
} |
82 |
} |
83 |
); |
83 |
); |
84 |
|
84 |
|
85 |
my @all_items = GetItemsInfo($biblionumber); |
|
|
86 |
if( $specific_item ) { |
87 |
@all_items = grep { $_->{itemnumber} == $query->param('itemnumber') } @all_items; |
88 |
$template->param( specific_item => 1 ); |
89 |
} |
90 |
my @hiddenitems; |
91 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
92 |
our $borcat= q{}; |
93 |
if ( C4::Context->preference('OpacHiddenItemsExceptions') ) { |
94 |
$borcat = $patron ? $patron->categorycode : q{}; |
95 |
} |
96 |
|
97 |
my $record = GetMarcBiblio({ |
85 |
my $record = GetMarcBiblio({ |
98 |
biblionumber => $biblionumber, |
86 |
biblionumber => $biblionumber, |
99 |
opac => 1 }); |
87 |
opac => 1 }); |
Lines 102-117
if ( ! $record ) {
Link Here
|
102 |
exit; |
90 |
exit; |
103 |
} |
91 |
} |
104 |
|
92 |
|
105 |
if ( scalar @all_items >= 1 ) { |
93 |
our $logged_in_patron = Koha::Patrons->find( $borrowernumber ); |
106 |
push @hiddenitems, |
|
|
107 |
GetHiddenItemnumbers( { items => \@all_items, borcat => $borcat } ); |
108 |
|
109 |
if (scalar @hiddenitems == scalar @all_items ) { |
110 |
print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early |
111 |
exit; |
112 |
} |
113 |
} |
114 |
|
115 |
my $biblio = Koha::Biblios->find( $biblionumber ); |
94 |
my $biblio = Koha::Biblios->find( $biblionumber ); |
116 |
my $framework = $biblio ? $biblio->frameworkcode : q{}; |
95 |
my $framework = $biblio ? $biblio->frameworkcode : q{}; |
117 |
my $record_processor = Koha::RecordProcessor->new({ |
96 |
my $record_processor = Koha::RecordProcessor->new({ |
Lines 280-286
if ($session->param('busc')) {
Link Here
|
280 |
my @newresults; |
259 |
my @newresults; |
281 |
my $search_context = { |
260 |
my $search_context = { |
282 |
'interface' => 'opac', |
261 |
'interface' => 'opac', |
283 |
'category' => $borcat |
262 |
'category' => $logged_in_patron ? $logged_in_patron->categorycode : undef, |
284 |
}; |
263 |
}; |
285 |
for (my $i=0;$i<@servers;$i++) { |
264 |
for (my $i=0;$i<@servers;$i++) { |
286 |
my $server = $servers[$i]; |
265 |
my $server = $servers[$i]; |
Lines 507-512
if ($session->param('busc')) {
Link Here
|
507 |
for (my $j = 0; $j < @arrBiblios; $j++) { |
486 |
for (my $j = 0; $j < @arrBiblios; $j++) { |
508 |
next unless ($arrBiblios[$j]); |
487 |
next unless ($arrBiblios[$j]); |
509 |
$dataBiblioPaging = Koha::Biblios->find( $arrBiblios[$j] ) if ($arrBiblios[$j] != $biblionumber); |
488 |
$dataBiblioPaging = Koha::Biblios->find( $arrBiblios[$j] ) if ($arrBiblios[$j] != $biblionumber); |
|
|
489 |
next unless $dataBiblioPaging; |
510 |
push @listResults, {index => $j + 1 + $offset, biblionumber => $arrBiblios[$j], title => ($arrBiblios[$j] == $biblionumber)?'':$dataBiblioPaging->title, author => ($arrBiblios[$j] != $biblionumber && $dataBiblioPaging->author)?$dataBiblioPaging->author:'', url => ($arrBiblios[$j] == $biblionumber)?'':'opac-detail.pl?biblionumber=' . $arrBiblios[$j]}; |
490 |
push @listResults, {index => $j + 1 + $offset, biblionumber => $arrBiblios[$j], title => ($arrBiblios[$j] == $biblionumber)?'':$dataBiblioPaging->title, author => ($arrBiblios[$j] != $biblionumber && $dataBiblioPaging->author)?$dataBiblioPaging->author:'', url => ($arrBiblios[$j] == $biblionumber)?'':'opac-detail.pl?biblionumber=' . $arrBiblios[$j]}; |
511 |
} |
491 |
} |
512 |
$template->param('listResults' => \@listResults) if (@listResults); |
492 |
$template->param('listResults' => \@listResults) if (@listResults); |
Lines 519-524
$template->param(
Link Here
|
519 |
OPACShowCheckoutName => C4::Context->preference("OPACShowCheckoutName"), |
499 |
OPACShowCheckoutName => C4::Context->preference("OPACShowCheckoutName"), |
520 |
); |
500 |
); |
521 |
|
501 |
|
|
|
502 |
my @all_items = GetItemsInfo($biblionumber); |
503 |
if( $specific_item ) { |
504 |
@all_items = grep { $_->{itemnumber} == $query->param('itemnumber') } @all_items; |
505 |
$template->param( specific_item => 1 ); |
506 |
} |
507 |
|
522 |
if ( C4::Context->preference('EasyAnalyticalRecords') ) { |
508 |
if ( C4::Context->preference('EasyAnalyticalRecords') ) { |
523 |
# adding items linked via host biblios |
509 |
# adding items linked via host biblios |
524 |
my $analyticfield = '773'; |
510 |
my $analyticfield = '773'; |
Lines 539-562
if ( C4::Context->preference('EasyAnalyticalRecords') ) {
Link Here
|
539 |
} |
525 |
} |
540 |
} |
526 |
} |
541 |
|
527 |
|
542 |
my @items; |
528 |
my @filtered_items; |
543 |
|
529 |
if ( @all_items ) { |
544 |
# Are there items to hide? |
530 |
@filtered_items = filter_items( { items => \@all_items, patron => $logged_in_patron, } ); |
545 |
my $hideitems; |
|
|
546 |
$hideitems = 1 if C4::Context->preference('hidelostitems') or scalar(@hiddenitems) > 0; |
547 |
|
531 |
|
548 |
# Hide items |
532 |
unless ( @filtered_items ) { |
549 |
if ($hideitems) { |
533 |
print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early |
550 |
for my $itm (@all_items) { |
534 |
exit; |
551 |
if ( C4::Context->preference('hidelostitems') ) { |
|
|
552 |
push @items, $itm unless $itm->{itemlost} or any { $itm->{'itemnumber'} eq $_ } @hiddenitems; |
553 |
} else { |
554 |
push @items, $itm unless any { $itm->{'itemnumber'} eq $_ } @hiddenitems; |
555 |
} |
535 |
} |
556 |
} |
536 |
} |
557 |
} else { |
537 |
|
|
|
538 |
sub filter_items { |
539 |
my ( $params ) = @_; |
540 |
my @all_items = @{$params->{items}}; |
541 |
my $patron = $params->{patron}; |
542 |
my @hiddenitems; |
543 |
my $patron_category = |
544 |
( C4::Context->preference('OpacHiddenItemsExceptions') && $patron ) |
545 |
? $patron->categorycode |
546 |
: undef; |
547 |
|
548 |
if ( scalar @all_items >= 1 ) { |
549 |
push @hiddenitems, |
550 |
GetHiddenItemnumbers( { items => \@all_items, borcat => $patron_category } ); |
551 |
|
552 |
return () if scalar @hiddenitems == scalar @all_items; |
553 |
} |
554 |
|
555 |
my @items; |
556 |
# Are there items to hide? |
557 |
my $hideitems; |
558 |
|
559 |
# Hide items |
560 |
if ( C4::Context->preference('hidelostitems') || @hiddenitems ) { |
561 |
for my $itm (@all_items) { |
562 |
if ( C4::Context->preference('hidelostitems') ) { |
563 |
push @items, $itm |
564 |
unless $itm->{itemlost} |
565 |
or any { $itm->{'itemnumber'} eq $_ } @hiddenitems; |
566 |
} |
567 |
else { |
568 |
push @items, $itm |
569 |
unless any { $itm->{'itemnumber'} eq $_ } @hiddenitems; |
570 |
} |
571 |
} |
572 |
} |
558 |
# Or not |
573 |
# Or not |
559 |
@items = @all_items; |
574 |
else { |
|
|
575 |
@items = @all_items; |
576 |
} |
577 |
return @items; |
560 |
} |
578 |
} |
561 |
|
579 |
|
562 |
my $branch = ''; |
580 |
my $branch = ''; |
Lines 580-586
if ( C4::Context->preference('HighlightOwnItemsOnOPAC') ) {
Link Here
|
580 |
my @our_items; |
598 |
my @our_items; |
581 |
my @other_items; |
599 |
my @other_items; |
582 |
|
600 |
|
583 |
foreach my $item ( @items ) { |
601 |
foreach my $item ( @filtered_items ) { |
584 |
if ( $item->{branchcode} eq $branchcode ) { |
602 |
if ( $item->{branchcode} eq $branchcode ) { |
585 |
$item->{'this_branch'} = 1; |
603 |
$item->{'this_branch'} = 1; |
586 |
push( @our_items, $item ); |
604 |
push( @our_items, $item ); |
Lines 589-595
if ( C4::Context->preference('HighlightOwnItemsOnOPAC') ) {
Link Here
|
589 |
} |
607 |
} |
590 |
} |
608 |
} |
591 |
|
609 |
|
592 |
@items = ( @our_items, @other_items ); |
610 |
@filtered_items= ( @our_items, @other_items ); |
593 |
} |
611 |
} |
594 |
} |
612 |
} |
595 |
|
613 |
|
Lines 650-656
foreach my $subscription (@subscriptions) {
Link Here
|
650 |
push @subs, \%cell; |
668 |
push @subs, \%cell; |
651 |
} |
669 |
} |
652 |
|
670 |
|
653 |
$dat->{'count'} = scalar(@items); |
671 |
$dat->{'count'} = scalar(@filtered_items); |
654 |
|
672 |
|
655 |
|
673 |
|
656 |
my (%item_reserves, %priority); |
674 |
my (%item_reserves, %priority); |
Lines 709-721
if ( C4::Context->preference('OPACAcquisitionDetails' ) ) {
Link Here
|
709 |
|
727 |
|
710 |
my $allow_onshelf_holds; |
728 |
my $allow_onshelf_holds; |
711 |
my ( $itemloop_has_images, $otheritemloop_has_images ); |
729 |
my ( $itemloop_has_images, $otheritemloop_has_images ); |
712 |
if ( not $viewallitems and @items > $max_items_to_display ) { |
730 |
if ( not $viewallitems and @filtered_items > $max_items_to_display ) { |
713 |
$template->param( |
731 |
$template->param( |
714 |
too_many_items => 1, |
732 |
too_many_items => 1, |
715 |
items_count => scalar( @items ), |
733 |
items_count => scalar( @filtered_items ), |
716 |
); |
734 |
); |
717 |
} else { |
735 |
} else { |
718 |
for my $itm (@items) { |
736 |
for my $itm (@filtered_items) { |
719 |
my $item = Koha::Items->find( $itm->{itemnumber} ); |
737 |
my $item = Koha::Items->find( $itm->{itemnumber} ); |
720 |
$itm->{holds_count} = $item_reserves{ $itm->{itemnumber} }; |
738 |
$itm->{holds_count} = $item_reserves{ $itm->{itemnumber} }; |
721 |
$itm->{priority} = $priority{ $itm->{itemnumber} }; |
739 |
$itm->{priority} = $priority{ $itm->{itemnumber} }; |
Lines 727-733
if ( not $viewallitems and @items > $max_items_to_display ) {
Link Here
|
727 |
&& !$itemtypes->{$itm->{'itype'}}->{notforloan} |
745 |
&& !$itemtypes->{$itm->{'itype'}}->{notforloan} |
728 |
&& $itm->{'itemnumber'}; |
746 |
&& $itm->{'itemnumber'}; |
729 |
|
747 |
|
730 |
$allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } ) |
748 |
$allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $logged_in_patron } ) |
731 |
unless $allow_onshelf_holds; |
749 |
unless $allow_onshelf_holds; |
732 |
|
750 |
|
733 |
# get collection code description, too |
751 |
# get collection code description, too |
Lines 843-849
if( C4::Context->preference('ArticleRequests') ) {
Link Here
|
843 |
OpacStarRatings => C4::Context->preference("OpacStarRatings"), |
861 |
OpacStarRatings => C4::Context->preference("OpacStarRatings"), |
844 |
); |
862 |
); |
845 |
|
863 |
|
846 |
if (C4::Context->preference("AlternateHoldingsField") && scalar @items == 0) { |
864 |
if (C4::Context->preference("AlternateHoldingsField") && scalar @filtered_items == 0) { |
847 |
my $fieldspec = C4::Context->preference("AlternateHoldingsField"); |
865 |
my $fieldspec = C4::Context->preference("AlternateHoldingsField"); |
848 |
my $subfields = substr $fieldspec, 3; |
866 |
my $subfields = substr $fieldspec, 3; |
849 |
my $holdingsep = C4::Context->preference("AlternateHoldingsSeparator") || ' '; |
867 |
my $holdingsep = C4::Context->preference("AlternateHoldingsSeparator") || ' '; |
Lines 1257-1263
if (C4::Context->preference('OpacHighlightedWords')) {
Link Here
|
1257 |
$template->{VARS}->{'trackclicks'} = C4::Context->preference('TrackClicks'); |
1275 |
$template->{VARS}->{'trackclicks'} = C4::Context->preference('TrackClicks'); |
1258 |
|
1276 |
|
1259 |
if ( C4::Context->preference('UseCourseReserves') ) { |
1277 |
if ( C4::Context->preference('UseCourseReserves') ) { |
1260 |
foreach my $i ( @items ) { |
1278 |
foreach my $i ( @filtered_items ) { |
1261 |
$i->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $i->{'itemnumber'} ); |
1279 |
$i->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $i->{'itemnumber'} ); |
1262 |
} |
1280 |
} |
1263 |
} |
1281 |
} |
1264 |
- |
|
|