From 41acd430aff31e4f17b5ce107f88d899b7566ee4 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. --- C4/Review.pm | 21 +------ .../opac-tmpl/bootstrap/en/modules/opac-detail.tt | 12 ++-- .../opac-tmpl/bootstrap/en/modules/opac-review.tt | 37 +----------- opac/opac-ISBDdetail.pl | 14 +---- opac/opac-detail.pl | 68 ++++++++++++---------- 5 files changed, 49 insertions(+), 103 deletions(-) diff --git a/C4/Review.pm b/C4/Review.pm index 5c6f45a..ed2b126 100644 --- a/C4/Review.pm +++ b/C4/Review.pm @@ -30,7 +30,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 @@ -46,7 +46,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 @@ -142,24 +141,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 4b3db89..9057f5a 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -892,12 +892,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 %] @@ -934,7 +938,7 @@ [% END %]

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

There are no comments for this item.

@@ -943,7 +947,7 @@ [% IF ( loggedinusername ) %] [% UNLESS ( loggedincommenter ) %]
- Post or edit your comments on this item. + Post your comments on this item.
[% 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 44792a5..c5ecd82 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 @@