Bugzilla – Attachment 13241 Details for
Bug 8919
ExtendedPatronAttributes not populated from LDAP
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8919 - ExtendedPatronAttributes not populated from LDAP
Bug-8919---ExtendedPatronAttributes-not-populated-.patch (text/plain), 2.32 KB, created by
Chris Cormack
on 2012-11-04 08:13:42 UTC
(
hide
)
Description:
Bug 8919 - ExtendedPatronAttributes not populated from LDAP
Filename:
MIME Type:
Creator:
Chris Cormack
Created:
2012-11-04 08:13:42 UTC
Size:
2.32 KB
patch
obsolete
>From 9ae1328f6922e877f8c8913faa8e57e2c783f2e4 Mon Sep 17 00:00:00 2001 >From: Dobrica Pavlinusic <dpavlin@rot13.org> >Date: Mon, 15 Oct 2012 14:55:05 +0200 >Subject: [PATCH] Bug 8919 - ExtendedPatronAttributes not populated from LDAP > >Current code is overly complex and assumes that >C4::Members::AttributeTypes::GetAttributeTypes >returns array of attribute codes which is not true. > >Instead it return array of hashes so none of extended attributes >will be replicated from LDAP. > >This code correctly extracts extended attributes from borrower data >provides simpler code which fills same structure. > >It also skips empty values (" ") which are result of mapping without >any default value. This is needed to make unique extended patron values >work. If not handled it would insert empty value for first user and >fail for all others on uniqueness constraint. > >Test scenario: > >1. define Patron attribute types in administration >2. define mapping from LDAP fields to attributes in koha-conf.xml >3. login as new user with LDAP fields and verify that extended > attributes are replicated from LDAP > >Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> >--- > C4/Auth_with_ldap.pm | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > >diff --git a/C4/Auth_with_ldap.pm b/C4/Auth_with_ldap.pm >index 2f2bb27..f3c1f7f 100644 >--- a/C4/Auth_with_ldap.pm >+++ b/C4/Auth_with_ldap.pm >@@ -169,11 +169,13 @@ sub checkpw_ldap { > return 0; # B2, D2 > } > if (C4::Context->preference('ExtendedPatronAttributes') && $borrowernumber && ($config{update} ||$config{replicate})) { >- my @types = C4::Members::AttributeTypes::GetAttributeTypes(); >- my @attributes = grep{my $key=$_; any{$_ eq $key}@types;} keys %borrower; > my $extended_patron_attributes; >- @{$extended_patron_attributes} = >- map { { code => $_, value => $borrower{$_} } } @attributes; >+ foreach my $attribute_type ( C4::Members::AttributeTypes::GetAttributeTypes() ) { >+ my $code = $attribute_type->{code}; >+ if ( exists($borrower{$code}) && $borrower{$code} !~ m/^\s*$/ ) { # skip empty values >+ push @$extended_patron_attributes, { code => $code, value => $borrower{$code} }; >+ } >+ } > my @errors; > #Check before add > for (my $i; $i< scalar(@$extended_patron_attributes)-1;$i++) { >-- >1.7.10.4
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 8919
:
12814
|
12848
|
12868
| 13241