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

(-)a/C4/Auth_with_ldap.pm (-12 / +15 lines)
Lines 233-251 sub checkpw_ldap { Link Here
233
    if (C4::Context->preference('ExtendedPatronAttributes') && $borrowernumber && ($config{update} ||$config{replicate})) {
233
    if (C4::Context->preference('ExtendedPatronAttributes') && $borrowernumber && ($config{update} ||$config{replicate})) {
234
        my $library_id = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
234
        my $library_id = C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef;
235
        my $attribute_types = Koha::Patron::Attribute::Types->search_with_library_limits({}, {}, $library_id);
235
        my $attribute_types = Koha::Patron::Attribute::Types->search_with_library_limits({}, {}, $library_id);
236
        while ( my $attribute_type = $attribute_types->next ) {
236
        my $patron = Koha::Patrons->find($borrowernumber);
237
            my $code = $attribute_type->code;
237
        if ( $patron ) {
238
            unless (exists($borrower{$code}) && $borrower{$code} !~ m/^\s*$/ ) {
238
            my @attributes;
239
                next;
239
            while ( my $attribute_type = $attribute_types->next ) {
240
            }
240
241
            my $patron = Koha::Patrons->find($borrowernumber);
241
                my $code = $attribute_type->code;
242
            if ( $patron ) { # Should not be needed, but we are in C4::Auth LDAP...
242
                unless (exists($borrower{$code}) && $borrower{$code} !~ m/^\s*$/ ) {
243
                    next;
244
                }
245
246
                # "repeatable" not supported
243
                eval {
247
                eval {
244
                    my $attribute = Koha::Patron::Attribute->new({code => $code, attribute => $borrower{$code}});
248
                    $patron->extended_attributes->search({ 'me.code' => $code })->filter_by_branch_limitations->delete;
245
                    $patron->extended_attributes([$attribute->unblessed]);
249
                    $patron->add_extended_attribute({ code => $code, attribute => $borrower{$code} });
246
                };
250
                };
247
                if ($@) { # FIXME Test if Koha::Exceptions::Patron::Attribute::NonRepeatable
251
                if ($@){
248
                    warn "ERROR_extended_unique_id_failed $code $borrower{$code}";
252
                    warn sprintf "ERROR update extended attribute %s %s for patron %s (%s)",  $code, $borrower{$code}, $patron->borrowernumber, $@;
249
                }
253
                }
250
            }
254
            }
251
        }
255
        }
252
- 

Return to bug 27957