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

(-)a/C4/Biblio.pm (-29 / +45 lines)
Lines 401-420 sub ModBiblio { Link Here
401
        return 0;
401
        return 0;
402
    }
402
    }
403
403
404
    if ( C4::Context->preference("CataloguingLog") ) {
405
        my $biblio = Koha::Biblios->find($biblionumber);
406
        my $record;
407
        my $decoding_error = "";
408
        eval { $record = $biblio->metadata->record };
409
        if ($@) {
410
            my $exception = $@;
411
            $exception->rethrow unless ( $exception->isa('Koha::Exceptions::Metadata::Invalid') );
412
            $decoding_error = "There was an error with this bibliographic record: " . $exception;
413
            $record         = $biblio->metadata->record_strip_nonxml;
414
        }
415
        logaction( "CATALOGUING", "MODIFY", $biblionumber, "biblio $decoding_error BEFORE=>" . $record->as_formatted );
416
    }
417
418
    if ( !$options->{disable_autolink} && C4::Context->preference('AutoLinkBiblios') ) {
404
    if ( !$options->{disable_autolink} && C4::Context->preference('AutoLinkBiblios') ) {
419
        BiblioAutoLink( $record, $frameworkcode );
405
        BiblioAutoLink( $record, $frameworkcode );
420
    }
406
    }
Lines 465-491 sub ModBiblio { Link Here
465
    # update MARC subfield that stores biblioitems.cn_sort
451
    # update MARC subfield that stores biblioitems.cn_sort
466
    _koha_marc_update_biblioitem_cn_sort( $record, $oldbiblio, $frameworkcode );
452
    _koha_marc_update_biblioitem_cn_sort( $record, $oldbiblio, $frameworkcode );
467
453
468
    # update the MARC record (that now contains biblio and items) with the new record data
454
    my $schema = Koha::Database->schema;
469
    ModBiblioMarc( $record, $biblionumber, $mod_biblio_marc_options );
455
    my $result = 0;
456
    $schema->txn_do(
457
        sub {
470
458
471
    # modify the other koha tables
459
            my $biblio = Koha::Biblios->find($biblionumber);
472
    _koha_modify_biblio( $dbh, $oldbiblio, $frameworkcode );
460
            my $orig_rec;
473
    _koha_modify_biblioitem_nonmarc( $dbh, $oldbiblio );
461
            my $decoding_error = "";
462
            eval { $orig_rec = $biblio->metadata->record };
463
            if ($@) {
464
                my $exception = $@;
465
                $exception->rethrow unless ( $exception->isa('Koha::Exceptions::Metadata::Invalid') );
466
                $decoding_error = "There was an error with this bibliographic record: " . $exception;
467
                $orig_rec       = $biblio->metadata->record_strip_nonxml;
468
            }
469
            if ( $orig_rec->field('005')->as_string eq $record->field('005')->as_string ) {
474
470
475
    _after_biblio_action_hooks({ action => 'modify', biblio_id => $biblionumber });
471
                if ( C4::Context->preference("CataloguingLog") ) {
472
                    logaction(
473
                        "CATALOGUING", "MODIFY", $biblionumber,
474
                        "biblio $decoding_error BEFORE=>" . $orig_rec->as_formatted
475
                    );
476
                }
476
477
477
    # update OAI-PMH sets
478
                # update the MARC record (that now contains biblio and items) with the new record data
478
    if(C4::Context->preference("OAI-PMH:AutoUpdateSets")) {
479
                ModBiblioMarc( $record, $biblionumber, $mod_biblio_marc_options );
479
        C4::OAI::Sets::UpdateOAISetsBiblio($biblionumber, $record);
480
    }
481
480
482
    Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue(
481
                # modify the other koha tables
483
        {
482
                _koha_modify_biblio( $dbh, $oldbiblio, $frameworkcode );
484
            biblio_ids => [ $biblionumber ]
483
                _koha_modify_biblioitem_nonmarc( $dbh, $oldbiblio );
484
485
                _after_biblio_action_hooks( { action => 'modify', biblio_id => $biblionumber } );
486
487
                # update OAI-PMH sets
488
                if ( C4::Context->preference("OAI-PMH:AutoUpdateSets") ) {
489
                    C4::OAI::Sets::UpdateOAISetsBiblio( $biblionumber, $record );
490
                }
491
492
                Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( { biblio_ids => [$biblionumber] } )
493
                    unless $options->{skip_holds_queue}
494
                    or !C4::Context->preference('RealTimeHoldsQueue');
495
496
                $result = 1;
497
498
            } else {
499
                $result = -1;
500
            }
485
        }
501
        }
486
    ) unless $options->{skip_holds_queue} or !C4::Context->preference('RealTimeHoldsQueue');
502
    );
487
503
488
    return 1;
504
    return $result;
489
}
505
}
490
506
491
=head2 _strip_item_fields
507
=head2 _strip_item_fields
(-)a/cataloguing/addbiblio.pl (-1 / +24 lines)
Lines 705-711 if ( $op eq "cud-addbiblio" ) { Link Here
705
    if ( !$duplicatebiblionumber or $confirm_not_duplicate ) {
705
    if ( !$duplicatebiblionumber or $confirm_not_duplicate ) {
706
        my $oldbibitemnum;
706
        my $oldbibitemnum;
707
        if ( $is_a_modif ) {
707
        if ( $is_a_modif ) {
708
            ModBiblio(
708
            my $success = ModBiblio(
709
                $record,
709
                $record,
710
                $biblionumber,
710
                $biblionumber,
711
                $frameworkcode,
711
                $frameworkcode,
Lines 717-722 if ( $op eq "cud-addbiblio" ) { Link Here
717
                    }
717
                    }
718
                }
718
                }
719
            );
719
            );
720
            unless ( $success > 0 ) {
721
                $success ||= 1;
722
                build_tabs( $template, $record, $dbh, $encoding, $input );
723
                $template->param(
724
                    biblionumber          => $biblionumber,
725
                    biblioitemnumber      => $biblioitemnumber,
726
                    duplicatebiblionumber => $duplicatebiblionumber,
727
                    duplicatebibid        => $duplicatebiblionumber,
728
                    duplicatetitle        => $duplicatetitle,
729
                    mod_error             => $success
730
                );
731
                $template->param(
732
                    popup          => $mode,
733
                    frameworkcode  => $frameworkcode,
734
                    itemtype       => $frameworkcode,
735
                    borrowernumber => $loggedinuser,
736
                    tab            => scalar $input->param('tab')
737
                );
738
                $template->{'VARS'}->{'searchid'} = $searchid;
739
740
                output_html_with_http_headers $input, $cookie, $template->output;
741
                exit;
742
            }
720
        }
743
        }
