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

(-)a/Koha/Patron/Modification.pm (-8 / +8 lines)
Lines 28-34 use Koha::Patron::Attributes; Link Here
28
use Koha::Patron::Modifications;
28
use Koha::Patron::Modifications;
29
29
30
use JSON;
30
use JSON;
31
use List::MoreUtils qw( uniq );
31
use List::MoreUtils qw( uniq any );
32
use Try::Tiny;
32
use Try::Tiny;
33
33
34
use base qw(Koha::Object);
34
use base qw(Koha::Object);
Lines 91-107 sub approve { Link Here
91
    delete $data->{timestamp};
91
    delete $data->{timestamp};
92
    delete $data->{verification_token};
92
    delete $data->{verification_token};
93
    delete $data->{extended_attributes};
93
    delete $data->{extended_attributes};
94
    my $changed_fields = $data->{changed_fields};
95
    delete $data->{changed_fields};
94
96
95
    my $patron = Koha::Patrons->find( $self->borrowernumber );
97
    my $patron = Koha::Patrons->find( $self->borrowernumber );
96
    return unless $patron;
98
    return unless $patron;
97
99
98
    foreach my $key ( keys %$data ) {
100
    my @keep_keys = split /,/, $changed_fields;
99
        next # Unset it!
101
    my @all_keys = keys %$data;
100
          if $key eq 'dateofbirth'
102
    foreach my $key ( @all_keys ) {
101
          && $patron->dateofbirth
103
        next if (any { $_ eq $key } @keep_keys);
102
          && not defined $data->{$key};
104
        delete $data->{$key};
103
104
        delete $data->{$key} unless defined $data->{$key};
105
    }
105
    }
106
106
107
    $patron->set($data);
107
    $patron->set($data);
(-)a/Koha/Patron/Modifications.pm (-3 / +7 lines)
Lines 30-35 use Koha::Patron::Attribute; Link Here
30
use Koha::Patron::Modification;
30
use Koha::Patron::Modification;
31
31
32
use JSON;
32
use JSON;
33
use List::Util qw /any none/;
33
34
34
use base qw(Koha::Objects);
35
use base qw(Koha::Objects);
35
36
Lines 116-122 sub pending { Link Here
116
117
117
    my @m;
118
    my @m;
118
    while ( my $row = $sth->fetchrow_hashref() ) {
119
    while ( my $row = $sth->fetchrow_hashref() ) {
120
        my @changed_keys = split /,/, $row->{changed_fields};
119
        foreach my $key ( keys %$row ) {
121
        foreach my $key ( keys %$row ) {
122
            if ($key eq 'changed_fields') {
123
                delete $row->{$key};
124
                next;
125
            }
120
            if ( defined $row->{$key} && $key eq 'extended_attributes' ) {
126
            if ( defined $row->{$key} && $key eq 'extended_attributes' ) {
121
                my $attributes = from_json( $row->{$key} );
127
                my $attributes = from_json( $row->{$key} );
122
                my @pending_attributes;
128
                my @pending_attributes;
Lines 132-140 sub pending { Link Here
132
138
133
                $row->{$key} = \@pending_attributes;
139
                $row->{$key} = \@pending_attributes;
134
            }
140
            }
135
            if ( $key eq 'dateofbirth' and not defined $row->{$key}) {
141
            if (none { $_ eq $key } @changed_keys) {
136
                $row->{$key} = '';
137
            } else {
138
                delete $row->{$key} unless defined $row->{$key};
142
                delete $row->{$key} unless defined $row->{$key};
139
            }
143
            }
140
        }
144
        }
(-)a/opac/opac-memberentry.pl (-3 / +2 lines)
Lines 247-255 elsif ( $action eq 'update' ) { Link Here
247
    my %borrower = ParseCgiForBorrower($cgi);
247
    my %borrower = ParseCgiForBorrower($cgi);
248
    $borrower{borrowernumber} = $borrowernumber;
248
    $borrower{borrowernumber} = $borrowernumber;
249
249
250
    my %borrower_changes = DelEmptyFields(%borrower);
251
    my @empty_mandatory_fields =
250
    my @empty_mandatory_fields =
252
      CheckMandatoryFields( \%borrower_changes, $action );
251
      CheckMandatoryFields( \%borrower, $action );
253
    my $invalidformfields = CheckForInvalidFields(\%borrower);
252
    my $invalidformfields = CheckForInvalidFields(\%borrower);
254
253
255
    # Send back the data to the template
254
    # Send back the data to the template
Lines 270-275 elsif ( $action eq 'update' ) { Link Here
270
    }
269
    }
271
    else {
270
    else {
272
        my %borrower_changes = DelUnchangedFields( $borrowernumber, %borrower );
271
        my %borrower_changes = DelUnchangedFields( $borrowernumber, %borrower );
272
        $borrower_changes{'changed_fields'} = join ',', keys %borrower_changes;
273
        my $extended_attributes_changes = FilterUnchangedAttributes( $borrowernumber, $attributes );
273
        my $extended_attributes_changes = FilterUnchangedAttributes( $borrowernumber, $attributes );
274
274
275
        if ( %borrower_changes || scalar @{$extended_attributes_changes} > 0 ) {
275
        if ( %borrower_changes || scalar @{$extended_attributes_changes} > 0 ) {
276
- 

Return to bug 23151