Bug 8435: DBRev 3.13.00.038
[koha.git] / C4 / Serials.pm
index 72d6bad..da876e2 100644 (file)
@@ -20,6 +20,7 @@ package C4::Serials;
 
 use Modern::Perl;
 
+use C4::Auth qw(haspermission);
 use C4::Context;
 use C4::Dates qw(format_date format_date_in_iso);
 use Date::Calc qw(:all);
@@ -2794,8 +2795,17 @@ sub subscriptionCurrentlyOnOrder {
     return $sth->fetchrow_array;
 }
 
+=head2 can_edit_subscription
+
+    $can = can_edit_subscription( $subscriptionid[, $userid] );
+
+Return 1 if the subscription is editable by the current logged user (or a given $userid), else 0.
+
+=cut
+
 sub can_edit_subscription {
     my ( $subscription, $userid ) = @_;
+    return 0 unless C4::Context->userenv;
     my $flags = C4::Context->userenv->{flags};
     $userid ||= C4::Context->userenv->{'id'};
     my $independent_branches = C4::Context->preference('IndependentBranches');