Skip to content

Commit

Permalink
[#26875895] Push check for group constraint into its own function
Browse files Browse the repository at this point in the history
  • Loading branch information
ctfliblime committed Apr 2, 2012
1 parent da353e9 commit 9703efc
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/C4/Members.pm
Expand Up @@ -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;
Expand Down

0 comments on commit 9703efc

Please sign in to comment.