|
Lines 529-537
returns authid of the newly created authority
Link Here
|
| 529 |
|
529 |
|
| 530 |
sub AddAuthority { |
530 |
sub AddAuthority { |
| 531 |
# pass the MARC::Record to this function, and it will create the records in the authority table |
531 |
# pass the MARC::Record to this function, and it will create the records in the authority table |
| 532 |
my ($record,$authid,$authtypecode) = @_; |
532 |
my ($record,$authid,$authtypecode) = @_; |
| 533 |
my $dbh=C4::Context->dbh; |
533 |
my $dbh=C4::Context->dbh; |
| 534 |
my $leader=' nz a22 o 4500';#Leader for incomplete MARC21 record |
534 |
my $leader=' nz a22 o 4500';#Leader for incomplete MARC21 record |
| 535 |
|
535 |
|
| 536 |
# if authid empty => true add, find a new authid number |
536 |
# if authid empty => true add, find a new authid number |
| 537 |
my $format; |
537 |
my $format; |
|
Lines 553-559
sub AddAuthority {
Link Here
|
| 553 |
} |
553 |
} |
| 554 |
|
554 |
|
| 555 |
SetUTF8Flag($record); |
555 |
SetUTF8Flag($record); |
| 556 |
if ($format eq "MARC21") { |
556 |
if ($format eq "MARC21") { |
| 557 |
my $userenv = C4::Context->userenv; |
557 |
my $userenv = C4::Context->userenv; |
| 558 |
my $library; |
558 |
my $library; |
| 559 |
my $marcorgcode = C4::Context->preference('MARCOrgCode'); |
559 |
my $marcorgcode = C4::Context->preference('MARCOrgCode'); |
|
Lines 583-626
sub AddAuthority {
Link Here
|
| 583 |
|
583 |
|
| 584 |
$record->insert_fields_ordered( MARC::Field->new('008',$date.$default_008) ); |
584 |
$record->insert_fields_ordered( MARC::Field->new('008',$date.$default_008) ); |
| 585 |
} |
585 |
} |
| 586 |
if (!$record->field('040')) { |
586 |
if (!$record->field('040')) { |
| 587 |
$record->insert_fields_ordered( |
587 |
$record->insert_fields_ordered( MARC::Field->new('040','','', 'a' => $marcorgcode, 'c' => $marcorgcode )); |
| 588 |
MARC::Field->new('040','','', |
588 |
} |
| 589 |
'a' => $marcorgcode, |
|
|
| 590 |
'c' => $marcorgcode, |
| 591 |
) |
| 592 |
); |
| 593 |
} |
589 |
} |
| 594 |
} |
|
|
| 595 |
|
590 |
|
| 596 |
if ($format eq "UNIMARCAUTH") { |
591 |
if ($format eq "UNIMARCAUTH") { |
| 597 |
$record->leader(" nx j22 ") unless ($record->leader()); |
592 |
$record->leader(" nx j22 ") unless ($record->leader()); |
| 598 |
my $date=POSIX::strftime("%Y%m%d",localtime); |
593 |
my $date=POSIX::strftime("%Y%m%d",localtime); |
| 599 |
my $defaultfield100 = C4::Context->preference('UNIMARCAuthorityField100'); |
594 |
my $defaultfield100 = C4::Context->preference('UNIMARCAuthorityField100'); |
| 600 |
if (my $string=$record->subfield('100',"a")){ |
595 |
if (my $string=$record->subfield('100',"a")){ |
| 601 |
$string=~s/fre50/frey50/; |
596 |
$string=~s/fre50/frey50/; |
| 602 |
$record->field('100')->update('a'=>$string); |
597 |
$record->field('100')->update('a'=>$string); |
| 603 |
} |
598 |
} elsif ($record->field('100')){ |
| 604 |
elsif ($record->field('100')){ |
|
|
| 605 |
$record->field('100')->update('a'=>$date.$defaultfield100); |
599 |
$record->field('100')->update('a'=>$date.$defaultfield100); |
| 606 |
} else { |
600 |
} else { |
| 607 |
$record->append_fields( |
601 |
$record->append_fields( MARC::Field->new('100',' ',' ','a'=>$date.$defaultfield100) ); |
| 608 |
MARC::Field->new('100',' ',' ' |
602 |
} |
| 609 |
,'a'=>$date.$defaultfield100) |
603 |
} |
| 610 |
); |
604 |
my ($auth_type_tag, $auth_type_subfield) = get_auth_type_location($authtypecode); |
| 611 |
} |
605 |
if (!$authid and $format eq "MARC21") { |
| 612 |
} |
|
|
| 613 |
my ($auth_type_tag, $auth_type_subfield) = get_auth_type_location($authtypecode); |
| 614 |
if (!$authid and $format eq "MARC21") { |
| 615 |
# only need to do this fix when modifying an existing authority |
606 |
# only need to do this fix when modifying an existing authority |
| 616 |
C4::AuthoritiesMarc::MARC21::fix_marc21_auth_type_location($record, $auth_type_tag, $auth_type_subfield); |
607 |
C4::AuthoritiesMarc::MARC21::fix_marc21_auth_type_location($record, $auth_type_tag, $auth_type_subfield); |
| 617 |
} |
608 |
} |
| 618 |
if (my $field=$record->field($auth_type_tag)){ |
609 |
if (my $field=$record->field($auth_type_tag)){ |
| 619 |
$field->update($auth_type_subfield=>$authtypecode); |
610 |
$field->update($auth_type_subfield=>$authtypecode); |
| 620 |
} |
611 |
} |
| 621 |
else { |
612 |
else { |
| 622 |
$record->add_fields($auth_type_tag,'','', $auth_type_subfield=>$authtypecode); |
613 |
$record->add_fields($auth_type_tag,'','', $auth_type_subfield=>$authtypecode); |
| 623 |
} |
614 |
} |
| 624 |
|
615 |
|
| 625 |
# Save record into auth_header, update 001 |
616 |
# Save record into auth_header, update 001 |
| 626 |
if (!$authid ) { |
617 |
if (!$authid ) { |
| 627 |
- |
|
|