From a7f831404eba0e38c10cc60dde337e7470e09572 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 12 Jul 2016 11:06:07 +0100 Subject: [PATCH] Bug 17089: Koha::Ratings - Remove ModRating Signed-off-by: Owen Leonard Signed-off-by: Marcel de Rooy Signed-off-by: Kyle M Hall --- C4/Ratings.pm | 27 --------------------------- opac/opac-ratings-ajax.pl | 3 +-- opac/opac-ratings.pl | 3 +-- 3 files changed, 2 insertions(+), 31 deletions(-) diff --git a/C4/Ratings.pm b/C4/Ratings.pm index 8291727ab3..0ec6e0364e 100644 --- a/C4/Ratings.pm +++ b/C4/Ratings.pm @@ -35,7 +35,6 @@ BEGIN { @EXPORT = qw( &GetRating - &ModRating &DelRating ); } @@ -58,9 +57,6 @@ Get a rating for a bib my $rating_hashref = GetRating( $biblionumber, undef ); my $rating_hashref = GetRating( $biblionumber, $borrowernumber ); -Mod a rating for a bib - my $rating_hashref = ModRating( $biblionumber, $borrowernumber, $rating_value ); - Delete a rating for a bib my $rating_hashref = DelRating( $biblionumber, $borrowernumber ); @@ -188,29 +184,6 @@ sub GetRating { return \%rating_hash; } -=head2 ModRating - - my $rating_hashref = ModRating( $biblionumber, $borrowernumber, $rating_value ); - -Mod a rating for a bib - -=cut - -sub ModRating { - my ( $biblionumber, $borrowernumber, $rating_value ) = @_; - - my $rating = Koha::Database->new()->schema->resultset('Rating')->find( - { - borrowernumber => $borrowernumber, - biblionumber => $biblionumber - } - ); - - $rating->update( { rating_value => $rating_value } ); - - return GetRating( $biblionumber, $borrowernumber ); -} - =head2 DelRating my $rating_hashref = DelRating( $biblionumber, $borrowernumber ); diff --git a/opac/opac-ratings-ajax.pl b/opac/opac-ratings-ajax.pl index 1e69650e84..63e2ebc827 100755 --- a/opac/opac-ratings-ajax.pl +++ b/opac/opac-ratings-ajax.pl @@ -82,8 +82,7 @@ elsif ( $rating_value and !$rating_old_value ) { } elsif ( $rating_value ne $rating_old_value ) { -#### mod - $rating = ModRating( $biblionumber, $loggedinuser, $rating_value ); + $rating = Koha::Ratings->find( { biblionumber => $biblionumber, borrowernumber => $loggedinuser })->rating_value($rating_value)->store; } my %js_reply = ( diff --git a/opac/opac-ratings.pl b/opac/opac-ratings.pl index 7ce681cd48..33d4aee5a5 100755 --- a/opac/opac-ratings.pl +++ b/opac/opac-ratings.pl @@ -45,7 +45,6 @@ my $loggedinuser = C4::Context->userenv->{'number'}; my $biblionumber = $query->param('biblionumber'); my $rating_old_value = $query->param('rating_value'); my $rating_value = $query->param('rating'); -my $rating; # If JS is disabled and a user click on "Rate me" without selecting a rate unless ( $biblionumber and $rating_value ) { @@ -58,7 +57,7 @@ if ( !$rating_old_value ) { Koha::Rating->new( { biblionumber => $biblionumber, borrowernumber => $loggedinuser, rating_value => $rating_value, })->store; } else { - $rating = ModRating( $biblionumber, $loggedinuser, $rating_value ); + Koha::Ratings->find( { biblionumber => $biblionumber, borrowernumber => $loggedinuser })->rating_value($rating_value)->store; } print $query->redirect( "/cgi-bin/koha/opac-detail.pl?biblionumber=$biblionumber"); -- 2.39.5