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

(-)a/C4/Auth.pm (-4 / +4 lines)
Lines 968-979 sub checkauth { Link Here
968
                        # doesn't have a userid. So if there is none, we pass along the
968
                        # doesn't have a userid. So if there is none, we pass along the
969
                        # borrower number, and the bits of code that need to know the user
969
                        # borrower number, and the bits of code that need to know the user
970
                        # ID will have to be smart enough to handle that.
970
                        # ID will have to be smart enough to handle that.
971
                        require C4::Members;
971
                        my $patrons = Koha::Patrons->search({ email => $value });
972
                        my @users_info = C4::Members::GetBorrowersWithEmail($value);
972
                        if ($patrons->count) {
973
                        if (@users_info) {
974
973
975
                            # First the userid, then the borrowernum
974
                            # First the userid, then the borrowernum
976
                            $value = $users_info[0][1] || $users_info[0][0];
975
                            my $patron = $patrons->next;
976
                            $value = $patron->userid || $patron->borrowernumber;
977
                        } else {
977
                        } else {
978
                            undef $value;
978
                            undef $value;
979
                        }
979
                        }
(-)a/C4/Members.pm (-29 lines)
Lines 79-85 BEGIN { Link Here
79
        &GetUpcomingMembershipExpires
79
        &GetUpcomingMembershipExpires
80
80
81
        &IssueSlip
81
        &IssueSlip
82
        GetBorrowersWithEmail
83
82
84
        GetOverduesForPatron
83
        GetOverduesForPatron
85
    );
84
    );
Lines 1414-1446 sub IssueSlip { Link Here
1414
    );
1413
    );
1415
}
1414
}
1416
1415
1417
=head2 GetBorrowersWithEmail
1418
1419
    ([$borrnum,$userid], ...) = GetBorrowersWithEmail('me@example.com');
1420
1421
This gets a list of users and their basic details from their email address.
1422
As it's possible for multiple user to have the same email address, it provides
1423
you with all of them. If there is no userid for the user, there will be an
1424
C<undef> there. An empty list will be returned if there are no matches.
1425
1426
=cut
1427
1428
sub GetBorrowersWithEmail {
1429
    my $email = shift;
1430
1431
    my $dbh = C4::Context->dbh;
1432
1433
    my $query = "SELECT borrowernumber, userid FROM borrowers WHERE email=?";
1434
    my $sth=$dbh->prepare($query);
1435
    $sth->execute($email);
1436
    my @result = ();
1437
    while (my $ref = $sth->fetch) {
1438
        push @result, $ref;
1439
    }
1440
    die "Failure searching for borrowers by email address: $sth->errstr" if $sth->err;
1441
    return @result;
1442
}
1443
1444
=head2 AddMember_Opac
1416
=head2 AddMember_Opac
1445
1417
1446
=cut
1418
=cut
1447
- 

Return to bug 17554