[Koha-patches] [PATCH 03/11] Auth_with_ldap : removing warnings
paul.poulain at biblibre.com
paul.poulain at biblibre.com
Wed Jan 19 21:24:35 CET 2011
From: Henri-Damien LAURENT <henridamien.laurent at biblibre.com>
Removing warnings in C4/Auth_with_ldap
extended_patron_attributes was defined twice
---
C4/Auth_with_ldap.pm | 48 ++++++++++++++++++++++++++----------------------
1 files changed, 26 insertions(+), 22 deletions(-)
diff --git a/C4/Auth_with_ldap.pm b/C4/Auth_with_ldap.pm
index b25697c..6ca33ae 100644
--- a/C4/Auth_with_ldap.pm
+++ b/C4/Auth_with_ldap.pm
@@ -159,29 +159,33 @@ sub checkpw_ldap {
}
} elsif ($config{replicate}) { # A2, C2
$borrowernumber = AddMember(%borrower) or die "AddMember failed";
- } else {
- return 0; # B2, D2
+ } else {
+ 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 = map { { code => $_, value => $borrower{$_} } } @attributes;
+ $extended_patron_attributes = [] unless $extended_patron_attributes;
+ my @errors;
+
+ #Check before add
+ for ( my $i ; $i < scalar(@$extended_patron_attributes) - 1 ; $i++ ) {
+ my $attr = $extended_patron_attributes->[$i];
+ unless ( C4::Members::Attributes::CheckUniqueness( $attr->{code}, $attr->{value}, $borrowernumber ) ) {
+ unshift @errors, $i;
+ }
+ }
+
+ #Removing erroneous attributes
+ foreach my $index (@errors) {
+ @$extended_patron_attributes = splice( @$extended_patron_attributes, $index, 1 );
+ }
+ C4::Members::Attributes::SetBorrowerAttributes( $borrowernumber, $extended_patron_attributes );
}
- 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 = map{{code=>$_,value=>$borrower{$_}}}@attributes;
- my $extended_patron_attributes = [] unless $extended_patron_attributes;
- my @errors;
- #Check before add
- for (my $i; $i< scalar(@$extended_patron_attributes)-1;$i++) {
- my $attr=$extended_patron_attributes->[$i];
- unless (C4::Members::Attributes::CheckUniqueness($attr->{code}, $attr->{value}, $borrowernumber)) {
- unshift @errors, $i;
- warn "ERROR_extended_unique_id_failed $attr->{code} $attr->{value}";
- }
- }
- #Removing erroneous attributes
- foreach my $index (@errors){
- @$extended_patron_attributes=splice(@$extended_patron_attributes,$index,1);
- }
- C4::Members::Attributes::SetBorrowerAttributes($borrowernumber, $extended_patron_attributes);
- }
return(1, $cardnumber);
}
--
1.7.1
More information about the Koha-patches
mailing list