|
Lines 311-317
sub AddBiblio {
Link Here
|
| 311 |
|
311 |
|
| 312 |
_after_biblio_action_hooks( { action => 'create', biblio_id => $biblionumber } ); |
312 |
_after_biblio_action_hooks( { action => 'create', biblio_id => $biblionumber } ); |
| 313 |
if ( C4::Context->preference("CataloguingLog") ) { |
313 |
if ( C4::Context->preference("CataloguingLog") ) { |
| 314 |
logaction( "CATALOGUING", "ADD", $biblionumber, "biblio", undef, Koha::Biblios->find($biblionumber) ); |
314 |
my $new_biblio = Koha::Biblios->find($biblionumber); |
|
|
315 |
my $marc_for_log = eval { $new_biblio->metadata->record_strip_nonxml }; |
| 316 |
logaction( |
| 317 |
"CATALOGUING", "ADD", $biblionumber, "biblio", undef, |
| 318 |
{ %{ $new_biblio->unblessed }, _marc => _marc_record_to_diffable($marc_for_log) } |
| 319 |
); |
| 315 |
} |
320 |
} |
| 316 |
|
321 |
|
| 317 |
# We index now, after the transaction is committed |
322 |
# We index now, after the transaction is committed |
|
Lines 397-405
sub ModBiblio {
Link Here
|
| 397 |
return 0; |
402 |
return 0; |
| 398 |
} |
403 |
} |
| 399 |
|
404 |
|
| 400 |
my $original; |
405 |
my ( $original, $original_marc ); |
| 401 |
if ( C4::Context->preference("CataloguingLog") ) { |
406 |
if ( C4::Context->preference("CataloguingLog") ) { |
| 402 |
$original = Koha::Biblios->find($biblionumber)->unblessed; |
407 |
my $pre_biblio = Koha::Biblios->find($biblionumber); |
|
|
408 |
$original = $pre_biblio->unblessed; |
| 409 |
$original_marc = eval { $pre_biblio->metadata->record_strip_nonxml }; |
| 403 |
} |
410 |
} |
| 404 |
|
411 |
|
| 405 |
if ( !$options->{disable_autolink} && C4::Context->preference('AutoLinkBiblios') ) { |
412 |
if ( !$options->{disable_autolink} && C4::Context->preference('AutoLinkBiblios') ) { |
|
Lines 463-469
sub ModBiblio {
Link Here
|
| 463 |
_after_biblio_action_hooks( { action => 'modify', biblio_id => $biblionumber } ); |
470 |
_after_biblio_action_hooks( { action => 'modify', biblio_id => $biblionumber } ); |
| 464 |
|
471 |
|
| 465 |
if ( C4::Context->preference("CataloguingLog") ) { |
472 |
if ( C4::Context->preference("CataloguingLog") ) { |
| 466 |
logaction( "CATALOGUING", "MODIFY", $biblionumber, Koha::Biblios->find($biblionumber), undef, $original ); |
473 |
my $updated_biblio = Koha::Biblios->find($biblionumber); |
|
|
474 |
my $updated_marc_log = eval { $updated_biblio->metadata->record_strip_nonxml }; |
| 475 |
logaction( |
| 476 |
"CATALOGUING", "MODIFY", $biblionumber, |
| 477 |
{ %{ $updated_biblio->unblessed }, _marc => _marc_record_to_diffable($updated_marc_log) }, |
| 478 |
undef, |
| 479 |
{ %{$original}, _marc => _marc_record_to_diffable($original_marc) } |
| 480 |
); |
| 467 |
} |
481 |
} |
| 468 |
|
482 |
|
| 469 |
# update OAI-PMH sets |
483 |
# update OAI-PMH sets |
|
Lines 487-492
MARC bib.
Link Here
|
| 487 |
|
501 |
|
| 488 |
=cut |
502 |
=cut |
| 489 |
|
503 |
|
|
|
504 |
sub _marc_record_to_diffable { |
| 505 |
my ($record) = @_; |
| 506 |
return {} unless defined $record; |
| 507 |
my %marc; |
| 508 |
for my $field ( $record->fields ) { |
| 509 |
my $tag = $field->tag; |
| 510 |
if ( $field->is_control_field ) { |
| 511 |
$marc{$tag} = $field->data; |
| 512 |
} else { |
| 513 |
my $ind1 = $field->indicator(1); |
| 514 |
my $ind2 = $field->indicator(2); |
| 515 |
my $formatted = "$ind1$ind2"; |
| 516 |
for my $subfield ( $field->subfields ) { |
| 517 |
$formatted .= " \$$subfield->[0] $subfield->[1]"; |
| 518 |
} |
| 519 |
push @{ $marc{$tag} }, $formatted; |
| 520 |
} |
| 521 |
} |
| 522 |
return \%marc; |
| 523 |
} |
| 524 |
|
| 490 |
sub _strip_item_fields { |
525 |
sub _strip_item_fields { |
| 491 |
my $record = shift; |
526 |
my $record = shift; |
| 492 |
my $frameworkcode = shift; |
527 |
my $frameworkcode = shift; |
|
Lines 533-538
sub DelBiblio {
Link Here
|
| 533 |
my $dbh = C4::Context->dbh; |
568 |
my $dbh = C4::Context->dbh; |
| 534 |
my $error; # for error handling |
569 |
my $error; # for error handling |
| 535 |
|
570 |
|
|
|
571 |
my $biblio_marc = |
| 572 |
C4::Context->preference("CataloguingLog") |
| 573 |
? eval { $biblio->metadata->record_strip_nonxml } |
| 574 |
: undef; |
| 575 |
|
| 536 |
# First make sure this biblio has no items attached |
576 |
# First make sure this biblio has no items attached |
| 537 |
my $sth = $dbh->prepare("SELECT itemnumber FROM items WHERE biblionumber=?"); |
577 |
my $sth = $dbh->prepare("SELECT itemnumber FROM items WHERE biblionumber=?"); |
| 538 |
$sth->execute($biblionumber); |
578 |
$sth->execute($biblionumber); |
|
Lines 585-592
sub DelBiblio {
Link Here
|
| 585 |
|
625 |
|
| 586 |
_after_biblio_action_hooks( { action => 'delete', biblio_id => $biblionumber } ); |
626 |
_after_biblio_action_hooks( { action => 'delete', biblio_id => $biblionumber } ); |
| 587 |
|
627 |
|
| 588 |
logaction( "CATALOGUING", "DELETE", $biblionumber, "biblio", undef, $biblio ) |
628 |
logaction( |
| 589 |
if C4::Context->preference("CataloguingLog"); |
629 |
"CATALOGUING", "DELETE", $biblionumber, "biblio", undef, |
|
|
630 |
{ %{ $biblio->unblessed }, _marc => _marc_record_to_diffable($biblio_marc) } |
| 631 |
) if C4::Context->preference("CataloguingLog"); |
| 590 |
|
632 |
|
| 591 |
Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( { biblio_ids => [$biblionumber] } ) |
633 |
Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( { biblio_ids => [$biblionumber] } ) |
| 592 |
unless $params->{skip_holds_queue} |
634 |
unless $params->{skip_holds_queue} |