|
Lines 395-412
sub ModBiblio {
Link Here
|
| 395 |
return 0; |
395 |
return 0; |
| 396 |
} |
396 |
} |
| 397 |
|
397 |
|
| 398 |
if ( C4::Context->preference("CataloguingLog") ) { |
398 |
my $record_before_mod; |
|
|
399 |
my $decoding_error = ""; |
| 400 |
if ( C4::Context->preference("CataloguingLog") || C4::Context->preference('AutoUpdateRecordStatus') ) { |
| 399 |
my $biblio = Koha::Biblios->find($biblionumber); |
401 |
my $biblio = Koha::Biblios->find($biblionumber); |
| 400 |
my $record; |
402 |
eval { $record_before_mod = $biblio->metadata->record }; |
| 401 |
my $decoding_error = ""; |
|
|
| 402 |
eval { $record = $biblio->metadata->record }; |
| 403 |
if ($@) { |
403 |
if ($@) { |
| 404 |
my $exception = $@; |
404 |
my $exception = $@; |
| 405 |
$exception->rethrow unless ( $exception->isa('Koha::Exceptions::Metadata::Invalid') ); |
405 |
$exception->rethrow unless ( $exception->isa('Koha::Exceptions::Metadata::Invalid') ); |
| 406 |
$decoding_error = "There was an error with this bibliographic record: " . $exception; |
406 |
$decoding_error = "There was an error with this bibliographic record: " . $exception; |
| 407 |
$record = $biblio->metadata->record_strip_nonxml; |
407 |
$record_before_mod = $biblio->metadata->record_strip_nonxml; |
|
|
408 |
} |
| 409 |
} |
| 410 |
|
| 411 |
if ( C4::Context->preference("CataloguingLog") ) { |
| 412 |
logaction( |
| 413 |
"CATALOGUING", "MODIFY", $biblionumber, |
| 414 |
"biblio $decoding_error BEFORE=>" . $record_before_mod->as_formatted |
| 415 |
); |
| 416 |
} |
| 417 |
|
| 418 |
if ( C4::Context->preference('AutoUpdateRecordStatus') && $record_before_mod ) { |
| 419 |
my $ldr_5 = substr( $record->leader, 5, 1 ); |
| 420 |
my $ldr_5_before_mod = substr( $record_before_mod->leader, 5, 1 ); |
| 421 |
if ( $ldr_5 ne 'c' && $ldr_5 eq $ldr_5_before_mod ) { # we update LDR/5 only if it has not been already changed |
| 422 |
_update_record_status( $record, $biblionumber ); |
| 408 |
} |
423 |
} |
| 409 |
logaction( "CATALOGUING", "MODIFY", $biblionumber, "biblio $decoding_error BEFORE=>" . $record->as_formatted ); |
|
|
| 410 |
} |
424 |
} |
| 411 |
|
425 |
|
| 412 |
if ( !$options->{disable_autolink} && C4::Context->preference('AutoLinkBiblios') ) { |
426 |
if ( !$options->{disable_autolink} && C4::Context->preference('AutoLinkBiblios') ) { |
|
Lines 3201-3206
sub _after_biblio_action_hooks {
Link Here
|
| 3201 |
); |
3215 |
); |
| 3202 |
} |
3216 |
} |
| 3203 |
|
3217 |
|
|
|
3218 |
=head2 _update_record_status |
| 3219 |
|
| 3220 |
_update_record_status( $record, $biblionumber ) |
| 3221 |
|
| 3222 |
Updates LDR/5 if need |
| 3223 |
|
| 3224 |
=cut |
| 3225 |
|
| 3226 |
sub _update_record_status { |
| 3227 |
my ( $record, $biblionumber ) = @_; |
| 3228 |
my $do_update_record_status; |
| 3229 |
my $marcflavour = C4::Context->preference("marcflavour"); |
| 3230 |
|
| 3231 |
# first - check date entered on file |
| 3232 |
my $today = POSIX::strftime( "%y%m%d", localtime ); |
| 3233 |
my $date_created = ''; |
| 3234 |
if ( $marcflavour eq 'MARC21' ) { |
| 3235 |
$date_created = substr( $record->field('008')->data, 0, 6 ) |
| 3236 |
if $record->field('008'); |
| 3237 |
} elsif ( $marcflavour eq 'UNIMARC' ) { |
| 3238 |
$date_created = substr( $record->subfield( '100', 'a' ), 2, 6 ) |
| 3239 |
if $record->subfield( '100', 'a' ); |
| 3240 |
|
| 3241 |
} |
| 3242 |
if ( $date_created && $date_created ne $today ) { |
| 3243 |
$do_update_record_status = 1; |
| 3244 |
} |
| 3245 |
|
| 3246 |
# second - if dates equal, check for 040 $d (for MARC 21) |
| 3247 |
if ( !$do_update_record_status |
| 3248 |
&& $marcflavour eq 'MARC21' |
| 3249 |
&& $record->subfield( '040', 'd' ) ) |
| 3250 |
{ |
| 3251 |
$do_update_record_status = 1; |
| 3252 |
} |
| 3253 |
|
| 3254 |
# third - if created today and no 040 $d, compare creator and modifier |
| 3255 |
if ( !$do_update_record_status ) { |
| 3256 |
if ( C4::Context->preference("CataloguingLog") ) { |
| 3257 |
my $logs = Koha::ActionLogs->search( |
| 3258 |
{ |
| 3259 |
module => 'CATALOGUING', |
| 3260 |
action => 'ADD', |
| 3261 |
object => $biblionumber |
| 3262 |
} |
| 3263 |
); |
| 3264 |
my $creator; |
| 3265 |
if ( my $log = $logs->next ) { |
| 3266 |
$creator = $log->user; |
| 3267 |
} |
| 3268 |
my $userenv = C4::Context->userenv(); |
| 3269 |
my $modifier; |
| 3270 |
$modifier = $userenv->{'number'} if ref($userenv) eq 'HASH'; |
| 3271 |
|
| 3272 |
# if not sure that modified by creator - set LDR/5 |
| 3273 |
unless ( defined $creator |
| 3274 |
&& defined $modifier |
| 3275 |
&& $creator == $modifier ) |
| 3276 |
{ |
| 3277 |
$do_update_record_status = 1; |
| 3278 |
} |
| 3279 |
} else { |
| 3280 |
$do_update_record_status = 1; |
| 3281 |
} |
| 3282 |
} |
| 3283 |
if ($do_update_record_status) { |
| 3284 |
my $leader = $record->leader; |
| 3285 |
substr( $leader, 5, 1, 'c' ); |
| 3286 |
$record->leader($leader); |
| 3287 |
} |
| 3288 |
} |
| 3289 |
|
| 3204 |
1; |
3290 |
1; |
| 3205 |
|
3291 |
|
| 3206 |
__END__ |
3292 |
__END__ |
| 3207 |
- |
|
|