Bug 11529: Use new biblio fields whenever possible
[srvgit] / opac / opac-readingrecord.pl
index 49348ad..00c7c43 100755 (executable)
@@ -33,6 +33,7 @@ use C4::Charset qw(StripNonXmlChars);
 use Koha::Patrons;
 
 use Koha::ItemTypes;
+use Koha::Ratings;
 
 my $query = new CGI;
 
@@ -97,8 +98,7 @@ foreach my $issue ( @{$issues} ) {
         my $marc_rec =
           MARC::Record::new_from_xml( $marcxml, 'utf8',
             C4::Context->preference('marcflavour') );
-        $issue->{subtitle} =
-          GetRecordValue( 'subtitle', $marc_rec, $issue->{frameworkcode} );
+        $issue->{subtitle} = GetRecordValue( 'subtitle', $marc_rec );
         $issue->{normalized_upc} = GetNormalizedUPC( $marc_rec, C4::Context->preference('marcflavour') );
     }
     # My Summary HTML
@@ -121,6 +121,12 @@ foreach my $issue ( @{$issues} ) {
           : $my_summary_html =~ s/{BIBLIONUMBER}//g;
         $issue->{MySummaryHTML} = $my_summary_html;
     }
+    # Star ratings
+    if ( C4::Context->preference('OpacStarRatings') eq 'all' ) {
+        my $ratings = Koha::Ratings->search({ biblionumber => $issue->{biblionumber} });
+        $issue->{ratings} = $ratings;
+        $issue->{my_rating} = $borrowernumber ? $ratings->search({ borrowernumber => $borrowernumber })->next : undef;
+    }
 }
 
 if (C4::Context->preference('BakerTaylorEnabled')) {
@@ -140,7 +146,7 @@ BEGIN {
        }
 }
 
-for(qw(AmazonCoverImages GoogleJackets)) {     # BakerTaylorEnabled handled above
+for(qw(AmazonCoverImages GoogleJackets)) { # BakerTaylorEnabled handled above
        C4::Context->preference($_) or next;
        $template->param($_=>1);
        $template->param(JacketImages=>1);