|
Lines 99-104
use Koha::Caches;
Link Here
|
| 99 |
use Koha::Authority::Types; |
99 |
use Koha::Authority::Types; |
| 100 |
use Koha::Acquisition::Currencies; |
100 |
use Koha::Acquisition::Currencies; |
| 101 |
use Koha::Biblio::Metadatas; |
101 |
use Koha::Biblio::Metadatas; |
|
|
102 |
use Koha::MetadataRecord::Authority; |
| 102 |
use Koha::Holds; |
103 |
use Koha::Holds; |
| 103 |
use Koha::ItemTypes; |
104 |
use Koha::ItemTypes; |
| 104 |
use Koha::Plugins; |
105 |
use Koha::Plugins; |
|
Lines 1150-1165
sub GetMarcSubfieldStructureFromKohaField {
Link Here
|
| 1150 |
=head2 GetMarcBiblio |
1151 |
=head2 GetMarcBiblio |
| 1151 |
|
1152 |
|
| 1152 |
my $record = GetMarcBiblio({ |
1153 |
my $record = GetMarcBiblio({ |
| 1153 |
biblionumber => $biblionumber, |
1154 |
biblionumber => $biblionumber, |
| 1154 |
embed_items => $embeditems, |
1155 |
embed_items => $embeditems, |
| 1155 |
opac => $opac, |
1156 |
embed_seefromheadings => $embedseefromheadings, |
| 1156 |
borcat => $patron_category }); |
1157 |
opac => $opac, |
|
|
1158 |
borcat => $patron_category }); |
| 1157 |
|
1159 |
|
| 1158 |
Returns MARC::Record representing a biblio record, or C<undef> if the |
1160 |
Returns MARC::Record representing a biblio record, or C<undef> if the |
| 1159 |
biblionumber doesn't exist. |
1161 |
biblionumber doesn't exist. |
| 1160 |
|
1162 |
|
| 1161 |
Both embed_items and opac are optional. |
1163 |
embed_seefromheadings, embed_items and opac are optional. |
| 1162 |
If embed_items is passed and is 1, items are embedded. |
1164 |
If embed_items is passed and is 1, items are embedded. |
|
|
1165 |
If embed_seefromheading is passed and is 1, see-from headings are embedded. |
| 1163 |
If opac is passed and is 1, the record is filtered as needed. |
1166 |
If opac is passed and is 1, the record is filtered as needed. |
| 1164 |
|
1167 |
|
| 1165 |
=over 4 |
1168 |
=over 4 |
|
Lines 1195-1204
sub GetMarcBiblio {
Link Here
|
| 1195 |
return; |
1198 |
return; |
| 1196 |
} |
1199 |
} |
| 1197 |
|
1200 |
|
| 1198 |
my $biblionumber = $params->{biblionumber}; |
1201 |
my $biblionumber = $params->{biblionumber}; |
| 1199 |
my $embeditems = $params->{embed_items} || 0; |
1202 |
my $embeditems = $params->{embed_items} || 0; |
| 1200 |
my $opac = $params->{opac} || 0; |
1203 |
my $embedseefromheadings = $params->{embed_seefromheadings} || 0; |
| 1201 |
my $borcat = $params->{borcat} // q{}; |
1204 |
my $opac = $params->{opac} || 0; |
|
|
1205 |
my $borcat = $params->{borcat} // q{}; |
| 1202 |
|
1206 |
|
| 1203 |
if (not defined $biblionumber) { |
1207 |
if (not defined $biblionumber) { |
| 1204 |
carp 'GetMarcBiblio called with undefined biblionumber'; |
1208 |
carp 'GetMarcBiblio called with undefined biblionumber'; |
|
Lines 1232-1237
sub GetMarcBiblio {
Link Here
|
| 1232 |
opac => $opac, |
1236 |
opac => $opac, |
| 1233 |
borcat => $borcat }) |
1237 |
borcat => $borcat }) |
| 1234 |
if ($embeditems); |
1238 |
if ($embeditems); |
|
|
1239 |
C4::Biblio::EmbedSeeFromHeadings({ |
| 1240 |
marc_record => $record }) |
| 1241 |
if ($embedseefromheadings); |
| 1235 |
|
1242 |
|
| 1236 |
return $record; |
1243 |
return $record; |
| 1237 |
} |
1244 |
} |
|
Lines 2680-2685
sub EmbedItemsInMarcBiblio {
Link Here
|
| 2680 |
$marc->append_fields(@item_fields); |
2687 |
$marc->append_fields(@item_fields); |
| 2681 |
} |
2688 |
} |
| 2682 |
|
2689 |
|
|
|
2690 |
=head2 EmbedSeeFromHeadings |
| 2691 |
|
| 2692 |
EmbedSeeFromHeadings({ |
| 2693 |
marc_record => $record }); |
| 2694 |
|
| 2695 |
Given a MARC::Record object containing a bib record, |
| 2696 |
modify it to include see-from headings. |
| 2697 |
|
| 2698 |
=cut |
| 2699 |
|
| 2700 |
sub EmbedSeeFromHeadings { |
| 2701 |
my ($params) = @_; |
| 2702 |
my $record = $params->{marc_record}; |
| 2703 |
|
| 2704 |
my ($item_tag) = GetMarcFromKohaField("items.itemnumber", ''); |
| 2705 |
$item_tag ||= ''; |
| 2706 |
|
| 2707 |
foreach my $field ( $record->fields() ) { |
| 2708 |
next if $field->is_control_field(); |
| 2709 |
next if $field->tag() eq $item_tag; |
| 2710 |
my $authid = $field->subfield('9'); |
| 2711 |
|
| 2712 |
next unless $authid; |
| 2713 |
|
| 2714 |
my $authority = Koha::MetadataRecord::Authority->get_from_authid($authid); |
| 2715 |
next unless $authority; |
| 2716 |
my $auth_marc = $authority->record; |
| 2717 |
my @seefrom = $auth_marc->field('4..'); |
| 2718 |
my @newfields; |
| 2719 |
foreach my $authfield (@seefrom) { |
| 2720 |
my $tag = substr($field->tag(), 0, 1) . substr($authfield->tag(), 1, 2); |
| 2721 |
next if MARC::Field->is_controlfield_tag($tag); |
| 2722 |
my $newfield = MARC::Field->new($tag, |
| 2723 |
'z', |
| 2724 |
$authfield->indicator(2) || ' ', |
| 2725 |
'9' => '1'); |
| 2726 |
foreach my $sub ($authfield->subfields()) { |
| 2727 |
my ($code,$val) = @$sub; |
| 2728 |
$newfield->add_subfields( $code => $val ); |
| 2729 |
} |
| 2730 |
$newfield->delete_subfield( code => '9' ); |
| 2731 |
push @newfields, $newfield if (scalar($newfield->subfields()) > 0); |
| 2732 |
} |
| 2733 |
$record->append_fields(@newfields); |
| 2734 |
} |
| 2735 |
} |
| 2736 |
|
| 2683 |
=head1 INTERNAL FUNCTIONS |
2737 |
=head1 INTERNAL FUNCTIONS |
| 2684 |
|
2738 |
|
| 2685 |
=head2 _koha_marc_update_bib_ids |
2739 |
=head2 _koha_marc_update_bib_ids |