@@ -, +, @@ --- C4/Biblio.pm | 13 ++++++++++++- opac/opac-basket.pl | 2 +- opac/opac-detail.pl | 2 +- t/Biblio/GetMarcNotes.t | 15 +++++++++++++-- 4 files changed, 27 insertions(+), 5 deletions(-) --- a/C4/Biblio.pm +++ a/C4/Biblio.pm @@ -1495,7 +1495,7 @@ sub GetMarcISSN { =cut sub GetMarcNotes { - my ( $record, $marcflavour ) = @_; + my ( $record, $marcflavour, $opac ) = @_; if (!$record) { carp 'GetMarcNotes called on undefined record'; return; @@ -1503,11 +1503,22 @@ sub GetMarcNotes { my $scope = $marcflavour eq "UNIMARC"? '3..': '5..'; my @marcnotes; + + #MARC21 specs indicate some notes should be private if first indicator 0 + my %maybe_private = ( + 541 => 1, + 542 => 1, + 561 => 1, + 583 => 1, + 590 => 1 + ); + my %blacklist = map { $_ => 1 } split( /,/, C4::Context->preference('NotesBlacklist')); foreach my $field ( $record->field($scope) ) { my $tag = $field->tag(); next if $blacklist{ $tag }; + next if $opac && $maybe_private{$tag} && !$field->indicator(1); if( $marcflavour ne 'UNIMARC' && $field->subfield('u') ) { # Field 5XX$u always contains URI # Examples: 505u, 506u, 510u, 514u, 520u, 530u, 538u, 540u, 542u, 552u, 555u, 561u, 563u, 583u --- a/opac/opac-basket.pl +++ a/opac/opac-basket.pl @@ -81,7 +81,7 @@ foreach my $biblionumber ( @bibs ) { }); $record_processor->process($record); next unless $record; - my $marcnotesarray = GetMarcNotes( $record, $marcflavour ); + my $marcnotesarray = GetMarcNotes( $record, $marcflavour, 1 ); my $marcauthorsarray = GetMarcAuthors( $record, $marcflavour ); my $marcsubjctsarray = GetMarcSubjects( $record, $marcflavour ); my $marcseriesarray = GetMarcSeries ($record,$marcflavour); --- a/opac/opac-detail.pl +++ a/opac/opac-detail.pl @@ -766,7 +766,7 @@ if (!C4::Context->preference("OPACXSLTDetailsDisplay") ) { ); } -my $marcnotesarray = GetMarcNotes ($record,$marcflavour); +my $marcnotesarray = GetMarcNotes ($record,$marcflavour,1); if( C4::Context->preference('ArticleRequests') ) { my $patron = $borrowernumber ? Koha::Patrons->find($borrowernumber) : undef; --- a/t/Biblio/GetMarcNotes.t +++ a/t/Biblio/GetMarcNotes.t @@ -26,7 +26,7 @@ use MARC::Record; use C4::Biblio; subtest 'GetMarcNotes MARC21' => sub { - plan tests => 4; + plan tests => 11; t::lib::Mocks::mock_preference( 'NotesBlacklist', '520' ); my $record = MARC::Record->new; @@ -34,12 +34,23 @@ subtest 'GetMarcNotes MARC21' => sub { MARC::Field->new( '500', '', '', a => 'Note1' ), MARC::Field->new( '505', '', '', a => 'Note2', u => 'http://someserver.com' ), MARC::Field->new( '520', '', '', a => 'Note3 skipped' ), + MARC::Field->new( '541', '0', '', a => 'Note4 skipped on opac' ), + MARC::Field->new( '541', '', '', a => 'Note5' ), ); my $notes = C4::Biblio::GetMarcNotes( $record, 'MARC21' ); is( $notes->[0]->{marcnote}, 'Note1', 'First note' ); is( $notes->[1]->{marcnote}, 'Note2', 'Second note' ); is( $notes->[2]->{marcnote}, 'http://someserver.com', 'URL separated' ); - is( @$notes, 3, 'No more notes' ); + is( $notes->[3]->{marcnote}, 'Note4 skipped on opac',"Not shows if not opac" ); + is( $notes->[4]->{marcnote}, 'Note5', 'Fifth note' ); + is( @$notes, 5, 'No more notes' ); + $notes = C4::Biblio::GetMarcNotes( $record, 'MARC21', 1 ); + is( $notes->[0]->{marcnote}, 'Note1', 'First note' ); + is( $notes->[1]->{marcnote}, 'Note2', 'Second note' ); + is( $notes->[2]->{marcnote}, 'http://someserver.com', 'URL separated' ); + is( $notes->[3]->{marcnote}, 'Note5', 'Fifth note shows after fourth skipped' ); + is( @$notes, 4, 'No more notes' ); + }; subtest 'GetMarcNotes UNIMARC' => sub { --