|
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 => $borrower->{userid}, |
291 |
id => $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 |
- |
|
|