Bug 34478: Add 'op' to opac-ratings

This is only for non-JS, might need to be removed

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2024-01-31 12:18:21 +01:00
parent 36e5555144
commit 4b704d02bc
No known key found for this signature in database
GPG Key ID: A085E712BEF0E0F0
2 changed files with 12 additions and 7 deletions

View File

@ -324,6 +324,7 @@
<!-- define some hidden vars for ratings -->
<input type="hidden" name="op" value="cud-add" />
<input type="hidden" name='biblionumber' value="[% biblio.biblionumber | html %]" />
<input type="hidden" name='rating_value' id='rating_value' class="rating_value" value="[% my_rating.rating_value | html %]" />

View File

@ -39,6 +39,7 @@ my $query = CGI->new();
my ($userid, $cookie, $sessionID) = checkauth( $query, 0, {}, 'opac' );
my $loggedinuser = C4::Context->userenv->{'number'};
my $op = $query->param('op') || q{};
my $biblionumber = $query->param('biblionumber');
my $rating_old_value = $query->param('rating_value');
my $rating_value = $query->param('rating');
@ -50,13 +51,16 @@ unless ( $biblionumber and $rating_value ) {
exit;
}
if ( !$rating_old_value ) {
my $rating = Koha::Rating->new( { biblionumber => $biblionumber, borrowernumber => $loggedinuser, rating_value => $rating_value, });
$rating->store if $rating;
}
else {
my $rating = Koha::Ratings->find( { biblionumber => $biblionumber, borrowernumber => $loggedinuser });
$rating->rating_value($rating_value)->store if $rating;
if ( $op eq 'cud-add' ) {
if ( !$rating_old_value ) {
my $rating = Koha::Rating->new( { biblionumber => $biblionumber, borrowernumber => $loggedinuser, rating_value => $rating_value, });
$rating->store if $rating;
}
else {
my $rating = Koha::Ratings->find( { biblionumber => $biblionumber, borrowernumber => $loggedinuser });
$rating->rating_value($rating_value)->store if $rating;
}
}
print $query->redirect(
"/cgi-bin/koha/opac-detail.pl?biblionumber=$biblionumber");