Bug 17089: Koha::Ratings - Remove AddRating
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 12 Jul 2016 10:04:41 +0000 (11:04 +0100)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 9 Sep 2016 09:31:28 +0000 (09:31 +0000)
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
C4/Ratings.pm
opac/opac-ratings-ajax.pl
opac/opac-ratings.pl

index 7cbc06c..8291727 100644 (file)
@@ -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 );
index 2d6c706..1e69650 100755 (executable)
@@ -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 ) {
index 23e73da..7ce681c 100755 (executable)
@@ -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 );