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

(-)a/C4/Auth.pm (-9 / +7 lines)
Lines 966-977 sub checkauth { Link Here
966
                    # doesn't have a userid. So if there is none, we pass along the
966
                    # doesn't have a userid. So if there is none, we pass along the
967
                    # borrower number, and the bits of code that need to know the user
967
                    # borrower number, and the bits of code that need to know the user
968
                    # ID will have to be smart enough to handle that.
968
                    # ID will have to be smart enough to handle that.
969
                    require C4::Members;
969
                    my $patrons = Koha::Patrons->search({ email => $value });
970
                    my @users_info = C4::Members::GetBorrowersWithEmail($value);
970
                    if ($patrons->count) {
971
                    if (@users_info) {
971
                        my $patron = $patrons->next;
972
973
                        # First the userid, then the borrowernum
972
                        # First the userid, then the borrowernum
974
                        $value = $users_info[0][1] || $users_info[0][0];
973
                        $value = $patron->userid || $patron->borrowernumber;
975
                    }
974
                    }
976
                    else {
975
                    else {
977
                        undef $value;
976
                        undef $value;
Lines 997-1008 sub checkauth { Link Here
997
                        # doesn't have a userid. So if there is none, we pass along the
996
                        # doesn't have a userid. So if there is none, we pass along the
998
                        # borrower number, and the bits of code that need to know the user
997
                        # borrower number, and the bits of code that need to know the user
999
                        # ID will have to be smart enough to handle that.
998
                        # ID will have to be smart enough to handle that.
1000
                        require C4::Members;
999
                        my $patrons = Koha::Patrons->search({ email => $value });
1001
                        my @users_info = C4::Members::GetBorrowersWithEmail($value);
1000
                        if ($patrons->count) {
1002
                        if (@users_info) {
1003
1001
1004
                            # First the userid, then the borrowernum
1002
                            # First the userid, then the borrowernum
1005
                            $value = $users_info[0][1] || $users_info[0][0];
1003
                            $value = $patron->userid || $patron->borrowernumber;
1006
                        } else {
1004
                        } else {
1007
                            undef $value;
1005
                            undef $value;
1008
                        }
1006
                        }
(-)a/C4/Members.pm (-29 lines)
Lines 84-90 BEGIN { Link Here
84
        &GetUpcomingMembershipExpires
84
        &GetUpcomingMembershipExpires
85
85
86
        &IssueSlip
86
        &IssueSlip
87
        GetBorrowersWithEmail
88
    );
87
    );
89
88
90
    #Modify data
89
    #Modify data
Lines 1560-1592 sub IssueSlip { Link Here
1560
    );
1559
    );
1561
}
1560
}
1562
1561
1563
=head2 GetBorrowersWithEmail
1564
1565
    ([$borrnum,$userid], ...) = GetBorrowersWithEmail('me@example.com');
1566
1567
This gets a list of users and their basic details from their email address.
1568
As it's possible for multiple user to have the same email address, it provides
1569
you with all of them. If there is no userid for the user, there will be an
1570
C<undef> there. An empty list will be returned if there are no matches.
1571
1572
=cut
1573
1574
sub GetBorrowersWithEmail {
1575
    my $email = shift;
1576
1577
    my $dbh = C4::Context->dbh;
1578
1579
    my $query = "SELECT borrowernumber, userid FROM borrowers WHERE email=?";
1580
    my $sth=$dbh->prepare($query);
1581
    $sth->execute($email);
1582
    my @result = ();
1583
    while (my $ref = $sth->fetch) {
1584
        push @result, $ref;
1585
    }
1586
    die "Failure searching for borrowers by email address: $sth->errstr" if $sth->err;
1587
    return @result;
1588
}
1589
1590
=head2 AddMember_Opac
1562
=head2 AddMember_Opac
1591
1563
1592
=cut
1564
=cut
1593
- 

Return to bug 17554