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