From 4b704d02bc644639a7d8f6d5b142abf6967353ea Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 31 Jan 2024 12:18:21 +0100 Subject: [PATCH] Bug 34478: Add 'op' to opac-ratings This is only for non-JS, might need to be removed Signed-off-by: Jonathan Druart --- .../bootstrap/en/modules/opac-detail.tt | 1 + opac/opac-ratings.pl | 18 +++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt index 25342d6efd..af58eaf88e 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -324,6 +324,7 @@ + diff --git a/opac/opac-ratings.pl b/opac/opac-ratings.pl index 7e1bca61cb..5d78f023fa 100755 --- a/opac/opac-ratings.pl +++ b/opac/opac-ratings.pl @@ -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"); -- 2.39.5