From ca1d9c835de2a47d348237bb70068ef7109c715a Mon Sep 17 00:00:00 2001 From: Paul Poulain Date: Mon, 12 Sep 2011 15:33:21 +0200 Subject: [PATCH] Bug 5725 follow-upd, deal with leader As Owen comment 33 notices, leader update was not working. This patch fixes the problem (and fix a few reindenting glitches as well) --- C4/Biblio.pm | 25 ++++++++++++++++++------- 1 files changed, 18 insertions(+), 7 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 90ecc5e..ee83caf 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -3712,11 +3712,22 @@ sub BatchModField { return 1; } else { my $done=0; + if ($field eq '000') { + my $value=$record->leader(); + if ($value=~ s/$condition/$repval/){ + $record->leader($repval); + $done=1; + } + if ( $nocond eq 'true'){ + $record->leader($repval); + $done=1; + } + } for my $rfield ($record->field($field)) { if ($subfield && $subfield ne "@"){ my @subfields = $rfield->subfields(); my @subfields_to_add; - foreach my $subf (@subfields) { + foreach my $subf (@subfields) { if ($subf->[0] eq $subfield){ $subf->[1]=NormalizeString($subf->[1]); if ( $action eq "mod" ) { @@ -3726,8 +3737,8 @@ sub BatchModField { if ($nocond eq "true"){ $subf->[1] = $repval; $done=1; - } - } elsif ( $action eq "del" ) { + } + } elsif ( $action eq "del" ) { if ( $subf->[1] =~ m/$condition/ || $nocond eq "true" ) { $done=1; next; @@ -3735,11 +3746,11 @@ sub BatchModField { } } push @subfields_to_add,@$subf; - } + } if ($done){ if (@subfields_to_add){ $rfield->replace_with(MARC::Field->new($rfield->tag,$rfield->indicator(1),$rfield->indicator(2),@subfields_to_add)); - } + } else { my $count= $record->delete_field($rfield); } @@ -3754,8 +3765,8 @@ sub BatchModField { if ($field < 10){ my $value=$record->field($field)->data(); if ($value=~ s/$condition/$repval/){ - $record->field($field)->update($value); - $done=1; + $record->field($field)->update($value); + $done=1; } if ( $nocond eq 'true'){ -- 1.7.4.1