-
- if ($results_hashref->{$server}->{"hits"}){
- $total = $total + $results_hashref->{$server}->{"hits"};
- }
- # Opac search history
- my $newsearchcookie;
- if (C4::Context->preference('EnableOpacSearchHistory')) {
- my @recentSearches;
-
- # Getting the (maybe) already sent cookie
- my $searchcookie = $cgi->cookie('KohaOpacRecentSearches');
- if ($searchcookie){
- $searchcookie = uri_unescape($searchcookie);
- if (thaw($searchcookie)) {
- @recentSearches = @{thaw($searchcookie)};
- }
- }
-
- # Adding the new search if needed
- if (!$borrowernumber || $borrowernumber eq '') {
- # To a cookie (the user is not logged in)
-
- if (($params->{'offset'}||'') eq '') {
-
- push @recentSearches, {
- "query_desc" => $query_desc || "unknown",
- "query_cgi" => $query_cgi || "unknown",
- "time" => time(),
- "total" => $total
- };
- $template->param(ShowOpacRecentSearchLink => 1);
- }
-
- shift @recentSearches if (@recentSearches > 15);
- # Pushing the cookie back
- $newsearchcookie = $cgi->cookie(
- -name => 'KohaOpacRecentSearches',
- # We uri_escape the whole freezed structure so we're sure we won't have any encoding problems
- -value => uri_escape(freeze(\@recentSearches)),
- -expires => ''
- );
- $cookie = [$cookie, $newsearchcookie];
- }
- else {
- # To the session (the user is logged in)
- if (($params->{'offset'}||'') eq '') {
- AddSearchHistory($borrowernumber, $cgi->cookie("CGISESSID"), $query_desc, $query_cgi, $total);
- $template->param(ShowOpacRecentSearchLink => 1);
- }
- }
- }
- ## If there's just one result, redirect to the detail page
+ }
+ }
+
+
+ if ( C4::Context->preference('OpacStarRatings') eq 'all' ) {
+ foreach my $res (@newresults) {
+ 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'};
+ }
+ }
+
+ if ($results_hashref->{$server}->{"hits"}){
+ $total = $total + $results_hashref->{$server}->{"hits"};
+ }
+
+ # Opac search history
+ my $newsearchcookie;
+ if (C4::Context->preference('EnableOpacSearchHistory')) {
+ my @recentSearches;
+
+ # Getting the (maybe) already sent cookie
+ my $searchcookie = $cgi->cookie('KohaOpacRecentSearches');
+ if ($searchcookie){
+ $searchcookie = uri_unescape($searchcookie);
+ if (thaw($searchcookie)) {
+ @recentSearches = @{thaw($searchcookie)};
+ }
+ }
+
+ # Adding the new search if needed
+ my $path_info = $cgi->url(-path_info=>1);
+ $query_cgi = $cgi->url(-query=>1);
+ $query_cgi =~ s/^$path_info\?//;
+ $query_cgi =~ s/;/&/g;
+ $query_desc .= ", $limit_desc";
+
+ if (!$borrowernumber || $borrowernumber eq '') {
+ # To a cookie (the user is not logged in)
+ if (($params->{'offset'}||'') eq '') {
+ push @recentSearches, {
+ "query_desc" => $query_desc || "unknown",
+ "query_cgi" => $query_cgi || "unknown",
+ "time" => time(),
+ "total" => $total
+ };
+ $template->param(ShowOpacRecentSearchLink => 1);
+ }
+
+ shift @recentSearches if (@recentSearches > 15);
+ # Pushing the cookie back
+ $newsearchcookie = $cgi->cookie(
+ -name => 'KohaOpacRecentSearches',
+ # We uri_escape the whole freezed structure so we're sure we won't have any encoding problems
+ -value => uri_escape(freeze(\@recentSearches)),
+ -expires => ''
+ );
+ $cookie = [$cookie, $newsearchcookie];
+ }
+ else {
+ # To the session (the user is logged in)
+ if (($params->{'offset'}||'') eq '') {
+ AddSearchHistory($borrowernumber, $cgi->cookie("CGISESSID"), $query_desc, $query_cgi, $total);
+ $template->param(ShowOpacRecentSearchLink => 1);
+ }
+ }
+ }
+ ## If there's just one result, redirect to the detail page