From 693bbc76e736f048c4c16e7a5664f3494db287c0 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Tue, 26 Mar 2019 13:51:47 +0000 Subject: [PATCH] Bug 11969: Show patrons star rating on their reading history This patch adds display of a user's ratings to their reading history in the OPAC. Also changed: Removed obsolete "border" attribute from the template, and removed obsolete JavaScript include from opac-results.tt To test, apply the patch and rebuild the OPAC CSS. OpacStarRatings should be set to all (results and details). - Log in to the OPAC as a user with a reading history and titles in that history which have ratings. - Under the "your reading history" tab, your ratings should show under rated titles with the date of the rating. - Test also with OpacStarRatings set to a value other than "all." Signed-off-by: Hayley Mapley Star ratings are displayed in Reading History with OpacStarRatings enabled, and are not displayed when OpacStarRatings is disabled, as expected. Signed-off-by: Katrin Fischer Signed-off-by: Nick Clemens --- .../en/modules/opac-readingrecord.tt | 26 ++++++++++++++++--- .../bootstrap/en/modules/opac-results.tt | 1 - opac/opac-readingrecord.pl | 9 ++++++- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt index d03d51855a..5a880b2a73 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-readingrecord.tt @@ -108,7 +108,7 @@ [% END %] [% IF OPACAmazonCoverImages %] [% IF issue.normalized_isbn %] - + [% ELSE %] No cover image available [% END %] @@ -143,7 +143,27 @@ [% ELSE %] [% issue.title | html %] [% IF issue.subtitle %][% FOREACH subtitl IN issue.subtitle %][% subtitl.subfield | html %][% END %][% END %] [% END %] - [% issue.author | html %] +

[% issue.author | html %]

+ + [% IF ( Koha.Preference( 'OpacStarRatings' ) == 'all' && issue.my_rating ) %] +
+
+
+ [% FOREACH i IN [ 1 2 3 4 5 ] %] + [% IF issue.my_rating.rating_value == i %] + + [% ELSIF issue.my_rating.rating_value > i %] + + [% ELSE %] + + [% END %] + [% END %] +
+
+ Rated on [% issue.my_rating.timestamp | $KohaDates %] +
+ [% END # / IF OpacStarRatings %] + [% UNLESS ( noItemTypeImages ) %] @@ -188,7 +208,6 @@ [% BLOCK jsinclude %] [% INCLUDE 'datatables.inc' %] [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt index 2e233f1d1a..6f53cabdce 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt @@ -618,7 +618,6 @@ [% IF ( LibraryThingForLibrariesID ) %] [% END %] -[% IF ( OpacStarRatings == 'all' || Koha.Preference('Babeltheque') ) %][% Asset.js("lib/jquery/plugins/jquery.rating.js") | $raw %][% END %] [% IF ( OverDriveEnabled ) %][% Asset.js("js/overdrive.js") | $raw %][% END %] [% IF ( RecordedBooksEnabled ) %][% Asset.js("js/recordedbooks.js") | $raw %][% END %] [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %] diff --git a/opac/opac-readingrecord.pl b/opac/opac-readingrecord.pl index 49348adf45..c01409a700 100755 --- a/opac/opac-readingrecord.pl +++ b/opac/opac-readingrecord.pl @@ -33,6 +33,7 @@ use C4::Charset qw(StripNonXmlChars); use Koha::Patrons; use Koha::ItemTypes; +use Koha::Ratings; my $query = new CGI; @@ -121,6 +122,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 +147,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); -- 2.39.5