From 77d4598e3705111695e49b72c45aac3662df3376 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Demians?= Date: Tue, 15 Apr 2014 10:10:07 +0200 Subject: [PATCH] [SIGNED OFF] Bug 12080 Superserials permission in search result Enabling/disabling IndependentBranch syspref & superserials permission, you can see that serials search result doesn't display all subscriptions when appropriate. Fixed with this patch. Dependency: This patch must be applied after patch for bug 12048. TEST PLAN --------- 1) Apply the patch for bug 12048 (as needed -- it may be pushed) 2) Ensure you have two users: superlibrarian, non-superlibrarian with all access to the staff client except superserials. 3) Ensure you have serials belonging to a different branch than the non-superlibrarian. 3) Log into staff client as superlibrarian 4) Click 'Serials' 5) Click the 'Submit' button in the search area. -- note the number of results. 6) Log into staff client as non-superlibrarian 7) Click 'Serials' 8) Click the 'Submit' button in the search area. -- note the number should be less, note the number. 9) Give the non-superlibrarian superserials access. 10) Home -> Serials 11) Click the 'Submit' button in the search area. -- the number will still be the same at the one in step #8. 12) Apply the patch 13) Refresh the page -- the number should now match the one in step #5. Signed-off-by: Mark Tompsett --- C4/Serials.pm | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/C4/Serials.pm b/C4/Serials.pm index 2b7fd51..9fc9ad8 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; -- 1.7.9.5