Bug 23392: Don't display private notes in MARC21

To test:
1 - Add some notes to a record in fields 541,542,561,583,590
2 - Ensure all of these are visible in the frameworks
3 - Note they appear in the 'Title notes'/'Description' tabs on OPAC/Staff client
4 - Mark first indicator '0' on all notes
5 - They still display
6 - Apply patch
7 - Notes no longer show on OPAC
8 - Notes still show on Staff client
9 - prove -v t/Biblio/GetMarcNotes.t

Signed-off-by: Myka Kennedy Stephens <mkstephens@lancasterseminary.edu>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Nick Clemens 2019-07-29 13:19:19 +00:00 committed by Martin Renvoize
parent 346f8b163a
commit d09083fc87
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
4 changed files with 27 additions and 5 deletions

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -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 {