diff --git a/C4/Serials.pm b/C4/Serials.pm index 2b7fd51069..9fc9ad82cc 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -736,12 +736,20 @@ sub SearchSubscriptions { my $results = $sth->fetchall_arrayref( {} ); $sth->finish; + my $cant_display_other_branches = 0; + if (my $env = C4::Context->userenv) { + my $userid = $env->{'id'}; + $cant_display_other_branches = + C4::Context->preference('IndependentBranches') && + !C4::Context->IsSuperLibrarian() && + !C4::Auth::haspermission( $userid, {serials => 'superserials'}); + } + my $user_branch = C4::Context->userenv->{'branch'}; for my $subscription ( @$results ) { $subscription->{cannotedit} = not can_edit_subscription( $subscription ); $subscription->{cannotdisplay} = - ( C4::Context->preference("IndependentBranches") && - (!C4::Context->IsSuperLibrarian()) && - $subscription->{branchcode} ne C4::Context->userenv->{'branch'} ) ? 1 : 0; + $cant_display_other_branches && + $subscription->{branchcode} ne $user_branch; } return @$results;