Enh 6902: Novelist Select enhanced content
[koha.git] / opac / opac-detail.pl
index f230834..ebb2d1c 100755 (executable)
@@ -44,6 +44,7 @@ use C4::ShelfBrowser;
 use C4::Charset;
 use MARC::Record;
 use MARC::Field;
+use List::MoreUtils qw/any none/;
 
 BEGIN {
        if (C4::Context->preference('BakerTaylorEnabled')) {
@@ -84,16 +85,29 @@ if (C4::Context->preference("OPACXSLTDetailsDisplay") ) {
 
 $template->param('OPACShowCheckoutName' => C4::Context->preference("OPACShowCheckoutName") ); 
 # change back when ive fixed request.pl
-my @all_items = &GetItemsInfo( $biblionumber, 'opac' );
+my @all_items = GetItemsInfo( $biblionumber );
 my @items;
-@items = @all_items unless C4::Context->preference('hidelostitems');
 
-if (C4::Context->preference('hidelostitems')) {
-    # Hide host items
+# Getting items to be hidden
+my @hiddenitems = GetHiddenItemnumbers(@all_items);
+
+# Are there items to hide?
+my $hideitems = 1 if C4::Context->preference('hidelostitems') or scalar(@hiddenitems) > 0;
+
+# Hide items
+if ($hideitems) {
     for my $itm (@all_items) {
-        push @items, $itm unless $itm->{itemlost};
+       if  ( C4::Context->preference('hidelostitems') ) {
+           push @items, $itm unless $itm->{itemlost} or any { $itm->{'itemnumber'} eq $_ } @hiddenitems;
+       } else {
+           push @items, $itm unless any { $itm->{'itemnumber'} eq $_ } @hiddenitems;
     }
 }
+} else {
+    # Or not
+    @items = @all_items;
+}
+
 my $dat = &GetBiblioData($biblionumber);
 
 my $itemtypes = GetItemTypes();
@@ -267,7 +281,10 @@ my $upc = GetNormalizedUPC($record,$marcflavour);
 my $ean = GetNormalizedEAN($record,$marcflavour);
 my $oclc = GetNormalizedOCLCNumber($record,$marcflavour);
 my $isbn = GetNormalizedISBN(undef,$record,$marcflavour);
-my $content_identifier_exists = 1 if ($isbn or $ean or $oclc or $upc);
+my $content_identifier_exists;
+if ( $isbn or $ean or $oclc or $upc ) {
+    $content_identifier_exists = 1;
+}
 $template->param(
        normalized_upc => $upc,
        normalized_ean => $ean,
@@ -281,6 +298,12 @@ $template->param(
     ocoins => GetCOinSBiblio($biblionumber),
 );
 
+my $libravatar_enabled = 0;
+eval 'use Libravatar::URL';
+if (!$@ and C4::Context->preference('ShowReviewer') and C4::Context->preference('ShowReviewerPhoto')) {
+    $libravatar_enabled = 1;
+}
+
 my $reviews = getreviews( $biblionumber, 1 );
 my $loggedincommenter;
 foreach ( @$reviews ) {
@@ -289,6 +312,9 @@ foreach ( @$reviews ) {
     $_->{title}     = $borrowerData->{'title'};
     $_->{surname}   = $borrowerData->{'surname'};
     $_->{firstname} = $borrowerData->{'firstname'};
+    if ($libravatar_enabled and $borrowerData->{'email'}) {
+        $_->{avatarurl} = libravatar_url(email => $borrowerData->{'email'}, https => $ENV{HTTPS});
+    }
     $_->{userid}    = $borrowerData->{'userid'};
     $_->{cardnumber}    = $borrowerData->{'cardnumber'};
     $_->{datereviewed} = format_date($_->{datereviewed});
@@ -468,6 +494,14 @@ $template->param(LibraryThingForLibrariesTabbedView =>
 C4::Context->preference('LibraryThingForLibrariesTabbedView') );
 } 
 
+# Novelist Select
+if( C4::Context->preference('NovelistSelectEnabled') ) 
+{ 
+$template->param(NovelistSelectProfile => C4::Context->preference('NovelistSelectProfile') ); 
+$template->param(NovelistSelectPassword => C4::Context->preference('NovelistSelectPassword') ); 
+$template->param(NovelistSelectView => C4::Context->preference('NovelistSelectView') ); 
+} 
+
 
 # Babelthèque
 if ( C4::Context->preference("Babeltheque") ) {
@@ -548,6 +582,7 @@ if (my $search_for_title = C4::Context->preference('OPACSearchForTitleIn')){
     $dat->{title} ? $search_for_title =~ s/{TITLE}/$dat->{title}/g : $search_for_title =~ s/{TITLE}//g;
     $isbn ? $search_for_title =~ s/{ISBN}/$isbn/g : $search_for_title =~ s/{ISBN}//g;
     $marccontrolnumber ? $search_for_title =~ s/{CONTROLNUMBER}/$marccontrolnumber/g : $search_for_title =~ s/{CONTROLNUMBER}//g;
+    $search_for_title =~ s/{BIBLIONUMBER}/$biblionumber/g;
  $template->param('OPACSearchForTitleIn' => $search_for_title);
 }