From ba8f552ab605739ca9a9ea3a2c4c9d0a93871c96 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 16 Feb 2016 15:09:01 +0000 Subject: [PATCH] Bug 15839: Koha::Reviews - Remove getreviews The C4::Reviews::getreviews subroutine retrieved the reviews for a given record, depending on their status. This can be achieve with a call to Koha::Reviews->search. There were 2 calls to this subroutine. The one from opac-ISBDdetail.pl does not look in used: the reviews are not display on this page. It certainly comes from an old copy/paste from opac-detail.pl. The one from opac-detail only asked for the approved reviews. So the logged in user does not see its own review if it is pending approval. Actually this pending approval review is only displayed when the user submits it (because of a unecessary complex text replacement done in JS). With this patch, the approved reviews AND the unaproved review from the logged in user will be displayed. It will allow a future enhancement to add a way to delete our own reviews. Moreover, the reviews were retrieved even if they were not displayed (if reviewson is off), it's now fixed. Signed-off-by: Marc Veron Signed-off-by: Marcel de Rooy Signed-off-by: Kyle M Hall --- C4/Review.pm | 21 +----- .../bootstrap/en/modules/opac-detail.tt | 12 ++-- .../bootstrap/en/modules/opac-review.tt | 37 +--------- opac/opac-ISBDdetail.pl | 14 +--- opac/opac-detail.pl | 67 ++++++++++--------- 5 files changed, 49 insertions(+), 102 deletions(-) diff --git a/C4/Review.pm b/C4/Review.pm index 5d56396f21..6f40ec16b8 100644 --- a/C4/Review.pm +++ b/C4/Review.pm @@ -28,7 +28,7 @@ BEGIN { require Exporter; @ISA = qw(Exporter); @EXPORT = qw(getreview savereview updatereview numberofreviews numberofreviewsbybiblionumber - getreviews getallreviews approvereview unapprovereview deletereview); + getallreviews approvereview unapprovereview deletereview); } =head1 NAME @@ -44,7 +44,6 @@ C4::Review - Perl Module containing routines for dealing with reviews of items updatereview($biblionumber,$borrowernumber,$review); my $count=numberofreviews($status); my $count=numberofreviewsbybiblionumber($biblionumber); - my $reviews=getreviews($biblionumber, $status); my $reviews=getallreviews($status, [$offset], [$row_count]); =head1 DESCRIPTION @@ -140,24 +139,6 @@ sub numberofreviewsbybiblionumber { return $sth->fetchrow; } -=head2 getreviews - - my $reviews=getreviews($biblionumber, $status); - -Return all reviews where in the 'reviews' database : -'biblionumber' = $biblionumber and 'approved' = $status - -=cut - -sub getreviews { - my ( $biblionumber, $approved ) = @_; - my $dbh = C4::Context->dbh; - my $query = "SELECT * FROM reviews WHERE biblionumber=? and approved=? order by datereviewed desc"; - my $sth = $dbh->prepare($query); - $sth->execute( $biblionumber, $approved ); - return $sth->fetchall_arrayref( {} ); -} - =head2 getallreviews my $reviews=getallreviews($status, [$offset], [$row_count]); diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt index 13dc57ecf1..5c52f0fcbe 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -882,12 +882,16 @@
[% IF ( reviews ) %] [% FOREACH review IN reviews %] - [% IF ( review.your_comment ) %] + [% IF review.borrowernumber == borrowernumber %]
[% IF ( review.avatarurl ) %] [% END %] -
Your comment
+ [% IF review.approved %] +
Your comment
+ [% ELSE %] +
Your comment (preview, pending approval)
+ [% END %] [% review.datereviewed | $KohaDates %]

[% FILTER html_break %] @@ -924,7 +928,7 @@ [% END %]

- [% END # / IF review.your_comment %] + [% END %] [% END # / FOREACH reviews %] [% ELSE %]

There are no comments for this item.

@@ -933,7 +937,7 @@ [% IF ( loggedinusername ) %] [% UNLESS ( loggedincommenter ) %] [% END %] [% ELSE %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-review.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-review.tt index 44792a5050..c5ecd82138 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-review.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-review.tt @@ -61,41 +61,8 @@