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> Passed-QA-by: Paul Poulain <paul.poulain@biblibre.com> Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
This commit is contained in:
parent
612fa3f158
commit
24125d4be3
1 changed files with 6 additions and 4 deletions
|
@ -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++) {
|
||||
|
|
Loading…
Reference in a new issue