From 41fa333ec98a492f9a509d3a05f747ac38ac7c79 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 16 Feb 2016 16:28:33 +0000 Subject: [PATCH] Bug 15839: Koha::Reviews - Remove updatereview Signed-off-by: Marc Veron Signed-off-by: Marcel de Rooy Signed-off-by: Kyle M Hall --- C4/Review.pm | 19 +------------------ opac/opac-review.pl | 11 +++++++++-- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/C4/Review.pm b/C4/Review.pm index b76b1e99fa..90bdfeb3f6 100644 --- a/C4/Review.pm +++ b/C4/Review.pm @@ -27,7 +27,7 @@ use vars qw(@ISA @EXPORT); BEGIN { require Exporter; @ISA = qw(Exporter); - @EXPORT = qw(savereview updatereview numberofreviewsbybiblionumber); + @EXPORT = qw(savereview numberofreviewsbybiblionumber); } =head1 NAME @@ -39,7 +39,6 @@ C4::Review - Perl Module containing routines for dealing with reviews of items use C4::Review; savereview($biblionumber,$borrowernumber,$review); - updatereview($biblionumber,$borrowernumber,$review); my $count=numberofreviewsbybiblionumber($biblionumber); =head1 DESCRIPTION @@ -66,22 +65,6 @@ sub savereview { $sth->execute( $borrowernumber, $biblionumber, $review ); } -=head2 updatereview - - updateview($biblionumber,$borrowernumber, $review); - -Update the review description in the 'reviews' database - -=cut - -sub updatereview { - my ( $biblionumber, $borrowernumber, $review ) = @_; - my $dbh = C4::Context->dbh; - my $query = "UPDATE reviews SET review=?,datereviewed=now(),approved=0 WHERE borrowernumber=? and biblionumber=?"; - my $sth = $dbh->prepare($query); - $sth->execute( $review, $borrowernumber, $biblionumber ); -} - =head2 numberofreviewsbybiblionumber my $count=numberofreviewsbybiblionumber($biblionumber); diff --git a/opac/opac-review.pl b/opac/opac-review.pl index fd3491ae76..a9658963cd 100755 --- a/opac/opac-review.pl +++ b/opac/opac-review.pl @@ -26,6 +26,7 @@ use C4::Review; use C4::Biblio; use C4::Scrubber; use C4::Debug; +use Koha::DateUtils; use Koha::Reviews; my $query = new CGI; @@ -60,8 +61,14 @@ if (defined $review) { my $js_ok_review = $clean; $js_ok_review =~ s/"/"/g; # probably redundant w/ TMPL ESCAPE=JS $template->param(clean_review=>$js_ok_review); - if ($savedreview) { - updatereview($biblionumber, $borrowernumber, $clean); + if ($savedreview) { + $savedreview->set( + { + review => $clean, + approved => 0, + datereviewed => dt_from_string + } + )->store; } else { savereview($biblionumber, $borrowernumber, $clean); }