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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/members-update.tt (+10 lines)
Lines 62-71 Link Here
62
[% CASE 'altcontactcountry'   %]<span>Alternate contact: Country</span>
62
[% CASE 'altcontactcountry'   %]<span>Alternate contact: Country</span>
63
[% CASE 'altcontactphone'     %]<span>Alternate contact: Phone</span>
63
[% CASE 'altcontactphone'     %]<span>Alternate contact: Phone</span>
64
[% CASE 'smsalertnumber'      %]<span>SMS alert number</span>
64
[% CASE 'smsalertnumber'      %]<span>SMS alert number</span>
65
[% CASE 'extended_attributes' %]<span>Additional attributes and identifiers</span>
65
[% CASE %][% field %]
66
[% CASE %][% field %]
66
[% END %]
67
[% END %]
67
[% END %]
68
[% END %]
68
69
70
[% BLOCK display_extended_attributes %]
71
    [% FOREACH attr IN attributes %]
72
        <span>[% attr.code %]: [% IF pending %][% attr.value %][% ELSE %][% attr.attribute %][% END %]</span><br/>
73
    [% END %]
74
[% END %]
75
69
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a> &rsaquo; Update patron records</div>
76
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a> &rsaquo; Update patron records</div>
70
77
71
<div id="doc2" class="yui-t7">
78
<div id="doc2" class="yui-t7">
Lines 111-116 Link Here
111
                                                            [% ELSIF key == 'branchcode' %]
118
                                                            [% ELSIF key == 'branchcode' %]
112
                                                                <td>[% Branches.GetName( borrowers.$borrowernumber.$key )  %]</td>
119
                                                                <td>[% Branches.GetName( borrowers.$borrowernumber.$key )  %]</td>
113
                                                                <td>[% Branches.GetName( pm.$key ) %]</td>
120
                                                                <td>[% Branches.GetName( pm.$key ) %]</td>
121
                                                            [% ELSIF ( key == 'extended_attributes' ) %]
122
                                                                <td>[% PROCESS display_extended_attributes attributes=borrowers.$borrowernumber.$key %]</td>
123
                                                                <td>[% PROCESS display_extended_attributes attributes=pm.$key pending=1 %]</td>
114
                                                            [% ELSE %]
124
                                                            [% ELSE %]
115
                                                                <td>[% borrowers.$borrowernumber.$key %]</td>
125
                                                                <td>[% borrowers.$borrowernumber.$key %]</td>
116
                                                                <td>[% pm.$key %]</td>
126
                                                                <td>[% pm.$key %]</td>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt (-12 / +2 lines)
Lines 911-918 Link Here
911
                                            [% IF ( pa.type.authorised_value_category ) %]
911
                                            [% IF ( pa.type.authorised_value_category ) %]
912
                                                <select id="[% form_id %]" name="patron_attribute_value">
912
                                                <select id="[% form_id %]" name="patron_attribute_value">
913
                                                    <option value=""></option>
913
                                                    <option value=""></option>
914
                                                    [% FOREACH auth_val IN AuthorisedValues.Get( pa.type.authorised_value_category, pa_value.value || '', 1 ) %]
914
                                                    [% FOREACH auth_val IN AuthorisedValues.Get( pa.type.authorised_value_category, 1 ) %]
915
                                                        [% IF ( auth_val.selected ) %]
915
                                                        [% IF ( auth_val.authorised_value == pa_value.value ) %]
916
                                                            <option value="[% auth_val.authorised_value %]" selected="selected">
916
                                                            <option value="[% auth_val.authorised_value %]" selected="selected">
