Bug 34478: Prevent renew if logged in user is not allowed to

This should be on its own bug. Feel free to do it if you have the
energy, I do not.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2024-02-27 11:43:22 +01:00
parent c706fc9e41
commit 8c3a25bf1f
Signed by: jonathan.druart
GPG key ID: A085E712BEF0E0F0

View file

@ -81,6 +81,12 @@ if ( $op eq "cud-renew" ) {
# Make sure the subscription exists
my $subscription = GetSubscription( $subscriptionid );
output_and_exit( $query, $cookie, $template, 'unknown_subscription') unless $subscription;
if ($subscription->{cannotedit}){
carp "Attempt to renew subscription $subscriptionid by ".C4::Context->userenv->{'id'}." not allowed";
print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
}
my $startdate = output_pref( { str => scalar $query->param('startdate'), dateonly => 1, dateformat => 'iso' } );
($numberlength, $weeklength, $monthlength) = GetSubscriptionLength( $subtype, $sublength );
ReNewSubscription(
@ -99,6 +105,7 @@ if ( $op eq "cud-renew" ) {
for my $subscriptionid ( @subscriptionids ) {
my $subscription = GetSubscription( $subscriptionid );
next unless $subscription;
next if $subscription->{cannotedit};
ReNewSubscription(
{
subscriptionid => $subscriptionid,