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

(-)a/Koha/Patron.pm (-37 / +33 lines)
Lines 2387-2433 sub extended_attributes { Link Here
2387
                    }
2387
                    }
2388
                }
2388
                }
2389
2389
2390
                if (%changed_attributes_codes) {
2390
                # Store changed attributes in the order they where passed in as some tests
2391
2391
                # relies on ids being assigned in that order
2392
                    # Store changed attributes in the order they where passed in as some tests
2392
                my $new_types = {};
2393
                    # relies on ids being assigned in that order
2393
                for my $new_attribute (@new_attributes) {
2394
                    my $new_types = {};
2394
                    $new_attribute->store() if $changed_attributes_codes{ $new_attribute->code };
2395
                    for my $new_attribute (@new_attributes) {
2395
                    $new_types->{ $new_attribute->code } = 1;
2396
                        $new_attribute->store() if $changed_attributes_codes{ $new_attribute->code };
2396
                }
2397
                        $new_types->{ $new_attribute->code } = 1;
2398
                    }
2399
2397
2400
                    # Check globally mandatory types
2398
                # Check globally mandatory types
2401
                    my $interface = C4::Context->interface;
2399
                my $interface = C4::Context->interface;
2402
                    my $params    = {
2400
                my $params    = {
2403
                        mandatory                                        => 1,
2401
                    mandatory                                        => 1,
2404
                        category_code                                    => [ undef, $self->categorycode ],
2402
                    category_code                                    => [ undef, $self->categorycode ],
2405
                        'borrower_attribute_types_branches.b_branchcode' => undef,
2403
                    'borrower_attribute_types_branches.b_branchcode' => undef,
2406
                    };
2404
                };
2407
2405
2408
                    if ( $interface eq 'opac' ) {
2406
                if ( $interface eq 'opac' ) {
2409
                        $params->{opac_editable} = 1;
2407
                    $params->{opac_editable} = 1;
2410
                    }
2408
                }
2411
2409
2412
                    my @required_attribute_types = Koha::Patron::Attribute::Types->search(
2410
                my @required_attribute_types = Koha::Patron::Attribute::Types->search(
2413
                        $params,
2411
                    $params,
2414
                        { join => 'borrower_attribute_types_branches' }
2412
                    { join => 'borrower_attribute_types_branches' }
2415
                    )->get_column('code');
2413
                )->get_column('code');
2416
2414
2417
                    for my $type (@required_attribute_types) {
2415
                for my $type (@required_attribute_types) {
2418
                        Koha::Exceptions::Patron::MissingMandatoryExtendedAttribute->throw(
2416
                    Koha::Exceptions::Patron::MissingMandatoryExtendedAttribute->throw(
2419
                            type => $type,
2417
                        type => $type,
2420
                        ) if !$new_types->{$type};
2418
                    ) if !$new_types->{$type};
2421
                    }
2419
                }
2422
2420
2423
                    if ( %{$all_changes} ) {
2421
                if ( %{$all_changes} ) {
2424
                        logaction(
2422
                    logaction(
2425
                            "MEMBERS",
2423
                        "MEMBERS",
2426
                            "MODIFY",
2424
                        "MODIFY",
2427
                            $self->borrowernumber,
2425
                        $self->borrowernumber,
2428
                            to_json( $all_changes, { pretty => 1, canonical => 1 } )
2426
                        to_json( $all_changes, { pretty => 1, canonical => 1 } )
2429
                        );
2427
                    );
2430
                    }
2431
                }
2428
                }
2432
            }
2429
            }
2433
        );
2430
        );
2434
- 

Return to bug 39970