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

(-)a/Koha/Patron.pm (-9 / +9 lines)
Lines 2238-2266 sub add_extended_attribute { Link Here
2238
    my ( $self, $attribute ) = @_;
2238
    my ( $self, $attribute ) = @_;
2239
2239
2240
    my $change;
2240
    my $change;
2241
    if (C4::Context->preference("BorrowersLog")) {
2241
    if ( C4::Context->preference("BorrowersLog") ) {
2242
        my @attribute_values_before = map { $_->attribute }
2242
        my @attribute_values_before =
2243
            $self->extended_attributes->search({ 'me.code' => $attribute->{code} })->as_list;
2243
            map { $_->attribute } $self->extended_attributes->search( { 'me.code' => $attribute->{code} } )->as_list;
2244
        my @attribute_values_after = sort ($attribute->{attribute}, @attribute_values_before);
2244
        my @attribute_values_after = sort ( $attribute->{attribute}, @attribute_values_before );
2245
        $change = {
2245
        $change = {
2246
            before => \@attribute_values_before,
2246
            before => \@attribute_values_before,
2247
            after => \@attribute_values_after
2247
            after  => \@attribute_values_after
2248
        }
2248
        };
2249
    }
2249
    }
2250
2250
2251
    my $added_attribute =  Koha::Patron::Attribute->new(
2251
    my $added_attribute = Koha::Patron::Attribute->new(
2252
        {
2252
        {
2253
            %{$attribute},
2253
            %{$attribute},
2254
            ( borrowernumber => $self->borrowernumber ),
2254
            ( borrowernumber => $self->borrowernumber ),
2255
        }
2255
        }
2256
    )->store;
2256
    )->store;
2257
2257
2258
    if (C4::Context->preference("BorrowersLog")) {
2258
    if ( C4::Context->preference("BorrowersLog") ) {
2259
        logaction(
2259
        logaction(
2260
            "MEMBERS",
2260
            "MEMBERS",
2261
            "MODIFY",
2261
            "MODIFY",
2262
            $self->borrowernumber,
2262
            $self->borrowernumber,
2263
            "Patron attribute " . $attribute->{code} . ": " . to_json($change, { pretty => 1, canonical => 1 })
2263
            "Patron attribute " . $attribute->{code} . ": " . to_json( $change, { pretty => 1, canonical => 1 } )
2264
        );
2264
        );
2265
    }
2265
    }
2266
2266
(-)a/t/db_dependent/Koha/Patron/Attribute.t (-4 / +4 lines)
Lines 743-755 subtest 'action log tests' => sub { Link Here
743
743
744
    my $attribute = {
744
    my $attribute = {
745
        attribute => 'Qux',
745
        attribute => 'Qux',
746
        code => $attribute_type->code,
746
        code      => $attribute_type->code,
747
    };
747
    };
748
    $patron->add_extended_attribute($attribute);
748
    $patron->add_extended_attribute($attribute);
749
749
750
    $info = $get_info->(
750
    $info = $get_info->(
751
        ['Foo', 'Bar', 'Baz'],
751
        [ 'Foo', 'Bar', 'Baz' ],
752
        ['Foo', 'Bar', 'Baz', 'Qux'],
752
        [ 'Foo', 'Bar', 'Baz', 'Qux' ],
753
        $attribute_type->code,
753
        $attribute_type->code,
754
        1
754
        1
755
    );
755
    );
Lines 758-764 subtest 'action log tests' => sub { Link Here
758
            module => "MEMBERS",
758
            module => "MEMBERS",
759
            action => "MODIFY",
759
            action => "MODIFY",
760
            object => $patron->borrowernumber,
760
            object => $patron->borrowernumber,
761
            info => $info
761
            info   => $info
762
        }
762
        }
763
    );
763
    );
764
    is(
764
    is(
(-)a/tools/modborrowers.pl (-5 / +3 lines)
Lines 445-460 if ( $op eq 'cud-do' ) { Link Here
445
445
446
            # The attribute is disabled, we remove it for this borrower !
446
            # The attribute is disabled, we remove it for this borrower !
447
            if ( !$attributes->{$code}->{disabled} ) {
447
            if ( !$attributes->{$code}->{disabled} ) {
448
                push @extended_attributes, { code => $code, attribute => $_}
448
                push @extended_attributes, { code => $code, attribute => $_ } for @{ $attributes->{$code}->{values} };
449
                    for @{ $attributes->{$code}->{values} };
450
            }
449
            }
451
450
452
        }
451
        }
453
452
454
        try {
453
        try {
455
            $patron->extended_attributes(\@extended_attributes);
454
            $patron->extended_attributes( \@extended_attributes );
456
        } catch {
455
        } catch {
457
            my $message =  blessed $_ ? $_->full_message() : $_;
456
            my $message = blessed $_ ? $_->full_message() : $_;
458
            push @errors, { error => $message };
457
            push @errors, { error => $message };
459
        };
458
        };
460
459
461
- 

Return to bug 26744