Bug 16551: Display the name of lists to the search results at the OPAC
[koha_ffzg] / opac / opac-search.pl
index 8dda1f0..ccbc025 100755 (executable)
@@ -50,10 +50,11 @@ use C4::Biblio;  # GetBiblioData
 use C4::Koha;
 use C4::Tags qw(get_tags);
 use C4::SocialData;
-use C4::Ratings;
 use C4::External::OverDrive;
 
 use Koha::LibraryCategories;
+use Koha::Ratings;
+use Koha::Virtualshelves;
 
 use POSIX qw(ceil floor strftime);
 use URI::Escape;
@@ -692,12 +693,17 @@ for (my $i=0;$i<@servers;$i++) {
                 }
             }
 
+            $res->{shelves} = Koha::Virtualshelves->get_shelves_containing_record(
+                {
+                    biblionumber   => $res->{biblionumber},
+                    borrowernumber => $borrowernumber
+                }
+            );
+
             if ( C4::Context->preference('OpacStarRatings') eq 'all' ) {
-                my $rating = GetRating( $res->{'biblionumber'}, $borrowernumber );
-                $res->{'rating_value'}  = $rating->{'rating_value'};
-                $res->{'rating_total'}  = $rating->{'rating_total'};
-                $res->{'rating_avg'}    = $rating->{'rating_avg'};
-                $res->{'rating_avg_int'} = $rating->{'rating_avg_int'};
+                my $ratings = Koha::Ratings->search({ biblionumber => $res->{biblionumber} });
+                $res->{ratings} = $ratings;
+                $res->{my_rating} = $borrowernumber ? $ratings->search({ borrowernumber => $borrowernumber })->next : undef;
             }
         }