use MARC::Record;
use MARC::Field;
use List::MoreUtils qw/any none/;
-use C4::Images;
use Koha::DateUtils;
use C4::HTML5Media;
use C4::CourseReserves qw(GetItemCourseReservesInfo);
use Koha::Plugins;
use Koha::Ratings;
use Koha::Reviews;
+use Koha::SearchEngine::Search;
use Try::Tiny;
}
my @hiddenitems;
my $patron = Koha::Patrons->find( $borrowernumber );
-our $borcat= q{};
-if ( C4::Context->preference('OpacHiddenItemsExceptions') ) {
- $borcat = $patron ? $patron->categorycode : q{};
-}
my $record = GetMarcBiblio({
biblionumber => $biblionumber,
exit;
}
-if ( scalar @all_items >= 1 ) {
- push @hiddenitems,
- GetHiddenItemnumbers( { items => \@all_items, borcat => $borcat } );
-
- if (scalar @hiddenitems == scalar @all_items ) {
- print $query->redirect("/cgi-bin/koha/errors/404.pl"); # escape early
+my $biblio = Koha::Biblios->find( $biblionumber );
+unless ( $patron and $patron->category->override_hidden_items ) {
+ # only skip this check if there's a logged in user
+ # and its category overrides OpacHiddenItems
+ if ( $biblio->hidden_in_opac({ rules => C4::Context->yaml_preference('OpacHiddenItems') }) ) {
+ print $query->redirect('/cgi-bin/koha/errors/404.pl'); # escape early
exit;
}
+ if ( scalar @all_items >= 1 ) {
+ push @hiddenitems,
+ GetHiddenItemnumbers( { items => \@all_items, borcat => $patron ? $patron->categorycode : undef } );
+ }
}
-my $biblio = Koha::Biblios->find( $biblionumber );
my $framework = $biblio ? $biblio->frameworkcode : q{};
my $record_processor = Koha::RecordProcessor->new({
filters => 'ViewPolicy',
if ( $xslfile ) {
+ my $searcher = Koha::SearchEngine::Search->new(
+ { index => $Koha::SearchEngine::BIBLIOS_INDEX }
+ );
+ my $cleaned_title = $biblio->title;
+ $cleaned_title =~ tr|/||;
+ my $query =
+ ( C4::Context->preference('UseControlNumber') and $record->field('001') )
+ ? 'rcn:'. $record->field('001')->data . ' AND (bib-level:a OR bib-level:b)'
+ : "Host-item:$cleaned_title";
+ my ( $err, $result, $count ) = $searcher->simple_search_compat( $query, 0, 0 );
+
+ warn "Warning from simple_search_compat: $err"
+ if $err;
+
my $variables = {
- anonymous_session => ($borrowernumber) ? 0 : 1
+ anonymous_session => ($borrowernumber) ? 0 : 1,
+ show_analytics_link => $count > 0 ? 1 : 0
};
my @plugin_responses = Koha::Plugins->call(
my @newresults;
my $search_context = {
'interface' => 'opac',
- 'category' => $borcat
+ 'category' => ($patron) ? $patron->categorycode : q{}
};
for (my $i=0;$i<@servers;$i++) {
my $server = $servers[$i];
}
my $allow_onshelf_holds;
+my ( $itemloop_has_images, $otheritemloop_has_images );
if ( not $viewallitems and @items > $max_items_to_display ) {
$template->param(
too_many_items => 1,
if grep { $_ eq $itm->{itemnumber} } @itemnumbers_on_order;
}
+ if ( C4::Context->preference("OPACLocalCoverImages") == 1 ) {
+ $itm->{cover_images} = $item->cover_images;
+ }
+
my $itembranch = $itm->{$separatebranch};
if ($currentbranch and C4::Context->preference('OpacSeparateHoldings')) {
if ($itembranch and $itembranch eq $currentbranch) {
push @itemloop, $itm;
+ $itemloop_has_images++ if $item->cover_images->count;
} else {
push @otheritemloop, $itm;
+ $otheritemloop_has_images++ if $item->cover_images->count;
}
} else {
push @itemloop, $itm;
+ $itemloop_has_images++ if $item->cover_images->count;
}
}
}
$template->param( ReservableItems => 1 );
}
+$template->param(
+ itemloop_has_images => $itemloop_has_images,
+ otheritemloop_has_images => $otheritemloop_has_images,
+);
+
# Display only one tab if one items list is empty
if (scalar(@itemloop) == 0 || scalar(@otheritemloop) == 0) {
$template->param(SeparateHoldings => 0);
);
}
-my $marcnotesarray = GetMarcNotes ($record,$marcflavour,1);
+my $marcnotesarray = $biblio->get_marc_notes({ marcflavour => $marcflavour, opac => 1 });
if( C4::Context->preference('ArticleRequests') ) {
my $patron = $borrowernumber ? Koha::Patrons->find($borrowernumber) : undef;
$template->param( ocoins => $coins );
my ( $loggedincommenter, $reviews );
-if ( C4::Context->preference('reviewson') ) {
+if ( C4::Context->preference('OPACComments') ) {
$reviews = Koha::Reviews->search(
{
biblionumber => $biblionumber,
$template->param('defaulttab' => $defaulttab);
if (C4::Context->preference('OPACLocalCoverImages') == 1) {
- my @images = ListImagesForBiblio($biblionumber);
- $template->{VARS}->{localimages} = \@images;
+ $template->param( localimages => $biblio->cover_images );
}
$template->{VARS}->{OPACPopupAuthorsSearch} = C4::Context->preference('OPACPopupAuthorsSearch');