Bug 17089: Koha::Ratings - Remove AddRating
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>
This commit is contained in:
parent
172b4b54a1
commit
d9af985de6
3 changed files with 7 additions and 33 deletions
|
@ -35,7 +35,6 @@ BEGIN {
|
||||||
|
|
||||||
@EXPORT = qw(
|
@EXPORT = qw(
|
||||||
&GetRating
|
&GetRating
|
||||||
&AddRating
|
|
||||||
&ModRating
|
&ModRating
|
||||||
&DelRating
|
&DelRating
|
||||||
);
|
);
|
||||||
|
@ -59,9 +58,6 @@ Get a rating for a bib
|
||||||
my $rating_hashref = GetRating( $biblionumber, undef );
|
my $rating_hashref = GetRating( $biblionumber, undef );
|
||||||
my $rating_hashref = GetRating( $biblionumber, $borrowernumber );
|
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
|
Mod a rating for a bib
|
||||||
my $rating_hashref = ModRating( $biblionumber, $borrowernumber, $rating_value );
|
my $rating_hashref = ModRating( $biblionumber, $borrowernumber, $rating_value );
|
||||||
|
|
||||||
|
@ -192,32 +188,6 @@ sub GetRating {
|
||||||
return \%rating_hash;
|
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
|
=head2 ModRating
|
||||||
|
|
||||||
my $rating_hashref = ModRating( $biblionumber, $borrowernumber, $rating_value );
|
my $rating_hashref = ModRating( $biblionumber, $borrowernumber, $rating_value );
|
||||||
|
|
|
@ -34,6 +34,9 @@ use C4::Context;
|
||||||
use C4::Debug;
|
use C4::Debug;
|
||||||
use C4::Output qw(:html :ajax pagination_bar);
|
use C4::Output qw(:html :ajax pagination_bar);
|
||||||
use C4::Ratings;
|
use C4::Ratings;
|
||||||
|
|
||||||
|
use Koha::Ratings;
|
||||||
|
|
||||||
use JSON;
|
use JSON;
|
||||||
|
|
||||||
my $is_ajax = is_ajax();
|
my $is_ajax = is_ajax();
|
||||||
|
@ -75,8 +78,7 @@ if ( $rating_value eq '' ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
elsif ( $rating_value and !$rating_old_value ) {
|
elsif ( $rating_value and !$rating_old_value ) {
|
||||||
#### insert
|
$rating = Koha::Rating->new( { biblionumber => $biblionumber, borrowernumber => $loggedinuser, rating_value => $rating_value, })->store;
|
||||||
$rating = AddRating( $biblionumber, $loggedinuser, $rating_value );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
elsif ( $rating_value ne $rating_old_value ) {
|
elsif ( $rating_value ne $rating_old_value ) {
|
||||||
|
|
|
@ -34,6 +34,8 @@ use C4::Context;
|
||||||
use C4::Ratings;
|
use C4::Ratings;
|
||||||
use C4::Debug;
|
use C4::Debug;
|
||||||
|
|
||||||
|
use Koha::Ratings;
|
||||||
|
|
||||||
my $query = CGI->new();
|
my $query = CGI->new();
|
||||||
|
|
||||||
# auth required to add ratings
|
# auth required to add ratings
|
||||||
|
@ -53,7 +55,7 @@ unless ( $biblionumber and $rating_value ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !$rating_old_value ) {
|
if ( !$rating_old_value ) {
|
||||||
$rating = AddRating( $biblionumber, $loggedinuser, $rating_value );
|
Koha::Rating->new( { biblionumber => $biblionumber, borrowernumber => $loggedinuser, rating_value => $rating_value, })->store;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$rating = ModRating( $biblionumber, $loggedinuser, $rating_value );
|
$rating = ModRating( $biblionumber, $loggedinuser, $rating_value );
|
||||||
|
|
Loading…
Reference in a new issue