From 6b95cb48b30a3e128d7b41ef1756efc12cd823ba Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 5 Feb 2016 12:30:29 +0000 Subject: [PATCH] Bug 15758: Koha::Libraries - Move onlymine to C4::Context::only_my_library Signed-off-by: Owen Leonard Signed-off-by: Kyle M Hall --- C4/Branch.pm | 8 -------- C4/Context.pm | 9 +++++++++ C4/Utils/DataTables/Members.pm | 2 +- Koha/Libraries.pm | 6 +----- admin/smart-rules.pl | 2 +- circ/overdue.pl | 7 ------- members/member.pl | 2 +- 7 files changed, 13 insertions(+), 23 deletions(-) diff --git a/C4/Branch.pm b/C4/Branch.pm index a4f6b2f3bd..1c912ab46d 100644 --- a/C4/Branch.pm +++ b/C4/Branch.pm @@ -48,14 +48,6 @@ The functions in this module deal with branches. =cut -sub onlymine { - return - C4::Context->preference('IndependentBranches') - && C4::Context->userenv - && !C4::Context->IsSuperLibrarian() - && C4::Context->userenv->{branch}; -} - =head2 GetBranch $branch = GetBranch( $query, $branches ); diff --git a/C4/Context.pm b/C4/Context.pm index 87242d34c0..c84230dd5a 100644 --- a/C4/Context.pm +++ b/C4/Context.pm @@ -1035,6 +1035,15 @@ sub mybranch { C4::Context->userenv or return ''; return C4::Context->userenv->{branch} || ''; } +sub only_my_library { + return + C4::Context->preference('IndependentBranches') + && C4::Context->userenv + && !C4::Context->IsSuperLibrarian() + && C4::Context->userenv->{branch}; +} + + 1; __END__ diff --git a/C4/Utils/DataTables/Members.pm b/C4/Utils/DataTables/Members.pm index a21500692b..958e92117c 100644 --- a/C4/Utils/DataTables/Members.pm +++ b/C4/Utils/DataTables/Members.pm @@ -25,7 +25,7 @@ sub search { # If branches are independent and user is not superlibrarian # The search has to be only on the user branch - if ( C4::Branch::onlymine ) { + if ( C4::Context::only_my_library ) { my $userenv = C4::Context->userenv; $branchcode = $userenv->{'branch'}; diff --git a/Koha/Libraries.pm b/Koha/Libraries.pm index fefc3ab51f..fa2bf17b04 100644 --- a/Koha/Libraries.pm +++ b/Koha/Libraries.pm @@ -45,11 +45,7 @@ Koha::Libraries - Koha Library Object set class sub search_filtered { my ( $self, $params, $attributes ) = @_; - if ( C4::Context->preference('IndependentBranches') - and C4::Context->userenv - and not C4::Context->IsSuperLibrarian() - and C4::Context->userenv->{branch} - ) { + if ( C4::Context::only_my_library ) { $params->{branchcode} = C4::Context->userenv->{branch}; } diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl index 8217b8da7a..9b745b4477 100755 --- a/admin/smart-rules.pl +++ b/admin/smart-rules.pl @@ -58,7 +58,7 @@ unless ( $branch ) { $branch = Koha::Libraries->search->count() == 1 ? undef : C4::Context::mybranch(); } else { - $branch = C4::Branch::onlymine() ? ( C4::Context::mybranch() || '*' ) : '*'; + $branch = C4::Context::only_my_library() ? ( C4::Context::mybranch() || '*' ) : '*'; } } $branch = '*' if $branch eq 'NO_LIBRARY_SET'; diff --git a/circ/overdue.pl b/circ/overdue.pl index c76b52991a..57865dd221 100755 --- a/circ/overdue.pl +++ b/circ/overdue.pl @@ -89,13 +89,6 @@ while (my ($itemtype, $description) =$req->fetchrow) { itemtypename => $description, }; } -my $onlymine = - C4::Context->preference('IndependentBranches') - && C4::Context->userenv - && !C4::Context->IsSuperLibrarian() - && C4::Context->userenv->{branch}; - -$branchfilter = C4::Context->userenv->{'branch'} if ($onlymine && !$branchfilter); # Filtering by Patron Attributes # @patron_attr_filter_loop is non empty if there are any patron attribute filters diff --git a/members/member.pl b/members/member.pl index 604d0290e6..93996ddc94 100755 --- a/members/member.pl +++ b/members/member.pl @@ -49,7 +49,7 @@ my $quicksearch = $input->param('quicksearch') // 0; if ( $quicksearch and $searchmember ) { my $branchcode; - if ( C4::Branch::onlymine ) { + if ( C4::Context::only_my_library ) { my $userenv = C4::Context->userenv; $branchcode = $userenv->{'branch'}; } -- 2.39.5