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

(-)a/C4/Log.pm (+2 lines)
Lines 124-129 sub logaction { Link Here
124
    $diff //= encode_json( diff( $original, $updated, noU => 1 ) )
124
    $diff //= encode_json( diff( $original, $updated, noU => 1 ) )
125
        if $original && ref $updated eq 'HASH';
125
        if $original && ref $updated eq 'HASH';
126
126
127
    $infos = Data::Dumper::Dumper( $infos ) if ref $infos;
128
127
    Koha::ActionLog->new(
129
    Koha::ActionLog->new(
128
        {
130
        {
129
            timestamp => \'NOW()',
131
            timestamp => \'NOW()',
(-)a/Koha/AuthorisedValue.pm (-5 / +54 lines)
Lines 51-66 AuthorisedValue specific store to ensure relevant caches are flushed on change Link Here
51
=cut
51
=cut
52
52
53
sub store {
53
sub store {
54
    my ($self) = @_;
54
    my ( $self, $branches ) = @_;
55
55
56
    my $flush = 0;
56
    my $flush = 0;
57
57
58
    my $new_authorized_value = !$self->in_storage;
58
    my $new_authorized_value = !$self->in_storage;
59
59
60
    my $original = {
61
        authorised_value => undef,
62
        id               => undef,
63
        category         => undef,
64
        library_limits   => undef,
65
        lib              => undef,
66
        lib_opac         => undef,
67
        imageurl         => undef,
68
    };
69
60
    if ( !$self->in_storage ) {
70
    if ( !$self->in_storage ) {
61
        $flush = 1;
71
        $flush = 1;
62
    }
72
    } else {
63
    else {
73
        my $original_av = Koha::AuthorisedValues->find( $self->id );
74
75
        # Fetch current library limits using get_library_limits method
76
        my $libraries = $original_av->get_library_limits();
77
78
        # Extract branch codes
79
        my @original_library_limits;
80
        if ($libraries) {
81
            while ( my $library = $libraries->next ) {
82
                push @original_library_limits, $library->branchcode;
83
            }
84
        }
85
86
        $original = {
87
            authorised_value => $original_av->authorised_value,
88
            id               => $original_av->id,
89
            category         => $original_av->category,
90
            library_limits   => \@original_library_limits,
91
            lib              => $original_av->lib,
92
            lib_opac         => $original_av->lib_opac,
93
            imageurl         => $original_av->imageurl
94
        };
95
64
        my %updated_columns = $self->_result->get_dirty_columns;
96
        my %updated_columns = $self->_result->get_dirty_columns;
65
97
66
        if (   exists $updated_columns{lib}
98
        if (   exists $updated_columns{lib}
Lines 75-86 sub store { Link Here
75
    $self = $self->SUPER::store;
107
    $self = $self->SUPER::store;
76
108
77
    if ( C4::Context->preference("AuthorizedValuesLog") ) {
109
    if ( C4::Context->preference("AuthorizedValuesLog") ) {
110
        $self->replace_library_limits($branches);
78
        my $action = $new_authorized_value ? 'CREATE' : 'MODIFY';
111
        my $action = $new_authorized_value ? 'CREATE' : 'MODIFY';
79
        logaction( 'AUTHORIZEDVALUE', $action, $self->id, $self );
112
113
        logaction(
114
            'AUTHORIZEDVALUE',
115
            $action,
116
            $self->id,
117
            {
118
                authorised_value => $self->authorised_value,
119
                id               => $self->id,
120
                category         => $self->category,
121
                library_limits   => $branches,
122
                lib              => $self->lib,
123
                lib_opac         => $self->lib_opac,
124
                imageurl         => $self->imageurl
125
            },
126
            undef,
127
            $original
128
        );
80
    }
129
    }
81
130
82
    if ($flush) {
131
    if ($flush) {
83
        my $key = "AV_descriptions:".$self->category;
132
        my $key = "AV_descriptions:" . $self->category;
84
        $cache->clear_from_cache($key);
133
        $cache->clear_from_cache($key);
85
    }
134
    }
86
135
(-)a/admin/authorised_values.pl (-6 / +2 lines)
Lines 119-126 if ( $op eq 'add_form' or $op eq 'edit_form' ) { Link Here
119
        $av->authorised_value( $new_authorised_value );
119
        $av->authorised_value( $new_authorised_value );
120
        $av->imageurl( $imageurl );
120
        $av->imageurl( $imageurl );
121
        eval{
121
        eval{
122
            $av->store;
122
            $av->store( \@branches );
123
            $av->replace_library_limits( \@branches );
124
        };
123
        };
125
        if ( $@ ) {
124
        if ( $@ ) {
126
            push @messages, {type => 'error', code => 'error_on_update' };
125
            push @messages, {type => 'error', code => 'error_on_update' };
Lines 138-146 if ( $op eq 'add_form' or $op eq 'edit_form' ) { Link Here
138
                    lib_opac         => scalar $input->param('lib_opac') || undef,
137
                    lib_opac         => scalar $input->param('lib_opac') || undef,
139
                    imageurl         => $imageurl,
138
                    imageurl         => $imageurl,
140
                }
139
                }
141
            );
140
            )->store( \@branches );
142
            $av->replace_library_limits( \@branches );
143
            $av->store;
144
        };
141
        };
145
142
146
        if ( $@ ) {
143
        if ( $@ ) {
147
- 

Return to bug 35630