Bug 15758: Koha::Libraries - Move onlymine to C4::Context::only_my_library
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 5 Feb 2016 12:30:29 +0000 (12:30 +0000)
committerKyle M Hall <kyle@bywatersolutions.com>
Thu, 8 Sep 2016 14:36:04 +0000 (14:36 +0000)
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
C4/Branch.pm
C4/Context.pm
C4/Utils/DataTables/Members.pm
Koha/Libraries.pm
admin/smart-rules.pl
circ/overdue.pl
members/member.pl

index a4f6b2f..1c912ab 100644 (file)
@@ -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 );
index 87242d3..c84230d 100644 (file)
@@ -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__
index a215006..958e921 100644 (file)
@@ -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'};
 
index fefc3ab..fa2bf17 100644 (file)
@@ -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};
     }
 
index 8217b8d..9b745b4 100755 (executable)
@@ -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';
index c76b529..57865dd 100755 (executable)
@@ -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
index 604d029..93996dd 100755 (executable)
@@ -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'};
     }