Lines 1249-1260
sub GetMarcSubfieldStructureFromKohaField {
Link Here
|
1249 |
|
1249 |
|
1250 |
=head2 GetMarcBiblio |
1250 |
=head2 GetMarcBiblio |
1251 |
|
1251 |
|
1252 |
my $record = GetMarcBiblio($biblionumber, [$embeditems]); |
1252 |
my $record = GetMarcBiblio($biblionumber, [$embeditems], [$opac]); |
1253 |
|
1253 |
|
1254 |
Returns MARC::Record representing bib identified by |
1254 |
Returns MARC::Record representing a biblio record, or C<undef> if the |
1255 |
C<$biblionumber>. If no bib exists, returns undef. |
1255 |
biblionumber doesn't exist. |
1256 |
C<$embeditems>. If set to true, items data are included. |
1256 |
|
1257 |
The MARC record contains biblio data, and items data if $embeditems is set to true. |
1257 |
=over 4 |
|
|
1258 |
|
1259 |
=item C<$biblionumber> |
1260 |
|
1261 |
the biblionumber |
1262 |
|
1263 |
=item C<$embeditems> |
1264 |
|
1265 |
set to true to include item information. |
1266 |
|
1267 |
=item C<$opac> |
1268 |
|
1269 |
set to true to make the result suited for OPAC view. This causes things like |
1270 |
OpacHiddenItems to be applied. |
1271 |
|
1272 |
=back |
1258 |
|
1273 |
|
1259 |
=cut |
1274 |
=cut |
1260 |
|
1275 |
|
Lines 1278-1292
sub GetMarcBiblio {
Link Here
|
1278 |
my $record = MARC::Record->new(); |
1293 |
my $record = MARC::Record->new(); |
1279 |
|
1294 |
|
1280 |
if ($marcxml) { |
1295 |
if ($marcxml) { |
1281 |
$record = eval { MARC::Record::new_from_xml( $marcxml, "utf8", C4::Context->preference('marcflavour') ) }; |
1296 |
$record = eval { |
|
|
1297 |
MARC::Record::new_from_xml( $marcxml, "utf8", |
1298 |
C4::Context->preference('marcflavour') ); |
1299 |
}; |
1282 |
if ($@) { warn " problem with :$biblionumber : $@ \n$marcxml"; } |
1300 |
if ($@) { warn " problem with :$biblionumber : $@ \n$marcxml"; } |
1283 |
return unless $record; |
1301 |
return unless $record; |
1284 |
|
1302 |
|
1285 |
C4::Biblio::_koha_marc_update_bib_ids($record, $frameworkcode, $biblionumber, $biblioitemnumber); |
1303 |
C4::Biblio::_koha_marc_update_bib_ids( $record, $frameworkcode, $biblionumber, |
1286 |
C4::Biblio::EmbedItemsInMarcBiblio($record, $biblionumber) if ($embeditems); |
1304 |
$biblioitemnumber ); |
|
|
1305 |
C4::Biblio::EmbedItemsInMarcBiblio( $record, $biblionumber, undef, $opac ) |
1306 |
if ($embeditems); |
1287 |
|
1307 |
|
1288 |
return $record; |
1308 |
return $record; |
1289 |
} else { |
1309 |
} |
|
|
1310 |
else { |
1290 |
return; |
1311 |
return; |
1291 |
} |
1312 |
} |
1292 |
} |
1313 |
} |
Lines 2887-2903
sub ModZebra {
Link Here
|
2887 |
|
2908 |
|
2888 |
=head2 EmbedItemsInMarcBiblio |
2909 |
=head2 EmbedItemsInMarcBiblio |
2889 |
|
2910 |
|
2890 |
EmbedItemsInMarcBiblio($marc, $biblionumber, $itemnumbers); |
2911 |
EmbedItemsInMarcBiblio($marc, $biblionumber, $itemnumbers, $opac); |
2891 |
|
2912 |
|
2892 |
Given a MARC::Record object containing a bib record, |
2913 |
Given a MARC::Record object containing a bib record, |
2893 |
modify it to include the items attached to it as 9XX |
2914 |
modify it to include the items attached to it as 9XX |
2894 |
per the bib's MARC framework. |
2915 |
per the bib's MARC framework. |
2895 |
if $itemnumbers is defined, only specified itemnumbers are embedded |
2916 |
if $itemnumbers is defined, only specified itemnumbers are embedded. |
|
|
2917 |
|
2918 |
If $opac is true, then opac-relevant suppressions are included. |
2896 |
|
2919 |
|
2897 |
=cut |
2920 |
=cut |
2898 |
|
2921 |
|
2899 |
sub EmbedItemsInMarcBiblio { |
2922 |
sub EmbedItemsInMarcBiblio { |
2900 |
my ($marc, $biblionumber, $itemnumbers) = @_; |
2923 |
my ($marc, $biblionumber, $itemnumbers, $opac) = @_; |
2901 |
if ( !$marc ) { |
2924 |
if ( !$marc ) { |
2902 |
carp 'EmbedItemsInMarcBiblio: No MARC record passed'; |
2925 |
carp 'EmbedItemsInMarcBiblio: No MARC record passed'; |
2903 |
return; |
2926 |
return; |
Lines 2914-2923
sub EmbedItemsInMarcBiblio {
Link Here
|
2914 |
$sth->execute($biblionumber); |
2937 |
$sth->execute($biblionumber); |
2915 |
my @item_fields; |
2938 |
my @item_fields; |
2916 |
my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField( "items.itemnumber", $frameworkcode ); |
2939 |
my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField( "items.itemnumber", $frameworkcode ); |
2917 |
while (my ($itemnumber) = $sth->fetchrow_array) { |
2940 |
my @items; |
|
|
2941 |
my $opachiddenitems = $opac |
2942 |
&& ( C4::Context->preference('OpacHiddenItems') !~ /^\s*$/ ); |
2943 |
require C4::Items; |
2944 |
while ( my ($itemnumber) = $sth->fetchrow_array ) { |
2918 |
next if @$itemnumbers and not grep { $_ == $itemnumber } @$itemnumbers; |
2945 |
next if @$itemnumbers and not grep { $_ == $itemnumber } @$itemnumbers; |
2919 |
require C4::Items; |
2946 |
my $i = C4::Items::GetItem($itemnumber) if $opachiddenitems; |
2920 |
my $item_marc = C4::Items::GetMarcItem($biblionumber, $itemnumber); |
2947 |
push @items, { itemnumber => $itemnumber, item => $i }; |
|
|
2948 |
} |
2949 |
my @hiddenitems = |
2950 |
C4::Items::GetHiddenItemnumbers( map { $_->{item} } @items ) |
2951 |
if $opachiddenitems; |
2952 |
# Convert to a hash for quick searching |
2953 |
my %hiddenitems = map { $_ => 1 } @hiddenitems; |
2954 |
foreach my $itemnumber ( map { $_->{itemnumber} } @items ) { |
2955 |
next if $hiddenitems{$itemnumber}; |
2956 |
my $item_marc = C4::Items::GetMarcItem( $biblionumber, $itemnumber ); |
2921 |
push @item_fields, $item_marc->field($itemtag); |
2957 |
push @item_fields, $item_marc->field($itemtag); |
2922 |
} |
2958 |
} |
2923 |
$marc->append_fields(@item_fields); |
2959 |
$marc->append_fields(@item_fields); |
2924 |
- |
|
|