|
Lines 41-46
Koha::Patron - Koha Patron Object class
Link Here
|
| 41 |
|
41 |
|
| 42 |
=cut |
42 |
=cut |
| 43 |
|
43 |
|
|
|
44 |
=head3 search_limited |
| 45 |
|
| 46 |
my $patrons = Koha::Patrons->search_limit( $params, $attributes ); |
| 47 |
|
| 48 |
Returns all the patrons the logged in user is allowed to see |
| 49 |
|
| 50 |
=cut |
| 51 |
|
| 52 |
sub search_limited { |
| 53 |
my ( $self, $params, $attributes ) = @_; |
| 54 |
|
| 55 |
my $userenv = C4::Context->userenv; |
| 56 |
my @restricted_branchcodes; |
| 57 |
my $logged_in_user = Koha::Patrons->find( $userenv->{number} ); |
| 58 |
if ( $logged_in_user and not |
| 59 |
$logged_in_user->can( |
| 60 |
{ borrowers => 'view_borrower_infos_from_any_libraries' } |
| 61 |
) |
| 62 |
) |
| 63 |
{ |
| 64 |
if ( my $library_groups = $logged_in_user->library->library_groups ) |
| 65 |
{ |
| 66 |
while ( my $library_group = $library_groups->next ) { |
| 67 |
push @restricted_branchcodes, |
| 68 |
$library_group->parent->children->get_column('branchcode'); |
| 69 |
} |
| 70 |
} |
| 71 |
else { |
| 72 |
push @restricted_branchcodes, $userenv->{branch}; |
| 73 |
} |
| 74 |
} |
| 75 |
$params->{'me.branchcode'} = { -in => \@restricted_branchcodes } if @restricted_branchcodes; |
| 76 |
return $self->search( $params, $attributes ); |
| 77 |
} |
| 78 |
|
| 44 |
=head3 search_housebound_choosers |
79 |
=head3 search_housebound_choosers |
| 45 |
|
80 |
|
| 46 |
Returns all Patrons which are Housebound choosers. |
81 |
Returns all Patrons which are Housebound choosers. |