From f6e4607a8ecf335531a8930fc40a0edef2f34890 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Thu, 6 Feb 2014 15:59:40 +0100 Subject: [PATCH] Bug 11700: C4::AuthoritiesMarc::merge enhancements/fixes - Returns the list of modified biblio records - Retrieve MARC records from DB if not given in parameters - Delete source authority if source and destination records are different Signed-off-by: Bernardo Gonzalez Kriegel Signed-off-by: Kyle M Hall --- C4/AuthoritiesMarc.pm | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm index 0d38042..3655126 100644 --- a/C4/AuthoritiesMarc.pm +++ b/C4/AuthoritiesMarc.pm @@ -1399,22 +1399,27 @@ sub AddAuthorityTrees{ =head2 merge - $ref= &merge(mergefrom,$MARCfrom,$mergeto,$MARCto) + my @edited_biblionumbers = merge(mergefrom, $MARCfrom, $mergeto, $MARCto); Could add some feature : Migrating from a typecode to an other for instance. Then we should add some new parameter : bibliotargettag, authtargettag +Returns a list of biblionumbers of records that were modified. + =cut sub merge { my ($mergefrom, $MARCfrom, $mergeto, $MARCto) = @_; - my ($counteditedbiblio,$countunmodifiedbiblio,$counterrors)=(0,0,0); + my @editedbiblios; my $dbh = C4::Context->dbh; my $authfrom = Koha::Authorities->find($mergefrom); my $authto = Koha::Authorities->find($mergeto); my $authtypefrom = Koha::Authority::Types->find($authfrom->authtypecode); my $authtypeto = Koha::Authority::Types->find($authto->authtypecode); + $MARCfrom ||= GetAuthority($mergefrom); + $MARCto ||= GetAuthority($mergeto); + return "error MARCFROM not a marcrecord ".Data::Dumper::Dumper($MARCfrom) if scalar($MARCfrom->fields()) == 0; return "error MARCTO not a marcrecord".Data::Dumper::Dumper($MARCto) if scalar($MARCto->fields()) == 0; # search the tag to report @@ -1514,12 +1519,13 @@ sub merge { } if ($update==1){ &ModBiblio($marcrecord,$biblionumber,GetFrameworkCode($biblionumber)) ; - $counteditedbiblio++; - warn $counteditedbiblio if (($counteditedbiblio % 10) and $ENV{DEBUG}); + push @editedbiblios, $biblionumber; } }#foreach $marc - return $counteditedbiblio; + DelAuthority($mergefrom) if ($mergefrom != $mergeto); + + return @editedbiblios; } =head2 get_auth_type_location -- 2.1.4