|
Lines 42-48
use Koha::Caches;
Link Here
|
| 42 |
use Koha::Authority::Types; |
42 |
use Koha::Authority::Types; |
| 43 |
use Koha::Acquisition::Currencies; |
43 |
use Koha::Acquisition::Currencies; |
| 44 |
use Koha::Biblio::Metadata; |
44 |
use Koha::Biblio::Metadata; |
|
|
45 |
use Koha::Biblio::DeletedMetadata; |
| 45 |
use Koha::Biblio::Metadatas; |
46 |
use Koha::Biblio::Metadatas; |
|
|
47 |
use Koha::Biblio::DeletedMetadatas; |
| 46 |
use Koha::SearchEngine; |
48 |
use Koha::SearchEngine; |
| 47 |
use Koha::Libraries; |
49 |
use Koha::Libraries; |
| 48 |
|
50 |
|
|
Lines 257-263
sub AddBiblio {
Link Here
|
| 257 |
_koha_marc_update_biblioitem_cn_sort( $record, $olddata, $frameworkcode ); |
259 |
_koha_marc_update_biblioitem_cn_sort( $record, $olddata, $frameworkcode ); |
| 258 |
|
260 |
|
| 259 |
# now add the record |
261 |
# now add the record |
| 260 |
ModBiblioMarc( $record, $biblionumber, $frameworkcode ) unless $defer_marc_save; |
262 |
ModBiblioMarc( $record, $biblionumber, $biblioitemnumber, $frameworkcode ) unless $defer_marc_save; |
| 261 |
|
263 |
|
| 262 |
# update OAI-PMH sets |
264 |
# update OAI-PMH sets |
| 263 |
if(C4::Context->preference("OAI-PMH:AutoUpdateSets")) { |
265 |
if(C4::Context->preference("OAI-PMH:AutoUpdateSets")) { |
|
Lines 335-341
sub ModBiblio {
Link Here
|
| 335 |
_koha_marc_update_biblioitem_cn_sort( $record, $oldbiblio, $frameworkcode ); |
337 |
_koha_marc_update_biblioitem_cn_sort( $record, $oldbiblio, $frameworkcode ); |
| 336 |
|
338 |
|
| 337 |
# update the MARC record (that now contains biblio and items) with the new record data |
339 |
# update the MARC record (that now contains biblio and items) with the new record data |
| 338 |
&ModBiblioMarc( $record, $biblionumber, $frameworkcode ); |
340 |
&ModBiblioMarc( $record, $biblionumber, $biblioitemnumber, $frameworkcode ); |
| 339 |
|
341 |
|
| 340 |
# modify the other koha tables |
342 |
# modify the other koha tables |
| 341 |
_koha_modify_biblio( $dbh, $oldbiblio, $frameworkcode ); |
343 |
_koha_modify_biblio( $dbh, $oldbiblio, $frameworkcode ); |
|
Lines 426-432
sub DelBiblio {
Link Here
|
| 426 |
$sth->execute($biblionumber); |
428 |
$sth->execute($biblionumber); |
| 427 |
while ( my $biblioitemnumber = $sth->fetchrow ) { |
429 |
while ( my $biblioitemnumber = $sth->fetchrow ) { |
| 428 |
|
430 |
|
| 429 |
# delete this biblioitem |
431 |
#Handle biblio_metadata and deletedbiblio_metadata first before biblioitems operations CASCADE there |
|
|
432 |
$error = _koha_delete_biblio_metadata( $dbh, $biblioitemnumber, $biblionumber ); |
| 433 |
return $error if $error; |
| 434 |
|
| 430 |
$error = _koha_delete_biblioitems( $dbh, $biblioitemnumber ); |
435 |
$error = _koha_delete_biblioitems( $dbh, $biblioitemnumber ); |
| 431 |
return $error if $error; |
436 |
return $error if $error; |
| 432 |
} |
437 |
} |
|
Lines 436-441
sub DelBiblio {
Link Here
|
| 436 |
# delete cascade will prevent deletedbiblioitems rows |
441 |
# delete cascade will prevent deletedbiblioitems rows |
| 437 |
# from being generated by _koha_delete_biblioitems |
442 |
# from being generated by _koha_delete_biblioitems |
| 438 |
$error = _koha_delete_biblio( $dbh, $biblionumber ); |
443 |
$error = _koha_delete_biblio( $dbh, $biblionumber ); |
|
|
444 |
return $error if $error; |
| 439 |
|
445 |
|
| 440 |
logaction( "CATALOGUING", "DELETE", $biblionumber, "biblio" ) if C4::Context->preference("CataloguingLog"); |
446 |
logaction( "CATALOGUING", "DELETE", $biblionumber, "biblio" ) if C4::Context->preference("CataloguingLog"); |
| 441 |
|
447 |
|
|
Lines 3438-3448
sub _koha_delete_biblioitems {
Link Here
|
| 3438 |
return; |
3444 |
return; |
| 3439 |
} |
3445 |
} |
| 3440 |
|
3446 |
|
|
|
3447 |
=head2 _koha_delete_biblio_metadata |
| 3448 |
|
| 3449 |
$error = _koha_delete_biblio_metadata($dbh, $biblioitemnumber, $biblionumber); |
| 3450 |
|
| 3451 |
Internal sub for deleting from biblio_metadata table -- also saves to deletedbiblio_metadata |
| 3452 |
|
| 3453 |
C<$dbh> - the database handle |
| 3454 |
C<$biblioitemnumber> - the biblioitemnumber of the biblio_metadata to be deleted |
| 3455 |
|
| 3456 |
=cut |
| 3457 |
|
| 3458 |
# FIXME: add error handling |
| 3459 |
|
| 3460 |
sub _koha_delete_biblio_metadata { |
| 3461 |
my ( $dbh, $biblioitemnumber ) = @_; |
| 3462 |
|
| 3463 |
my $m = Koha::Biblio::Metadatas->find({biblioitemnumber => $biblioitemnumber}); |
| 3464 |
die "_koha_delete_biblio_metadata($biblioitemnumber):> No biblio_metadata-row!" unless $m; |
| 3465 |
|
| 3466 |
my $dm = Koha::Biblio::DeletedMetadata->new( $m->_result->{_column_data} ); |
| 3467 |
$dm->store; |
| 3468 |
$m->delete(); |
| 3469 |
return undef; |
| 3470 |
} |
| 3471 |
|
| 3441 |
=head1 UNEXPORTED FUNCTIONS |
3472 |
=head1 UNEXPORTED FUNCTIONS |
| 3442 |
|
3473 |
|
| 3443 |
=head2 ModBiblioMarc |
3474 |
=head2 ModBiblioMarc |
| 3444 |
|
3475 |
|
| 3445 |
&ModBiblioMarc($newrec,$biblionumber,$frameworkcode); |
3476 |
&ModBiblioMarc($newrec,$biblionumber,$biblioitemnumber,$frameworkcode); |
| 3446 |
|
3477 |
|
| 3447 |
Add MARC XML data for a biblio to koha |
3478 |
Add MARC XML data for a biblio to koha |
| 3448 |
|
3479 |
|
|
Lines 3453-3459
Function exported, but should NOT be used, unless you really know what you're do
Link Here
|
| 3453 |
sub ModBiblioMarc { |
3484 |
sub ModBiblioMarc { |
| 3454 |
# pass the MARC::Record to this function, and it will create the records in |
3485 |
# pass the MARC::Record to this function, and it will create the records in |
| 3455 |
# the marcxml field |
3486 |
# the marcxml field |
| 3456 |
my ( $record, $biblionumber, $frameworkcode ) = @_; |
3487 |
my ( $record, $biblionumber, $biblioitemnumber, $frameworkcode ) = @_; |
| 3457 |
if ( !$record ) { |
3488 |
if ( !$record ) { |
| 3458 |
carp 'ModBiblioMarc passed an undefined record'; |
3489 |
carp 'ModBiblioMarc passed an undefined record'; |
| 3459 |
return; |
3490 |
return; |
|
Lines 3500-3505
sub ModBiblioMarc {
Link Here
|
| 3500 |
} |
3531 |
} |
| 3501 |
|
3532 |
|
| 3502 |
my $metadata = { |
3533 |
my $metadata = { |
|
|
3534 |
biblioitemnumber => $biblioitemnumber, |
| 3503 |
biblionumber => $biblionumber, |
3535 |
biblionumber => $biblionumber, |
| 3504 |
format => 'marcxml', |
3536 |
format => 'marcxml', |
| 3505 |
marcflavour => C4::Context->preference('marcflavour'), |
3537 |
marcflavour => C4::Context->preference('marcflavour'), |