=cut
-use strict;
-use warnings;
+use Modern::Perl;
use CGI qw ( -utf8 );
use CGI::Cookie; # need to check cookies before having CGI parse the POST request
-use C4::Auth qw(:DEFAULT check_cookie_auth);
+use C4::Auth qw( get_template_and_user check_cookie_auth );
use C4::Context;
-use C4::Debug;
-use C4::Output qw(:html :ajax pagination_bar);
+use C4::Output qw( is_ajax output_ajax_with_http_headers );
use Koha::Ratings;
query => $query,
type => "opac",
authnotrequired => 0, # auth required to add tags
- debug => 1,
}
);
}
$rating_value //= '';
if ( $rating_value eq '' ) {
- Koha::Ratings->find( { biblionumber => $biblionumber, borrowernumber => $loggedinuser } )->delete;
+ my $rating = Koha::Ratings->find( { biblionumber => $biblionumber, borrowernumber => $loggedinuser } );
+ $rating->delete if $rating;
}
elsif ( $rating_value and !$rating_old_value ) {
}
elsif ( $rating_value ne $rating_old_value ) {
- Koha::Ratings->find( { biblionumber => $biblionumber, borrowernumber => $loggedinuser })->rating_value($rating_value)->store;
+ my $rating = Koha::Ratings->find( { biblionumber => $biblionumber, borrowernumber => $loggedinuser });
+ $rating->rating_value($rating_value)->store if $rating
}
my $ratings = Koha::Ratings->search({ biblionumber => $biblionumber });
rating_total => $ratings->count,
rating_avg => $avg,
rating_avg_int => sprintf("%.0f", $avg),
- rating_value => $my_rating->rating_value,
+ rating_value => $my_rating ? $my_rating->rating_value : undef,
auth_status => $auth_status,
);
my %cookies = CGI::Cookie->fetch;
my $input = CGI->new;
my $sessid = $cookies{'CGISESSID'}->value || $input->param('CGISESSID');
- my ( $auth_status, $auth_sessid ) =
+ my ( $auth_status ) =
check_cookie_auth( $sessid, $needed_flags );
return $input, $auth_status;
}