@@ -, +, @@ headings when a record is saved in the cataloging module when LinkerRelink is turned on, even if the headings were manually linked to a different authority by the cataloger. When turned off (the default), the automatic linker will not relink any headings that have already been linked when a record is saved. the authority plugin. authority. the link. Save the record. same authority record you did earlier. authority. the link. Save the record. --- C4/Biblio.pm | 17 ++++++++++------- .../atomicupdate/bug_7284_authority_linking_pt2 | 9 +++++++++ installer/data/mysql/sysprefs.sql | 1 + .../en/modules/admin/preferences/authorities.pref | 7 +++++++ 4 files changed, 27 insertions(+), 7 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_7284_authority_linking_pt2 --- a/C4/Biblio.pm +++ a/C4/Biblio.pm @@ -487,13 +487,14 @@ sub BiblioAutoLink { my $linker = $linker_module->new( { 'options' => C4::Context->preference("LinkerOptions") } ); my ( $headings_changed, undef ) = - LinkBibHeadingsToAuthorities( $linker, $record, $frameworkcode ); + LinkBibHeadingsToAuthorities( $linker, $record, $frameworkcode, C4::Context->preference("CatalogModuleRelink") || '' ); + # By default we probably don't want to relink things when cataloging return $headings_changed; } =head2 LinkBibHeadingsToAuthorities - my $num_headings_changed, %results = LinkBibHeadingsToAuthorities($linker, $marc, $frameworkcode); + my $num_headings_changed, %results = LinkBibHeadingsToAuthorities($linker, $marc, $frameworkcode, [$allowrelink]); Links bib headings to authority records by checking each authority-controlled field in the C @@ -501,9 +502,9 @@ object C<$marc>, looking for a matching authority record, and setting the linking subfield $9 to the ID of that authority record. -If no matching authority exists, or if multiple -authorities match, no $9 will be added, and any -existing one inthe field will be deleted. +If $allowrelink is false, existing authids will never be +replaced, regardless of the values of LinkerKeepStale and +LinkerRelink. Returns the number of heading links changed in the MARC record. @@ -514,9 +515,11 @@ sub LinkBibHeadingsToAuthorities { my $linker = shift; my $bib = shift; my $frameworkcode = shift; + my $allowrelink = shift; my %results; require C4::AuthoritiesMarc; + $allowrelink = 1 unless defined $allowrelink; my $num_headings_changed = 0; foreach my $field ( $bib->fields() ) { my $heading = C4::Heading->new_from_bib_field( $field, $frameworkcode ); @@ -525,7 +528,7 @@ sub LinkBibHeadingsToAuthorities { # check existing $9 my $current_link = $field->subfield('9'); - if ( defined $current_link && !C4::Context->preference('LinkerRelink') ) + if ( defined $current_link && (!$allowrelink || !C4::Context->preference('LinkerRelink')) ) { $results{'linked'}->{ $heading->display_form() }++; next; @@ -543,7 +546,7 @@ sub LinkBibHeadingsToAuthorities { } else { if ( defined $current_link - && C4::Context->preference('LinkerKeepStale') ) + && (!$allowrelink || C4::Context->preference('LinkerKeepStale')) ) { $results{'fuzzy'}->{ $heading->display_form() }++; } --- a/installer/data/mysql/atomicupdate/bug_7284_authority_linking_pt2 +++ a/installer/data/mysql/atomicupdate/bug_7284_authority_linking_pt2 @@ -0,0 +1,9 @@ +#! /usr/bin/perl +use strict; +use warnings; +use C4::Context; +my $dbh = C4::Context->dbh; +$dbh->do( +"INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('CatalogModuleRelink',0,'If OFF the linker will never replace the authids that are set in the cataloging module.',NULL,'YesNo');" +); +print "Upgrade done (Configured bug 7284, added the )\n"; --- a/installer/data/mysql/sysprefs.sql +++ a/installer/data/mysql/sysprefs.sql @@ -339,3 +339,4 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES(' INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('LinkerOptions','','A pipe-separated list of options for the linker.','','free'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('LinkerRelink',1,'If ON the authority linker will relink headings that have previously been linked every time it runs.',NULL,'YesNo'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('LinkerKeepStale',0,'If ON the authority linker will keep existing authority links for headings where it is unable to find a match.',NULL,'YesNo'); +INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('CatalogModuleRelink',0,'If OFF the linker will never replace the authids that are set in the cataloging module.',NULL,'YesNo'); --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/authorities.pref +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/authorities.pref @@ -65,3 +65,10 @@ Authorities: yes: Do no: "Do not" - keep existing links to authority records for headings where the linker is unable to find a match. + - + - pref: CatalogModuleRelink + default: no + choices: + yes: Do + no: "Do not" + - automatically relink headings that have previously been linked when saving records in the cataloging module. --