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

(-)a/C4/Auth.pm (-4 / +3 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
                            $value = $patron->userid || $patron->borrowernumber;
977
                        } else {
976
                        } else {
978
                            undef $value;
977
                            undef $value;
979
                        }
978
                        }
(-)a/C4/Members.pm (-29 lines)
Lines 82-88 BEGIN { Link Here
82
        &GetUpcomingMembershipExpires
82
        &GetUpcomingMembershipExpires
83
83
84
        &IssueSlip
84
        &IssueSlip
85
        GetBorrowersWithEmail
86
85
87
        GetOverduesForPatron
86
        GetOverduesForPatron
88
    );
87
    );
Lines 1589-1621 sub IssueSlip { Link Here
1589
    );
1588
    );
1590
}
1589
}
1591
1590
1592
=head2 GetBorrowersWithEmail
1593
1594
    ([$borrnum,$userid], ...) = GetBorrowersWithEmail('me@example.com');
1595
1596
This gets a list of users and their basic details from their email address.
1597
As it's possible for multiple user to have the same email address, it provides
1598
you with all of them. If there is no userid for the user, there will be an
1599
C<undef> there. An empty list will be returned if there are no matches.
1600
1601
=cut
1602
1603
sub GetBorrowersWithEmail {
1604
    my $email = shift;
1605
1606
    my $dbh = C4::Context->dbh;
1607
1608
    my $query = "SELECT borrowernumber, userid FROM borrowers WHERE email=?";
1609
    my $sth=$dbh->prepare($query);
1610
    $sth->execute($email);
1611
    my @result = ();
1612
    while (my $ref = $sth->fetch) {
1613
        push @result, $ref;
1614
    }
1615
    die "Failure searching for borrowers by email address: $sth->errstr" if $sth->err;
1616
    return @result;
1617
}
1618
1619
=head2 AddMember_Opac
1591
=head2 AddMember_Opac
1620
1592
1621
=cut
1593
=cut
1622
- 

Return to bug 17554