From d9af985de6dc21ad1bed99c4fed536f377c255d9 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 12 Jul 2016 11:04:41 +0100 Subject: [PATCH] Bug 17089: Koha::Ratings - Remove AddRating Signed-off-by: Owen Leonard Signed-off-by: Marcel de Rooy Signed-off-by: Kyle M Hall --- C4/Ratings.pm | 30 ------------------------------ opac/opac-ratings-ajax.pl | 6 ++++-- opac/opac-ratings.pl | 4 +++- 3 files changed, 7 insertions(+), 33 deletions(-) diff --git a/C4/Ratings.pm b/C4/Ratings.pm index 7cbc06c8fd..8291727ab3 100644 --- a/C4/Ratings.pm +++ b/C4/Ratings.pm @@ -35,7 +35,6 @@ BEGIN { @EXPORT = qw( &GetRating - &AddRating &ModRating &DelRating ); @@ -59,9 +58,6 @@ Get a rating for a bib my $rating_hashref = GetRating( $biblionumber, undef ); my $rating_hashref = GetRating( $biblionumber, $borrowernumber ); -Add a rating for a bib - my $rating_hashref = AddRating( $biblionumber, $borrowernumber, $rating_value ); - Mod a rating for a bib my $rating_hashref = ModRating( $biblionumber, $borrowernumber, $rating_value ); @@ -192,32 +188,6 @@ sub GetRating { return \%rating_hash; } -=head2 AddRating - - my $rating_hashref = AddRating( $biblionumber, $borrowernumber, $rating_value ); - -Add a rating for a bib - -This adds or updates a rating for a particular user on a biblio. If the value -is 0, then the rating will be deleted. If the value is out of the range of -0-5, nothing will happen. - -=cut - -sub AddRating { - my ( $biblionumber, $borrowernumber, $rating_value ) = @_; - - my $rating = Koha::Database->new()->schema->resultset('Rating')->create( - { - biblionumber => $biblionumber, - borrowernumber => $borrowernumber, - rating_value => $rating_value - } - ); - - return GetRating( $biblionumber, $borrowernumber ); -} - =head2 ModRating my $rating_hashref = ModRating( $biblionumber, $borrowernumber, $rating_value ); diff --git a/opac/opac-ratings-ajax.pl b/opac/opac-ratings-ajax.pl index 2d6c706f33..1e69650e84 100755 --- a/opac/opac-ratings-ajax.pl +++ b/opac/opac-ratings-ajax.pl @@ -34,6 +34,9 @@ use C4::Context; use C4::Debug; use C4::Output qw(:html :ajax pagination_bar); use C4::Ratings; + +use Koha::Ratings; + use JSON; my $is_ajax = is_ajax(); @@ -75,8 +78,7 @@ if ( $rating_value eq '' ) { } elsif ( $rating_value and !$rating_old_value ) { -#### insert - $rating = AddRating( $biblionumber, $loggedinuser, $rating_value ); + $rating = Koha::Rating->new( { biblionumber => $biblionumber, borrowernumber => $loggedinuser, rating_value => $rating_value, })->store; } elsif ( $rating_value ne $rating_old_value ) { diff --git a/opac/opac-ratings.pl b/opac/opac-ratings.pl index 23e73daedf..7ce681cd48 100755 --- a/opac/opac-ratings.pl +++ b/opac/opac-ratings.pl @@ -34,6 +34,8 @@ use C4::Context; use C4::Ratings; use C4::Debug; +use Koha::Ratings; + my $query = CGI->new(); # auth required to add ratings @@ -53,7 +55,7 @@ unless ( $biblionumber and $rating_value ) { } if ( !$rating_old_value ) { - $rating = AddRating( $biblionumber, $loggedinuser, $rating_value ); + Koha::Rating->new( { biblionumber => $biblionumber, borrowernumber => $loggedinuser, rating_value => $rating_value, })->store; } else { $rating = ModRating( $biblionumber, $loggedinuser, $rating_value ); -- 2.39.5