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 1245-1277 sub IssueSlip { Link Here
1245
    );
1244
    );
1246
}
1245
}
1247
1246
1248
=head2 GetBorrowersWithEmail
1249
1250
    ([$borrnum,$userid], ...) = GetBorrowersWithEmail('me@example.com');
1251
1252
This gets a list of users and their basic details from their email address.
1253
As it's possible for multiple user to have the same email address, it provides
1254
you with all of them. If there is no userid for the user, there will be an
1255
C<undef> there. An empty list will be returned if there are no matches.
1256
1257
=cut
1258
1259
sub GetBorrowersWithEmail {
1260
    my $email = shift;
1261
1262
    my $dbh = C4::Context->dbh;
1263
1264
    my $query = "SELECT borrowernumber, userid FROM borrowers WHERE email=?";
1265
    my $sth=$dbh->prepare($query);
1266
    $sth->execute($email);
1267
    my @result = ();
1268
    while (my $ref = $sth->fetch) {
1269
        push @result, $ref;
1270
    }
1271
    die "Failure searching for borrowers by email address: $sth->errstr" if $sth->err;
1272
    return @result;
1273
}
1274
1275
=head2 AddMember_Auto
1247
=head2 AddMember_Auto
1276
1248
1277
=cut
1249
=cut
1278
- 

Return to bug 17554