Bug 21365: Call BiblioAutoLink from AddBiblio and ModBiblio
authorEre Maijala <ere.maijala@helsinki.fi>
Sun, 16 Sep 2018 22:13:55 +0000 (01:13 +0300)
committerNick Clemens <nick@bywatersolutions.com>
Mon, 15 Oct 2018 13:11:53 +0000 (13:11 +0000)
This makes e.g. the advanced MARC editor, and anything that uses AddBiblio or
ModBiblio honor BiblioAddsAuthorities.

To test:
1. Make sure BiblioAddsAuthorities and AutoCreateAuthorities preferences are enabled.
2. Add a new record using advanced editor (enable EnableAdvancedCatalogingEditor to
use it), include a previously non-existing author.
3. Save the record and observe the author get an authority number.
4. Add another author, save the record and make sure it also gets an authority number.

Signed-off-by: Michal Denar <black23@gmail.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

C4/Biblio.pm
acqui/addorderiso2709.pl
acqui/neworderempty.pl
cataloguing/addbiblio.pl

index ccc3e3a..50c7c4c 100644 (file)
@@ -207,6 +207,10 @@ sub AddBiblio {
         $defer_marc_save = 1;
     }
 
+    if (C4::Context->preference('BiblioAddsAuthorities')) {
+        BiblioAutoLink( $record, $frameworkcode );
+    }
+
     my ( $biblionumber, $biblioitemnumber, $error );
     my $dbh = C4::Context->dbh;
 
@@ -268,6 +272,10 @@ sub ModBiblio {
         logaction( "CATALOGUING", "MODIFY", $biblionumber, "biblio BEFORE=>" . $newrecord->as_formatted );
     }
 
+    if (C4::Context->preference('BiblioAddsAuthorities')) {
+        BiblioAutoLink( $record, $frameworkcode );
+    }
+
     # Cleaning up invalid fields must be done early or SetUTF8Flag is liable to
     # throw an exception which probably won't be handled.
     foreach my $field ($record->fields()) {
index 91d8321..1921a5a 100755 (executable)
@@ -163,7 +163,7 @@ if ($op eq ""){
         my $c_sort1 = shift( @sort1 ) || $input->param('all_sort1') || '';
         my $c_sort2 = shift( @sort2 ) || $input->param('all_sort2') || '';
 
-        # 1st insert the biblio, or find it through matcher
+        # Insert the biblio, or find it through matcher
         unless ( $biblionumber ) {
             if ($matcher_id) {
                 if ( $matcher_id eq '_TITLE_AUTHOR_' ) {
@@ -194,10 +194,6 @@ if ($op eq ""){
             }
             ( $biblionumber, $bibitemnum ) = AddBiblio( $marcrecord, $cgiparams->{'frameworkcode'} || '' );
             SetImportRecordStatus( $biblio->{'import_record_id'}, 'imported' );
-            # 2nd add authorities if applicable
-            if (C4::Context->preference("BiblioAddsAuthorities")){
-                my $headings_linked =BiblioAutoLink($marcrecord, $cgiparams->{'frameworkcode'});
-            }
         } else {
             SetImportRecordStatus( $biblio->{'import_record_id'}, 'imported' );
         }
index 0e6f2c1..968ceec 100755 (executable)
@@ -164,9 +164,6 @@ if ( $ordernumber eq '' and defined $params->{'breedingid'}){
         exit;
     }
     #from this point: add a new record
-        if (C4::Context->preference("BiblioAddsAuthorities")){
-            my $headings_linked=BiblioAutoLink($marcrecord, $params->{'frameworkcode'});
-        }
         my $bibitemnum;
         $params->{'frameworkcode'} or $params->{'frameworkcode'} = "";
         ( $biblionumber, $bibitemnum ) = AddBiblio( $marcrecord, $params->{'frameworkcode'} );
index 11c6d38..9018929 100755 (executable)
@@ -831,9 +831,6 @@ if ( $op eq "addbiblio" ) {
     # it is not a duplicate (determined either by Koha itself or by user checking it's not a duplicate)
     if ( !$duplicatebiblionumber or $confirm_not_duplicate ) {
         my $oldbibitemnum;
-        if (C4::Context->preference("BiblioAddsAuthorities")){
-            BiblioAutoLink( $record, $frameworkcode );
-        } 
         if ( $is_a_modif ) {
             ModBiblio( $record, $biblionumber, $frameworkcode );
         }