Bug 28519: Add lib to koha-shell
[srvgit] / opac / opac-detail.pl
index 67c074c..6173b72 100755 (executable)
@@ -89,10 +89,6 @@ if( $specific_item ) {
 }
 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,
@@ -102,17 +98,20 @@ if ( ! $record ) {
     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',
@@ -280,7 +279,7 @@ if ($session->param('busc')) {
         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];
@@ -763,22 +762,21 @@ if ( not $viewallitems and @items > $max_items_to_display ) {
     }
 
     if ( C4::Context->preference("OPACLocalCoverImages") == 1 ) {
-        my $cover_image = $item->cover_image;
-        $itm->{imagenumber} = $cover_image ? $cover_image->imagenumber : undef;
+        $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 $itm->{imagenumber};
+            $itemloop_has_images++ if $item->cover_images->count;
         } else {
             push @otheritemloop, $itm;
-            $otheritemloop_has_images++ if $itm->{imagenumber};
+            $otheritemloop_has_images++ if $item->cover_images->count;
         }
     } else {
         push @itemloop, $itm;
-        $itemloop_has_images++ if $itm->{imagenumber};
+        $itemloop_has_images++ if $item->cover_images->count;
     }
   }
 }
@@ -817,7 +815,7 @@ if (!C4::Context->preference("OPACXSLTDetailsDisplay") ) {
     );
 }
 
-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;
@@ -901,7 +899,7 @@ my $coins = eval { $biblio->get_coins };
 $template->param( ocoins => $coins );
 
 my ( $loggedincommenter, $reviews );
-if ( C4::Context->preference('reviewson') ) {
+if ( C4::Context->preference('OPACComments') ) {
     $reviews = Koha::Reviews->search(
         {
             biblionumber => $biblionumber,