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

(-)a/Koha/Patron/Modification.pm (-11 / +22 lines)
Lines 23-33 use Carp; Link Here
23
23
24
use Koha::Database;
24
use Koha::Database;
25
use Koha::Exceptions::Patron::Modification;
25
use Koha::Exceptions::Patron::Modification;
26
use Koha::Patron::Attribute;
27
use Koha::Patron::Attributes;
26
use Koha::Patron::Modifications;
28
use Koha::Patron::Modifications;
27
# TODO: Remove once Koha::Patron::Attribute(s) is implemented
28
use C4::Members::Attributes qw( SetBorrowerAttributes );
29
29
30
use JSON;
30
use JSON;
31
use List::MoreUtils qw( uniq );
31
use Try::Tiny;
32
use Try::Tiny;
32
33
33
use base qw(Koha::Object);
34
use base qw(Koha::Object);
Lines 87-92 sub approve { Link Here
87
    my ($self) = @_;
88
    my ($self) = @_;
88
89
89
    my $data = $self->unblessed();
90
    my $data = $self->unblessed();
91
    my $extended_attributes;
90
92
91
    delete $data->{timestamp};
93
    delete $data->{timestamp};
92
    delete $data->{verification_token};
94
    delete $data->{verification_token};
Lines 104-110 sub approve { Link Here
104
106
105
    # Take care of extended attributes
107
    # Take care of extended attributes
106
    if ( $self->extended_attributes ) {
108
    if ( $self->extended_attributes ) {
107
        our $extended_attributes
109
        $extended_attributes
108
            = try { decode_json( $self->extended_attributes ) }
110
            = try { decode_json( $self->extended_attributes ) }
109
        catch {
111
        catch {
110
            Koha::Exceptions::Patron::Modification::InvalidData->throw(
112
            Koha::Exceptions::Patron::Modification::InvalidData->throw(
Lines 117-128 sub approve { Link Here
117
            try {
119
            try {
118
                $patron->store();
120
                $patron->store();
119
121
120
                # Take care of extended attributes
122
                # Deal with attributes
121
                if ( $self->extended_attributes ) {
123
                my @codes
122
                    my $extended_attributes
124
                    = uniq( map { $_->{code} } @{$extended_attributes} );
123
                        = decode_json( $self->extended_attributes );
125
                foreach my $code (@codes) {
124
                    SetBorrowerAttributes( $patron->borrowernumber,
126
                    map { $_->delete } Koha::Patron::Attributes->search(
125
                        $extended_attributes );
127
                        {   borrowernumber => $patron->borrowernumber,
128
                            code           => $code
129
                        }
130
                    );
131
                }
132
                foreach my $attr ( @{$extended_attributes} ) {
133
                    Koha::Patron::Attribute->new(
134
                        {   borrowernumber => $patron->borrowernumber,
135
                            code           => $attr->{code},
136
                            attribute      => $attr->{value}
137
                        }
138
                    )->store;
126
                }
139
                }
127
            }
140
            }
128
            catch {
141
            catch {
Lines 141-148 sub approve { Link Here
141
}
154
}
142
155
143
156
144
145
146
=head3 type
157
=head3 type
147
158
148
=cut
159
=cut
(-)a/members/members-update.pl (-4 / +4 lines)
Lines 24-30 use C4::Auth; Link Here
24
use C4::Output;
24
use C4::Output;
25
use C4::Context;
25
use C4::Context;
26
use C4::Members;
26
use C4::Members;
27
use C4::Members::Attributes qw( GetBorrowerAttributes );
28
use Koha::Patron::Attributes;
27
use Koha::Patron::Attributes;
29
use Koha::Patron::Modifications;
28
use Koha::Patron::Modifications;
30
29
Lines 55-64 my $borrowers; Link Here
55
foreach my $pm (@$pending_modifications) {
54
foreach my $pm (@$pending_modifications) {
56
    $borrowers->{ $pm->{borrowernumber} }
55
    $borrowers->{ $pm->{borrowernumber} }
57
        = GetMember( borrowernumber => $pm->{borrowernumber} );
56
        = GetMember( borrowernumber => $pm->{borrowernumber} );
58
    my $patron_attributes = Koha::Patron::Attributes->search(
57
    my @patron_attributes
58
        = grep { $_->opac_editable }
59
        Koha::Patron::Attributes->search(
59
        { borrowernumber => $pm->{borrowernumber} } );
60
        { borrowernumber => $pm->{borrowernumber} } );
60
    $borrowers->{ $pm->{'borrowernumber'} }->{extended_attributes}
61
    $borrowers->{ $pm->{'borrowernumber'} }->{extended_attributes}
61
        = $patron_attributes;
62
        = \@patron_attributes;
62
}
63
}
63
64
64
$template->param(
65
$template->param(
65
- 

Return to bug 13757