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

(-)a/C4/Auth.pm (-4 / +4 lines)
Lines 995-1006 sub checkauth { Link Here
995
                        # doesn't have a userid. So if there is none, we pass along the
995
                        # doesn't have a userid. So if there is none, we pass along the
996
                        # borrower number, and the bits of code that need to know the user
996
                        # borrower number, and the bits of code that need to know the user
997
                        # ID will have to be smart enough to handle that.
997
                        # ID will have to be smart enough to handle that.
998
                        require C4::Members;
998
                        my $patrons = Koha::Patrons->search({ email => $value });
999
                        my @users_info = C4::Members::GetBorrowersWithEmail($value);
999
                        if ($patrons->count) {
1000
                        if (@users_info) {
1001
1000
1002
                            # First the userid, then the borrowernum
1001
                            # First the userid, then the borrowernum
1003
                            $value = $users_info[0][1] || $users_info[0][0];
1002
                            my $patron = $patrons->next;
1003
                            $value = $patron->userid || $patron->borrowernumber;
1004
                        } else {
1004
                        } else {
1005
                            undef $value;
1005
                            undef $value;
1006
                        }
1006
                        }
(-)a/C4/Members.pm (-29 lines)
Lines 74-80 BEGIN { Link Here
74
        &GetBorrowersToExpunge
74
        &GetBorrowersToExpunge
75
75
76
        &IssueSlip
76
        &IssueSlip
77
        GetBorrowersWithEmail
78
77
79
        GetOverduesForPatron
78
        GetOverduesForPatron
80
    );
79
    );
Lines 1240-1272 sub IssueSlip { Link Here
1240
    );
1239
    );
1241
}
1240
}
1242
1241
1243
=head2 GetBorrowersWithEmail
1244
1245
    ([$borrnum,$userid], ...) = GetBorrowersWithEmail('me@example.com');
1246
1247
This gets a list of users and their basic details from their email address.
1248
As it's possible for multiple user to have the same email address, it provides
1249
you with all of them. If there is no userid for the user, there will be an
1250
C<undef> there. An empty list will be returned if there are no matches.
1251
1252
=cut
1253
1254
sub GetBorrowersWithEmail {
1255
    my $email = shift;
1256
1257
    my $dbh = C4::Context->dbh;
1258
1259
    my $query = "SELECT borrowernumber, userid FROM borrowers WHERE email=?";
1260
    my $sth=$dbh->prepare($query);
1261
    $sth->execute($email);
1262
    my @result = ();
1263
    while (my $ref = $sth->fetch) {
1264
        push @result, $ref;
1265
    }
1266
    die "Failure searching for borrowers by email address: $sth->errstr" if $sth->err;
1267
    return @result;
1268
}
1269
1270
=head2 AddMember_Auto
1242
=head2 AddMember_Auto
1271
1243
1272
=cut
1244
=cut
1273
- 

Return to bug 17554