|
Lines 186-216
The first argument is a C<MARC::Record> object containing the
Link Here
|
| 186 |
bib to add, while the second argument is the desired MARC |
186 |
bib to add, while the second argument is the desired MARC |
| 187 |
framework code. |
187 |
framework code. |
| 188 |
|
188 |
|
| 189 |
This function also accepts a third, optional argument: a hashref |
189 |
The C<$options> argument is a hashref with additional parameters: |
| 190 |
to additional options. The only defined option is C<defer_marc_save>, |
190 |
|
| 191 |
which if present and mapped to a true value, causes C<AddBiblio> |
191 |
=over 4 |
| 192 |
to omit the call to save the MARC in C<biblio_metadata.metadata> |
192 |
|
| 193 |
This option is provided B<only> |
193 |
=item C<defer_marc_save> |
| 194 |
for the use of scripts such as C<bulkmarcimport.pl> that may need |
194 |
|
| 195 |
to do some manipulation of the MARC record for item parsing before |
195 |
Causes C<AddBiblio> to omit the call to save the MARC in C<biblio_metadata.metadata> |
| 196 |
saving it and which cannot afford the performance hit of saving |
196 |
This option is provided B<only> for the use of scripts such as C<bulkmarcimport.pl> |
| 197 |
the MARC record twice. Consequently, do not use that option |
197 |
that may need to do some manipulation of the MARC record for item parsing before |
| 198 |
unless you can guarantee that C<ModBiblioMarc> will be called. |
198 |
saving it and which cannot afford the performance hit of saving the MARC record twice. |
|
|
199 |
Consequently, do not use that option unless you can guarantee that C<ModBiblioMarc> |
| 200 |
will be called. |
| 201 |
|
| 202 |
=item C<disable_autolink> |
| 203 |
|
| 204 |
Unless C<disable_autolink> is passed AddBiblio will link record headings |
| 205 |
to authorities based on settings in the system preferences. This flag allows |
| 206 |
us to not link records when the authority linker is saving modifications. |
| 207 |
|
| 208 |
=back |
| 199 |
|
209 |
|
| 200 |
=cut |
210 |
=cut |
| 201 |
|
211 |
|
| 202 |
sub AddBiblio { |
212 |
sub AddBiblio { |
| 203 |
my $record = shift; |
213 |
my ($record, $frameworkcode, $options) = @_; |
| 204 |
my $frameworkcode = shift; |
214 |
$options //= {}; |
| 205 |
my $options = @_ ? shift : undef; |
|
|
| 206 |
my $defer_marc_save = 0; |
| 207 |
if (!$record) { |
215 |
if (!$record) { |
| 208 |
carp('AddBiblio called with undefined record'); |
216 |
carp('AddBiblio called with undefined record'); |
| 209 |
return; |
217 |
return; |
| 210 |
} |
218 |
} |
| 211 |
if ( defined $options and exists $options->{'defer_marc_save'} and $options->{'defer_marc_save'} ) { |
|
|
| 212 |
$defer_marc_save = 1; |
| 213 |
} |
| 214 |
|
219 |
|
| 215 |
my $schema = Koha::Database->schema; |
220 |
my $schema = Koha::Database->schema; |
| 216 |
my ( $biblionumber, $biblioitemnumber ); |
221 |
my ( $biblionumber, $biblioitemnumber ); |
|
Lines 286-297
sub AddBiblio {
Link Here
|
| 286 |
# update MARC subfield that stores biblioitems.cn_sort |
291 |
# update MARC subfield that stores biblioitems.cn_sort |
| 287 |
_koha_marc_update_biblioitem_cn_sort( $record, $olddata, $frameworkcode ); |
292 |
_koha_marc_update_biblioitem_cn_sort( $record, $olddata, $frameworkcode ); |
| 288 |
|
293 |
|
| 289 |
if (C4::Context->preference('BiblioAddsAuthorities')) { |
294 |
if ($options->{'disable_autolink'} && C4::Context->preference('BiblioAddsAuthorities')) { |
| 290 |
BiblioAutoLink( $record, $frameworkcode ); |
295 |
BiblioAutoLink( $record, $frameworkcode ); |
| 291 |
} |
296 |
} |
| 292 |
|
297 |
|
| 293 |
# now add the record |
298 |
# now add the record |
| 294 |
ModBiblioMarc( $record, $biblionumber ) unless $defer_marc_save; |
299 |
ModBiblioMarc( $record, $biblionumber ) unless $options->{'defer_marc_save'}; |
| 295 |
|
300 |
|
| 296 |
# update OAI-PMH sets |
301 |
# update OAI-PMH sets |
| 297 |
if(C4::Context->preference("OAI-PMH:AutoUpdateSets")) { |
302 |
if(C4::Context->preference("OAI-PMH:AutoUpdateSets")) { |
|
Lines 545-550
sub BiblioAutoLink {
Link Here
|
| 545 |
my $record = shift; |
550 |
my $record = shift; |
| 546 |
my $frameworkcode = shift; |
551 |
my $frameworkcode = shift; |
| 547 |
my $verbose = shift; |
552 |
my $verbose = shift; |
|
|
553 |
|
| 548 |
if (!$record) { |
554 |
if (!$record) { |
| 549 |
carp('Undefined record passed to BiblioAutoLink'); |
555 |
carp('Undefined record passed to BiblioAutoLink'); |
| 550 |
return 0; |
556 |
return 0; |