Bugzilla – Attachment 101135 Details for
Bug 20443
Move C4::Members::Attributes to Koha namespace
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20443: Remove SearchIdMatchingAttribute - prove we are not cheating
Bug-20443-Remove-SearchIdMatchingAttribute---prove.patch (text/plain), 2.45 KB, created by
Jonathan Druart
on 2020-03-20 14:47:45 UTC
(
hide
)
Description:
Bug 20443: Remove SearchIdMatchingAttribute - prove we are not cheating
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-03-20 14:47:45 UTC
Size:
2.45 KB
patch
obsolete
>From c8fd9d667facca3e38ffe487c68b002f77697418 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 16 Jul 2018 20:34:42 -0300 >Subject: [PATCH] Bug 20443: Remove SearchIdMatchingAttribute - prove we are > not cheating > >Tests are still passing that way, we can continue > >Signed-off-by: Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > C4/Members/Attributes.pm | 17 ++++------------- > Koha/Patrons.pm | 21 +++++++++++++++++++++ > 2 files changed, 25 insertions(+), 13 deletions(-) > >diff --git a/C4/Members/Attributes.pm b/C4/Members/Attributes.pm >index 17c6286626..19b5b9e6ef 100644 >--- a/C4/Members/Attributes.pm >+++ b/C4/Members/Attributes.pm >@@ -51,21 +51,12 @@ C4::Members::Attributes - manage extend patron attributes > my $matching_borrowernumbers = C4::Members::Attributes::SearchIdMatchingAttribute($filter); > > =cut >- >+use Koha::Patrons; > sub SearchIdMatchingAttribute{ > my $filter = shift; >- $filter = [$filter] unless ref $filter; >- >- my $dbh = C4::Context->dbh(); >- my $query = qq{ >-SELECT DISTINCT borrowernumber >-FROM borrower_attributes >-JOIN borrower_attribute_types USING (code) >-WHERE staff_searchable = 1 >-AND (} . join (" OR ", map "attribute like ?", @$filter) .qq{)}; >- my $sth = $dbh->prepare_cached($query); >- $sth->execute(map "%$_%", @$filter); >- return [map $_->[0], @{ $sth->fetchall_arrayref }]; >+ >+ my @borrowernumbers = Koha::Patrons->filter_by_attribute_value($filter)->get_column('borrowernumber'); >+ return \@borrowernumbers; > } > > =head2 extended_attributes_code_value_arrayref >diff --git a/Koha/Patrons.pm b/Koha/Patrons.pm >index ce732e00d4..0b65756945 100644 >--- a/Koha/Patrons.pm >+++ b/Koha/Patrons.pm >@@ -442,6 +442,27 @@ sub filter_by_attribute_type { > return Koha::Patrons->_new_from_dbic($rs); > } > >+=head3 filter_by_attribute_value >+ >+my $patrons = Koha::Patrons->filter_by_attribute_value($attribute_value); >+ >+Return a Koha::Patrons set with patrong having the attribute value passed in paramter. >+ >+=cut >+ >+sub filter_by_attribute_value { >+ my ( $self, $attribute_value ) = @_; >+ my $rs = Koha::Patron::Attributes->search( >+ { >+ 'borrower_attribute_types.staff_searchable' => 1, >+ attribute => { like => "%$attribute_value%" } >+ }, >+ { join => 'borrower_attribute_types' } >+ )->_resultset()->search_related('borrowernumber'); >+ return Koha::Patrons->_new_from_dbic($rs); >+} >+ >+ > =head3 _type > > =cut >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 20443
:
101122
|
101123
|
101124
|
101125
|
101126
|
101127
|
101128
|
101129
|
101130
|
101131
|
101132
|
101133
|
101134
|
101135
|
101136
|
101137
|
101138
|
101139
|
101140
|
101141
|
101142
|
101143
|
101144
|
101145
|
101146
|
101147
|
101148
|
101149
|
101150
|
101209
|
101210
|
101211
|
101212
|
101213
|
101214
|
101215
|
101216
|
101217
|
101218
|
101219
|
101220
|
101221
|
101222
|
101223
|
101224
|
101225
|
101226
|
101227
|
101228
|
101229
|
101230
|
101231
|
101232
|
101233
|
101234
|
101235
|
101236
|
101237
|
101472
|
104519