Permalink
Browse files

[#26875895] Push check for group constraint into its own function

  • Loading branch information...
ctfliblime committed Mar 22, 2012
1 parent da353e9 commit 9703efc3fdd55e5ff594a96f68bce921b156c27c
Showing with 7 additions and 4 deletions.
  1. +7 −4 lib/C4/Members.pm
View
@@ -175,13 +175,16 @@ C<$count> is the number of elements in C<$borrowers>.
=cut
+sub ConstrainPatronSearch {
+ return (C4::Branch::CategoryTypeIsUsed('patrons')
+ && $ENV{REQUEST_METHOD} # need a nicer way to do this, but check if we're command line vs. CGI
+ && !C4::Auth::haspermission(undef, {superlibrarian => 1})) ? 1 : 0;
+}
+
sub _constrain_sql_by_branchcategory {
my ($query, @bind) = @_;
- if ( C4::Branch::CategoryTypeIsUsed('patrons')
- && $ENV{REQUEST_METHOD} # need a nicer way to do this, but check if we're command line vs. CGI
- && !C4::Auth::haspermission(undef, {superlibrarian => 1})
- )
+ if (ConstrainPatronSearch())
{
my $mybranch = (C4::Context->userenv) ? C4::Context->userenv->{branch} : undef;
confess 'Unable to determine selected branch' if not $mybranch;

0 comments on commit 9703efc

Please sign in to comment.