721
        else {
744
        else {
722
            ( $biblionumber, $oldbibitemnum ) = AddBiblio( $record, $frameworkcode );
745
            ( $biblionumber, $oldbibitemnum ) = AddBiblio( $record, $frameworkcode );
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt (-2 / +13 lines)
Lines 879-885 $(document).ready(function(){ Link Here
879
                    [% END %]
879
                    [% END %]
880
                </h1>
880
                </h1>
881
881
882
                [% UNLESS ( number ) %]
882
                [% UNLESS ( number && !mod_error ) %]
883
                    <!-- show duplicate warning on tab 0 only -->
883
                    <!-- show duplicate warning on tab 0 only -->
884
                    [% IF ( duplicatebiblionumber ) %]
884
                    [% IF ( duplicatebiblionumber ) %]
885
                        <div class="dialog alert">
885
                        <div class="dialog alert">
Lines 905-910 $(document).ready(function(){ Link Here
905
                            </form>
905
                            </form>
906
                        </div> <!-- /.dialog.alert -->
906
                        </div> <!-- /.dialog.alert -->
907
                    [% END # /IF duplicatebiblionumber %]
907
                    [% END # /IF duplicatebiblionumber %]
908
                    [% IF (mod_error == -1 ) %]
909
                        <div class="dialog alert">
910
                            <h3>Record edited elsewhere</h3>
911
                            <p>Someone else beat you to it!</p>
912
                        </div>
913
                    [% ELSIF (mod_error == 1) %]
914
                        <div class="dialog alert">
915
                            <h3>Error</h3>
916
                            <p>Something is not right!</p>
917
                        </div>
918
                    [% END %]
919
908
                [% END # /UNLESS number %]
920
                [% END # /UNLESS number %]
909
921
910
                [% IF ( done ) %]
922
                [% IF ( done ) %]
911
- 

Return to bug 31109