View | Details | Raw Unified | Return to bug 11315
Collapse All | Expand All

(-)a/C4/AuthoritiesMarc.pm (-11 / +15 lines)
Lines 732-738 sub ModAuthority { Link Here
732
  # In that case set system preference "dontmerge" to 1. Otherwise biblios will
732
  # In that case set system preference "dontmerge" to 1. Otherwise biblios will
733
  # be updated.
733
  # be updated.
734
  unless(C4::Context->preference('dontmerge') eq '1'){
734
  unless(C4::Context->preference('dontmerge') eq '1'){
735
      &merge($authid,$oldrecord,$authid,$record);
735
      my $overwrite = C4::Context->preference('overwriteSubfieldsOnMerge');
736
      &merge($authid,$oldrecord,$authid,$record,$overwrite);
736
  } else {
737
  } else {
737
      # save a record in need_merge_authorities table
738
      # save a record in need_merge_authorities table
738
      my $sqlinsert="INSERT INTO need_merge_authorities (authid, done) ".
739
      my $sqlinsert="INSERT INTO need_merge_authorities (authid, done) ".
Lines 1407-1413 sub AddAuthorityTrees{ Link Here
1407
1408
1408
=head2 merge
1409
=head2 merge
1409
1410
1410
  $ref= &merge(mergefrom,$MARCfrom,$mergeto,$MARCto)
1411
  $ref= &merge(mergefrom,$MARCfrom,$mergeto,$MARCto,$overwrite)
1411
1412
1412
Could add some feature : Migrating from a typecode to an other for instance.
1413
Could add some feature : Migrating from a typecode to an other for instance.
1413
Then we should add some new parameter : bibliotargettag, authtargettag
1414
Then we should add some new parameter : bibliotargettag, authtargettag
Lines 1415-1421 Then we should add some new parameter : bibliotargettag, authtargettag Link Here
1415
=cut
1416
=cut
1416
1417
1417
sub merge {
1418
sub merge {
1418
    my ($mergefrom,$MARCfrom,$mergeto,$MARCto) = @_;
1419
    my ($mergefrom,$MARCfrom,$mergeto,$MARCto,$overwrite) = @_;
1419
    my ($counteditedbiblio,$countunmodifiedbiblio,$counterrors)=(0,0,0);        
1420
    my ($counteditedbiblio,$countunmodifiedbiblio,$counterrors)=(0,0,0);        
1420
    my $dbh=C4::Context->dbh;
1421
    my $dbh=C4::Context->dbh;
1421
    my $authtypecodefrom = GetAuthTypeCode($mergefrom);
1422
    my $authtypecodefrom = GetAuthTypeCode($mergefrom);
Lines 1491-1507 sub merge { Link Here
1491
                my $tag=$field->tag();          
1492
                my $tag=$field->tag();          
1492
                if ($auth_number==$mergefrom) {
1493
                if ($auth_number==$mergefrom) {
1493
                my $field_to=MARC::Field->new(($tag_to?$tag_to:$tag),$field->indicator(1),$field->indicator(2),"9"=>$mergeto);
1494
                my $field_to=MARC::Field->new(($tag_to?$tag_to:$tag),$field->indicator(1),$field->indicator(2),"9"=>$mergeto);
1494
		my $exclude='9';
1495
                my $exclude='9';
1495
                foreach my $subfield (grep {$_->[0] ne '9'} @record_to) {
1496
                foreach my $subfield (grep {$_->[0] ne '9'} @record_to) {
1496
                    $field_to->add_subfields($subfield->[0] =>$subfield->[1]);
1497
                    $field_to->add_subfields($subfield->[0] =>$subfield->[1]);
1497
		    $exclude.= $subfield->[0];
1498
                    $exclude.= $subfield->[0];
1498
                }
1499
                }
1499
		$exclude='['.$exclude.']';
1500
                $exclude='['.$exclude.']';
1500
#		add subfields in $field not included in @record_to
1501
                unless($overwrite) {
1501
		my @restore= grep {$_->[0]!~/$exclude/} $field->subfields();
1502
                    # add subfields in $field not included in @record_to
1502
                foreach my $subfield (@restore) {
1503
                    my @restore= grep {$_->[0]!~/$exclude/} $field->subfields();
1503
                   $field_to->add_subfields($subfield->[0] =>$subfield->[1]);
1504
                    foreach my $subfield (@restore) {
1504
		}
1505
                        $field_to->add_subfields($subfield->[0] =>$subfield->[1]);
1506
                    }
1507
                }
1508
1505
                $marcrecord->delete_field($field);
1509
                $marcrecord->delete_field($field);
1506
                $marcrecord->insert_grouped_field($field_to);            
1510
                $marcrecord->insert_grouped_field($field_to);            
1507
                $update=1;
1511
                $update=1;
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 289-294 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
289
('OverDriveLibraryID','','Library ID for OverDrive integration','','Integer'),
289
('OverDriveLibraryID','','Library ID for OverDrive integration','','Integer'),
290
('OverdueNoticeBcc','','','Email address to bcc outgoing overdue notices sent by email','free'),
290
('OverdueNoticeBcc','','','Email address to bcc outgoing overdue notices sent by email','free'),
291
('OverduesBlockCirc','noblock','noblock|confirmation|block','When checking out an item should overdues block checkout, generate a confirmation dialogue, or allow checkout','Choice'),
291
('OverduesBlockCirc','noblock','noblock|confirmation|block','When checking out an item should overdues block checkout, generate a confirmation dialogue, or allow checkout','Choice'),
292
('overwriteSubfieldsOnMerge','0',NULL,'Overwrite the biblio\'s subfields when merging an authority record with a biblio record.','YesNo'),
292
('patronimages','0',NULL,'Enable patron images for the Staff Client','YesNo'),
293
('patronimages','0',NULL,'Enable patron images for the Staff Client','YesNo'),
293
('PatronSelfRegistration','0',NULL,'If enabled, patrons will be able to register themselves via the OPAC.','YesNo'),
294
('PatronSelfRegistration','0',NULL,'If enabled, patrons will be able to register themselves via the OPAC.','YesNo'),
294
('PatronSelfRegistrationAdditionalInstructions','','','A free text field to display additional instructions to newly self registered patrons.','free'),
295
('PatronSelfRegistrationAdditionalInstructions','','','A free text field to display additional instructions to newly self registered patrons.','free'),
(-)a/installer/data/mysql/updatedatabase.pl (+7 lines)
Lines 7771-7776 if ( CheckVersion($DBversion) ) { Link Here
7771
    SetVersion($DBversion);
7771
    SetVersion($DBversion);
7772
}
7772
}
7773
7773
7774
$DBversion = "XXX";
7775
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
7776
    $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')");
7777
    print "Add the overwriteSubfieldsOnMerge preference.\n";
7778
    SetVersion($DBversion);
7779
}
7780
7774
=head1 FUNCTIONS
7781
=head1 FUNCTIONS
7775
7782
7776
=head2 TableExists($table)
7783
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/authorities.pref (+7 lines)
Lines 44-49 Authorities: Link Here
44
                  no: "Don't use"
44
                  no: "Don't use"
45
            - authority record numbers instead of text strings for searches from subject tracings.
45
            - authority record numbers instead of text strings for searches from subject tracings.
46
        -
46
        -
47
            - pref: overwriteSubfieldsOnMerge
48
              default: no
49
              choices:
50
                  yes: Overwrite
51
                  no: "Don't overwrite"
52
            - "the biblio's subfields when merging an authority record with a biblio record."
53
        -
47
            - 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).
54
            - 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).
48
            - pref: UNIMARCAuthorityField100
55
            - pref: UNIMARCAuthorityField100
49
              defautl: "afrey50      ba0"
56
              defautl: "afrey50      ba0"
(-)a/misc/migration_tools/merge_authority.pl (-3 / +4 lines)
Lines 58-63 my $authto = GetAuthority($mergeto); Link Here
58
my $authtypecodefrom = GetAuthTypeCode($mergefrom);
58
my $authtypecodefrom = GetAuthTypeCode($mergefrom);
59
my $authtypecodeto = GetAuthTypeCode($mergeto);
59
my $authtypecodeto = GetAuthTypeCode($mergeto);
60
60
61
my $overwrite = C4::Context->preference('overwriteSubfieldsOnMerge');
62
61
unless ($noconfirm || $batch) {
63
unless ($noconfirm || $batch) {
62
    print "************\n";
64
    print "************\n";
63
    print "You will merge authority : $mergefrom ($authtypecodefrom)\n".$authfrom->as_formatted;
65
    print "You will merge authority : $mergefrom ($authtypecodefrom)\n".$authfrom->as_formatted;
Lines 83-95 if ($batch) { Link Here
83
      print "managing $authid\n" if $verbose;
85
      print "managing $authid\n" if $verbose;
84
      my $MARCauth = GetAuthority($authid) ;
86
      my $MARCauth = GetAuthority($authid) ;
85
      next unless ($MARCauth);
87
      next unless ($MARCauth);
86
      merge($authid,$MARCauth,$authid,$MARCauth) if ($MARCauth);
88
      merge($authid,$MARCauth,$authid,$MARCauth,$overwrite) if ($MARCauth);
87
  }
89
  }
88
  $dbh->do("update need_merge_authorities set done=1 where done=2"); #DONE
90
  $dbh->do("update need_merge_authorities set done=1 where done=2"); #DONE
89
} else {
91
} else {
90
  my $MARCfrom = GetAuthority($mergefrom);
92
  my $MARCfrom = GetAuthority($mergefrom);
91
  my $MARCto = GetAuthority($mergeto);
93
  my $MARCto = GetAuthority($mergeto);
92
  &merge($mergefrom,$MARCfrom,$mergeto,$MARCto);
94
  &merge($mergefrom,$MARCfrom,$mergeto,$MARCto,$overwrite);
93
  #Could add mergefrom authority to mergeto rejected forms before deletion 
95
  #Could add mergefrom authority to mergeto rejected forms before deletion 
94
  DelAuthority($mergefrom) if ($mergefrom != $mergeto);
96
  DelAuthority($mergefrom) if ($mergefrom != $mergeto);
95
}
97
}
96
- 

Return to bug 11315