917
                                                                [%# Yes, lib; GetAuthorisedValues takes care of intelligently setting this from lib_opac %]
917
                                                                [%# Yes, lib; GetAuthorisedValues takes care of intelligently setting this from lib_opac %]
918
                                                                [% auth_val.lib %]
918
                                                                [% auth_val.lib %]
Lines 931-952 Link Here
931
                                            [% IF ( pa.type.repeatable ) %]
931
                                            [% IF ( pa.type.repeatable ) %]
932
                                            <a href="#" class="clone-attribute">New</a>
932
                                            <a href="#" class="clone-attribute">New</a>
933
                                            [% END %]
933
                                            [% END %]
934
                                            [% IF ( pa.type.password_allowed ) %]
935
                                                </li><li><label for="[% form_id %]_password">Password:</label>
936
                                                <input type="password" maxlength="64" value="[% pa_value.password %]" id="[% form_id %]_password" name="patron_attribute_password" />
937
                                            [% ELSE %]
938
                                                [%# To keep the form inputs lined up in the POST %]
939
                                                <input type="hidden" name="patron_attribute_password" value="" />
940
                                            [% END %]
941
                                        [% ELSE %]
934
                                        [% ELSE %]
942
                                            [% IF ( pa.type.authorised_value_category ) %]
935
                                            [% IF ( pa.type.authorised_value_category ) %]
943
                                                [% AuthorisedValues.GetByCode( pa.type.authorised_value, pa_value.value, 1 ) %]
936
                                                [% AuthorisedValues.GetByCode( pa.type.authorised_value, pa_value.value, 1 ) %]
944
                                            [% ELSE %]
937
                                            [% ELSE %]
945
                                                [% pa_value.value | html_line_break %]
938
                                                [% pa_value.value | html_line_break %]
946
                                            [% END %]
939
                                            [% END %]
947
                                            [% IF ( pa_value.password ) %]
948
                                                (Password: *******)
949
                                            [% END %]
950
                                        [% END %]
940
                                        [% END %]
951
                                    </li>
941
                                    </li>
952
                                [% END %]
942
                                [% END %]
(-)a/members/members-update.pl (-6 / +13 lines)
Lines 16-29 Link Here
16
# You should have received a copy of the GNU General Public License
16
# You should have received a copy of the GNU General Public License
17
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
# along with Koha; if not, see <http://www.gnu.org/licenses>.
18
18
19
use strict;
19
use Modern::Perl;
20
use warnings;
21
20
22
use CGI qw ( -utf8 );
21
use CGI qw ( -utf8 );
22
23
use C4::Auth;
23
use C4::Auth;
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::Modifications;
29
use Koha::Patron::Modifications;
28
30
29
my $query = new CGI;
31
my $query = new CGI;
Lines 51-64 my $pending_modifications = Link Here
51
53
52
my $borrowers;
54
my $borrowers;
53
foreach my $pm (@$pending_modifications) {
55
foreach my $pm (@$pending_modifications) {
54
    $borrowers->{ $pm->{'borrowernumber'} } =
56
    $borrowers->{ $pm->{borrowernumber} }
55
      GetMember( borrowernumber => $pm->{'borrowernumber'} );
57
        = GetMember( borrowernumber => $pm->{borrowernumber} );
56
58
    my $patron_attributes = Koha::Patron::Attributes->search(
59
        { borrowernumber => $pm->{borrowernumber} } );
60
    $borrowers->{ $pm->{'borrowernumber'} }->{extended_attributes}
61
        = $patron_attributes;
57
}
62
}
58
63
59
$template->param(
64
$template->param(
60
    PendingModifications => $pending_modifications,
65
    PendingModifications => $pending_modifications,
61
    borrowers            => $borrowers,
66
    borrowers            => $borrowers
62
);
67
);
63
68
64
output_html_with_http_headers $query, $cookie, $template->output;
69
output_html_with_http_headers $query, $cookie, $template->output;
70
71
1;
(-)a/opac/opac-memberentry.pl (-6 / +30 lines)
Lines 21-32 use CGI qw ( -utf8 ); Link Here
21
use Digest::MD5 qw( md5_base64 md5_hex );
21
use Digest::MD5 qw( md5_base64 md5_hex );
22
use Encode qw( encode );
22
use Encode qw( encode );
23
use JSON;
23
use JSON;
24
use List::MoreUtils qw( each_array uniq );
24
use List::MoreUtils qw( any each_array uniq );
25
use String::Random qw( random_string );
25
use String::Random qw( random_string );
26
26
27
use C4::Auth;
27
use C4::Auth;
28
use C4::Output;
28
use C4::Output;
29
use C4::Members;
29
use C4::Members;
30
use C4::Members::Attributes qw( GetBorrowerAttributes );
30
use C4::Form::MessagingPreferences;
31
use C4::Form::MessagingPreferences;
31
use Koha::Patrons;
32
use Koha::Patrons;
32
use Koha::Patron::Modification;
33
use Koha::Patron::Modification;
Lines 251-257 elsif ( $action eq 'update' ) { Link Here
251
    }
252
    }
252
    else {
253
    else {
253
        my %borrower_changes = DelUnchangedFields( $borrowernumber, %borrower );
254
        my %borrower_changes = DelUnchangedFields( $borrowernumber, %borrower );
254
        if (%borrower_changes) {
255
        my $extended_attributes_changes = ExtendedAttributesMatch( $borrowernumber, $attributes );
256
257
        if ( %borrower_changes || $extended_attributes_changes ) {
255
            ( $template, $borrowernumber, $cookie ) = get_template_and_user(
258
            ( $template, $borrowernumber, $cookie ) = get_template_and_user(
256
                {
259
                {
257
                    template_name   => "opac-memberentry-update-submitted.tt",
260
                    template_name   => "opac-memberentry-update-submitted.tt",
Lines 283-288 elsif ( $action eq 'update' ) { Link Here
283
                action => 'edit',
286
                action => 'edit',
284
                nochanges => 1,
287
                nochanges => 1,
285
                borrower => GetMember( borrowernumber => $borrowernumber ),
288
                borrower => GetMember( borrowernumber => $borrowernumber ),
289
                patron_attribute_classes => GeneratePatronAttributesForm( undef, $attributes ),
286
                csrf_token => Koha::Token->new->generate_csrf({
290
                csrf_token => Koha::Token->new->generate_csrf({
287
                    id     => Encode::encode( 'UTF-8', $borrower->{userid} ),
291
                    id     => Encode::encode( 'UTF-8', $borrower->{userid} ),
288
                    secret => md5_base64( Encode::encode( 'UTF-8', C4::Context->config('pass') ) ),
292
                    secret => md5_base64( Encode::encode( 'UTF-8', C4::Context->config('pass') ) ),
Lines 468-473 sub DelEmptyFields { Link Here
468
    return %borrower;
472
    return %borrower;
469
}
473
}
470
474
475
sub ExtendedAttributesMatch {
476
    my ( $borrowernumber, $entered_attributes ) = @_;
477
478
    my @patron_attributes_arr = GetBorrowerAttributes( $borrowernumber, 1 );
479
    my $patron_attributes = $patron_attributes_arr[0];
480
481
    if ( scalar @{$entered_attributes} != scalar @{$patron_attributes} ) {
482
        return 1;
483
    }
484
485
    foreach my $attr ( @{$patron_attributes} ) {
486
        next if any {
487
            $_->{code} eq $attr->{code} and $_->{value} eq $attr->{value};
488
        }
489
        @{$entered_attributes};
490
        return 1;
491
    }
492
493
    return 0;
494
}
495
496
471
sub GeneratePatronAttributesForm {
497
sub GeneratePatronAttributesForm {
472
    my ( $borrowernumber, $entered_attributes ) = @_;
498
    my ( $borrowernumber, $entered_attributes ) = @_;
473
499
Lines 538-546 sub ParsePatronAttributes { Link Here
538
564
539
    my @codes = $cgi->multi_param('patron_attribute_code');
565
    my @codes = $cgi->multi_param('patron_attribute_code');
540
    my @values = $cgi->multi_param('patron_attribute_value');
566
    my @values = $cgi->multi_param('patron_attribute_value');
541
    my @passwords = $cgi->multi_param('patron_attribute_password');
542
567
543
    my $ea = each_array( @codes, @values, @passwords );
568
    my $ea = each_array( @codes, @values );
544
    my @attributes;
569
    my @attributes;
545
    my %dups = ();
570
    my %dups = ();
546
571
Lines 549-555 sub ParsePatronAttributes { Link Here
549
        next if exists $dups{$code}->{$value};
574
        next if exists $dups{$code}->{$value};
550
        $dups{$code}->{$value} = 1;
575
        $dups{$code}->{$value} = 1;
551
576
552
        push @attributes, { code => $code, value => $value, password => $password };
577
        push @attributes, { code => $code, value => $value };
553
    }
578
    }
554
579
555
    return \@attributes;
580
    return \@attributes;
556
- 

Return to bug 13757