Lines 574-582
if ((!$nok) and $nodouble and ($op eq 'cud-insert' or $op eq 'cud-save')){
Link Here
|
574 |
|
574 |
|
575 |
if ( $success ) { |
575 |
if ( $success ) { |
576 |
if (C4::Context->preference('ExtendedPatronAttributes') and $input->param('setting_extended_patron_attributes')) { |
576 |
if (C4::Context->preference('ExtendedPatronAttributes') and $input->param('setting_extended_patron_attributes')) { |
577 |
$patron->extended_attributes->filter_by_branch_limitations->delete; |
577 |
my $existing_attributes = $patron->extended_attributes->filter_by_branch_limitations->unblessed; |
578 |
$patron->extended_attributes($extended_patron_attributes); |
578 |
|
579 |
} |
579 |
my $needs_update = 1; |
|
|
580 |
|
581 |
# If there are an unqueunal number of new and old patron attributes they definietely need updated |
582 |
if ( scalar @{$existing_attributes} == scalar @{$extended_patron_attributes} ) { |
583 |
my $seen = 0; |
584 |
for ( my $i = 0 ; $i <= scalar @{$extended_patron_attributes} ; $i++ ) { |
585 |
my $new_attr = $extended_patron_attributes->[$i]; |
586 |
next unless $new_attr; |
587 |
for ( my $j = 0 ; $j <= scalar @{$existing_attributes} ; $j++ ) { |
588 |
my $existing_attr = $existing_attributes->[$j]; |
589 |
next unless $existing_attr; |
590 |
|
591 |
if ( $new_attr->{attribute} eq $existing_attr->{attribute} |
592 |
&& $new_attr->{borrowernumber} eq $existing_attr->{borrowernumber} |
593 |
&& $new_attr->{code} eq $existing_attr->{code} ) |
594 |
{ |
595 |
$seen++; |
596 |
|
597 |
# Remove the match from the "old" attribute |
598 |
splice( @{$existing_attributes}, $j, 1 ); |
599 |
|
600 |
# Move on to look at the next "new" attribute |
601 |
last; |
602 |
} |
603 |
} |
604 |
} |
605 |
|
606 |
# If we found a match for each existing attribute and the number of see attributes matches the number seen |
607 |
# we don't need to update the attributes |
608 |
if ( scalar @{$existing_attributes} == 0 && $seen == @{$extended_patron_attributes} ) { |
609 |
$needs_update = 0; |
610 |
} |
611 |
} |
612 |
|
613 |
if ($needs_update) { |
614 |
$patron->extended_attributes->filter_by_branch_limitations->delete; |
615 |
$patron->extended_attributes($extended_patron_attributes); |
616 |
} |
617 |
} |
580 |
|
618 |
|
581 |
if ( $destination eq 'circ' and not C4::Auth::haspermission( C4::Context->userenv->{id}, { circulate => 'circulate_remaining_permissions' } ) ) { |
619 |
if ( $destination eq 'circ' and not C4::Auth::haspermission( C4::Context->userenv->{id}, { circulate => 'circulate_remaining_permissions' } ) ) { |
582 |
# If we want to redirect to circulation.pl and need to check if the logged in user has the necessary permission |
620 |
# If we want to redirect to circulation.pl and need to check if the logged in user has the necessary permission |
583 |
- |
|
|