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

(-)a/C4/Members/Attributes.pm (-1 / +2 lines)
Lines 142-148 sub GetBorrowerAttributeValue { Link Here
142
=cut
142
=cut
143
143
144
sub SearchIdMatchingAttribute{
144
sub SearchIdMatchingAttribute{
145
    my $filter = shift;
145
    my ( $filter, $limit ) = @_;
146
    $filter = [$filter] unless ref $filter;
146
    $filter = [$filter] unless ref $filter;
147
147
148
    my $dbh   = C4::Context->dbh();
148
    my $dbh   = C4::Context->dbh();
Lines 152-157 FROM borrower_attributes Link Here
152
JOIN borrower_attribute_types USING (code)
152
JOIN borrower_attribute_types USING (code)
153
WHERE staff_searchable = 1
153
WHERE staff_searchable = 1
154
AND (} . join (" OR ", map "attribute like ?", @$filter) .qq{)};
154
AND (} . join (" OR ", map "attribute like ?", @$filter) .qq{)};
155
    $query .= q{ LIMIT ?} if $limit;
155
    my $sth = $dbh->prepare_cached($query);
156
    my $sth = $dbh->prepare_cached($query);
156
    $sth->execute(map "%$_%", @$filter);
157
    $sth->execute(map "%$_%", @$filter);
157
    return [map $_->[0], @{ $sth->fetchall_arrayref }];
158
    return [map $_->[0], @{ $sth->fetchall_arrayref }];
(-)a/C4/Utils/DataTables/Members.pm (-2 / +5 lines)
Lines 121-127 sub search { Link Here
121
        }
121
        }
122
122
123
        if ( $searchfieldstype eq 'standard' and C4::Context->preference('ExtendedPatronAttributes') and $searchmember ) {
123
        if ( $searchfieldstype eq 'standard' and C4::Context->preference('ExtendedPatronAttributes') and $searchmember ) {
124
            my $matching_borrowernumbers = C4::Members::Attributes::SearchIdMatchingAttribute($searchmember);
124
            # 100 is hardcoded here, it could be moved to a pref is necessary
125
            # The borrowernumbers returned by this subroutine will be concatenated to produce another SQL query
126
            # We do not want to generate a very long query as it could overload the server if the user searches
127
            # for something too generic (% for instance)
128
            my $matching_borrowernumbers = C4::Members::Attributes::SearchIdMatchingAttribute($searchmember, 100);
125
129
126
            for my $borrowernumber ( @$matching_borrowernumbers ) {
130
            for my $borrowernumber ( @$matching_borrowernumbers ) {
127
                push @where_strs_or, "borrowers.borrowernumber = ?";
131
                push @where_strs_or, "borrowers.borrowernumber = ?";
128
- 

Return to bug 1707