@@ -, +, @@ --- C4/AuthoritiesMarc.pm | 24 +++++++++++-------- installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 7 +++++ .../en/modules/admin/preferences/authorities.pref | 7 +++++ 4 files changed, 29 insertions(+), 10 deletions(-) --- a/C4/AuthoritiesMarc.pm +++ a/C4/AuthoritiesMarc.pm @@ -1407,7 +1407,7 @@ sub AddAuthorityTrees{ =head2 merge - $ref= &merge(mergefrom,$MARCfrom,$mergeto,$MARCto) + $ref= &merge(mergefrom,$MARCfrom,$mergeto,$MARCto,$overwrite) Could add some feature : Migrating from a typecode to an other for instance. Then we should add some new parameter : bibliotargettag, authtargettag @@ -1415,7 +1415,8 @@ Then we should add some new parameter : bibliotargettag, authtargettag =cut sub merge { - my ($mergefrom,$MARCfrom,$mergeto,$MARCto) = @_; + my ($mergefrom,$MARCfrom,$mergeto,$MARCto,$overwrite) = @_; + $overwrite = C4::Context->preference('overwriteSubfieldsOnMerge') unless defined $overwrite; my ($counteditedbiblio,$countunmodifiedbiblio,$counterrors)=(0,0,0); my $dbh=C4::Context->dbh; my $authtypecodefrom = GetAuthTypeCode($mergefrom); @@ -1491,17 +1492,20 @@ sub merge { my $tag=$field->tag(); if ($auth_number==$mergefrom) { my $field_to=MARC::Field->new(($tag_to?$tag_to:$tag),$field->indicator(1),$field->indicator(2),"9"=>$mergeto); - my $exclude='9'; + my $exclude='9'; foreach my $subfield (grep {$_->[0] ne '9'} @record_to) { $field_to->add_subfields($subfield->[0] =>$subfield->[1]); - $exclude.= $subfield->[0]; + $exclude.= $subfield->[0]; } - $exclude='['.$exclude.']'; -# add subfields in $field not included in @record_to - my @restore= grep {$_->[0]!~/$exclude/} $field->subfields(); - foreach my $subfield (@restore) { - $field_to->add_subfields($subfield->[0] =>$subfield->[1]); - } + $exclude='['.$exclude.']'; + unless($overwrite) { + # add subfields in $field not included in @record_to + my @restore= grep {$_->[0]!~/$exclude/} $field->subfields(); + foreach my $subfield (@restore) { + $field_to->add_subfields($subfield->[0] =>$subfield->[1]); + } + } + $marcrecord->delete_field($field); $marcrecord->insert_grouped_field($field_to); $update=1; --- a/installer/data/mysql/sysprefs.sql +++ a/installer/data/mysql/sysprefs.sql @@ -289,6 +289,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('OverDriveLibraryID','','Library ID for OverDrive integration','','Integer'), ('OverdueNoticeBcc','','','Email address to bcc outgoing overdue notices sent by email','free'), ('OverduesBlockCirc','noblock','noblock|confirmation|block','When checking out an item should overdues block checkout, generate a confirmation dialogue, or allow checkout','Choice'), +('overwriteSubfieldsOnMerge','0',NULL,'Overwrite the biblio\'s subfields when merging an authority record with a biblio record.','YesNo'), ('patronimages','0',NULL,'Enable patron images for the Staff Client','YesNo'), ('PatronSelfRegistration','0',NULL,'If enabled, patrons will be able to register themselves via the OPAC.','YesNo'), ('PatronSelfRegistrationAdditionalInstructions','','','A free text field to display additional instructions to newly self registered patrons.','free'), --- a/installer/data/mysql/updatedatabase.pl +++ a/installer/data/mysql/updatedatabase.pl @@ -7825,6 +7825,13 @@ if ( CheckVersion($DBversion) ) { } +$DBversion = "XXX"; +if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { + $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('overwriteSubfieldsOnMerge','0',NULL,'Overwrite the biblio\\'s subfields when merging an authority record with a biblio record.','YesNo')"); + print "Add the overwriteSubfieldsOnMerge preference.\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/authorities.pref +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/authorities.pref @@ -44,6 +44,13 @@ Authorities: no: "Don't use" - authority record numbers instead of text strings for searches from subject tracings. - + - pref: overwriteSubfieldsOnMerge + default: no + choices: + yes: Overwrite + no: "Don't overwrite" + - "the biblio's subfields when merging an authority record with a biblio record." + - - Use the following text for the contents of UNIMARC authority field 100 position (fixed length data elements). Do NOT include the date (position 00-05). - pref: UNIMARCAuthorityField100 defautl: "afrey50 ba0" --