View | Details | Raw Unified | Return to bug 18403
Collapse All | Expand All

(-)a/Koha/Patrons.pm (+35 lines)
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.
(-)a/circ/ysearch.pl (-1 / +1 lines)
Lines 67-73 foreach my $p (@parts) { Link Here
67
67
68
push( @params, { branchcode => C4::Context->userenv->{branch} } ) if $limit_on_branch;
68
push( @params, { branchcode => C4::Context->userenv->{branch} } ) if $limit_on_branch;
69
69
70
my $borrowers_rs = Koha::Patrons->search(
70
my $borrowers_rs = Koha::Patrons->search_limited(
71
    { -and => \@params },
71
    { -and => \@params },
72
    {
72
    {
73
        # Get the first 10 results
73
        # Get the first 10 results
(-)a/members/memberentry.pl (-1 / +1 lines)
Lines 241-247 if ( ( $op eq 'insert' ) and !$nodouble ) { Link Here
241
        $conditions->{dateofbirth} = $newdata{dateofbirth} if $newdata{dateofbirth};
241
        $conditions->{dateofbirth} = $newdata{dateofbirth} if $newdata{dateofbirth};
242
    }
242
    }
243
    $nodouble = 1;
243
    $nodouble = 1;
244
    my $patrons = Koha::Patrons->search($conditions);
244
    my $patrons = Koha::Patrons->search($conditions); # FIXME Should be search_limited?
245
    if ( $patrons->count > 0) {
245
    if ( $patrons->count > 0) {
246
        $nodouble = 0;
246
        $nodouble = 0;
247
        $check_member = $patrons->next->borrowernumber;
247
        $check_member = $patrons->next->borrowernumber;
(-)a/opac/opac-memberentry.pl (-2 / +1 lines)
Lines 391-397 sub CheckForInvalidFields { Link Here
391
        unless ( Email::Valid->address($borrower->{'email'}) ) {
391
        unless ( Email::Valid->address($borrower->{'email'}) ) {
392
            push(@invalidFields, "email");
392
            push(@invalidFields, "email");
393
        } elsif ( C4::Context->preference("PatronSelfRegistrationEmailMustBeUnique") ) {
393
        } elsif ( C4::Context->preference("PatronSelfRegistrationEmailMustBeUnique") ) {
394
            my $patrons_with_same_email = Koha::Patrons->search( { email => $borrower->{email} })->count;
394
            my $patrons_with_same_email = Koha::Patrons->search( { email => $borrower->{email} })->count; # FIXME Should be search_limited?
395
            if ( $patrons_with_same_email ) {
395
            if ( $patrons_with_same_email ) {
396
                push @invalidFields, "duplicate_email";
396
                push @invalidFields, "duplicate_email";
397
            }
397
            }
398
- 

Return to bug 18403