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