|
Lines 700-711
sub AddAuthority {
Link Here
|
| 700 |
|
700 |
|
| 701 |
my $heading = $authority->heading_object( { record => $record } ); |
701 |
my $heading = $authority->heading_object( { record => $record } ); |
| 702 |
|
702 |
|
|
|
703 |
my $origincode = CalculateOriginCode( $record, $authtypecode ); |
| 704 |
|
| 703 |
# Update |
705 |
# Update |
| 704 |
$authority->update( |
706 |
$authority->update( |
| 705 |
{ |
707 |
{ |
| 706 |
authtypecode => $authtypecode, |
708 |
authtypecode => $authtypecode, |
| 707 |
marcxml => $record->as_xml_record($format), |
709 |
marcxml => $record->as_xml_record($format), |
| 708 |
heading => $heading ? $heading->display_form : '', |
710 |
heading => $heading ? $heading->display_form : '', |
|
|
711 |
origincode => $origincode, |
| 709 |
} |
712 |
} |
| 710 |
); |
713 |
); |
| 711 |
|
714 |
|
|
Lines 1269-1274
sub GetAuthorizedHeading {
Link Here
|
| 1269 |
return; |
1272 |
return; |
| 1270 |
} |
1273 |
} |
| 1271 |
|
1274 |
|
|
|
1275 |
=head2 CalculateOriginCode |
| 1276 |
|
| 1277 |
Finds the auth_header.origincode from the given MARC Authorities Record for the given MARC Authorities Framework |
| 1278 |
|
| 1279 |
=cut |
| 1280 |
|
| 1281 |
sub CalculateOriginCode { |
| 1282 |
my ( $record, $authtypecode ) = @_; |
| 1283 |
|
| 1284 |
my ( $tagfield, $tagsubfield ) = GetAuthMARCFromKohaField( 'auth_header.origincode', $authtypecode ); |
| 1285 |
if ( not( defined($tagfield) && defined($tagsubfield) ) || not( $record->subfield( $tagfield, $tagsubfield ) ) ) { |
| 1286 |
if ( C4::Context->preference('marcflavour') eq 'MARC21' ) { |
| 1287 |
return |
| 1288 |
$record->subfield( '040', 'c' ) |
| 1289 |
|| $record->subfield( '040', 'a' ) |
| 1290 |
|| $record->subfield( '024', '2' ) |
| 1291 |
|| $record->field('003') |
| 1292 |
|| ''; |
| 1293 |
} else { |
| 1294 |
warn "KohaToMARCMapping for 'auth_header.origincode' not set for '" |
| 1295 |
. C4::Context->preference('marcflavour') |
| 1296 |
. "' and don't know what fallbacks to use."; |
| 1297 |
return ''; |
| 1298 |
} |
| 1299 |
} |
| 1300 |
return $record->subfield( $tagfield, $tagsubfield ); |
| 1301 |
} |
| 1302 |
|
| 1272 |
=head2 CompareFieldWithAuthority |
1303 |
=head2 CompareFieldWithAuthority |
| 1273 |
|
1304 |
|
| 1274 |
$match = &CompareFieldWithAuthority({ field => $field, authid => $authid }) |
1305 |
$match = &CompareFieldWithAuthority({ field => $field, authid => $authid }) |