use URI::Escape qw( uri_escape_utf8 );
use C4::Koha qw( GetNormalizedISBN );
-use C4::XSLT qw( transformMARCXML4XSLT );
use Koha::Database;
use Koha::DateUtils qw( dt_from_string );
use Koha::Libraries;
use Koha::Old::Checkouts;
use Koha::Recalls;
+use Koha::RecordProcessor;
use Koha::Suggestions;
use Koha::Subscriptions;
use Koha::SearchEngine;
my ( $self, $params ) = @_;
my $marcflavour = C4::Context->preference('marcflavour');
- my $opac = $params->{opac};
+ my $opac = $params->{opac} // '0';
+ my $interface = $params->{opac} ? 'opac' : 'intranet';
- my $scope = $marcflavour eq "UNIMARC"? '3..': '5..';
- my @marcnotes;
+ my $record = $params->{record} // $self->metadata->record;
+ my $record_processor = Koha::RecordProcessor->new(
+ {
+ filters => [ 'ViewPolicy', 'ExpandCodedFields' ],
+ options => {
+ interface => $interface,
+ frameworkcode => $self->frameworkcode
+ }
+ }
+ );
+ $record_processor->process($record);
+ my $scope = $marcflavour eq "UNIMARC"? '3..': '5..';
#MARC21 specs indicate some notes should be private if first indicator 0
my %maybe_private = (
541 => 1,
my %hiddenlist = map { $_ => 1 }
split( /,/, C4::Context->preference('NotesToHide'));
- my $record = $params->{record} // $self->metadata->record;
- $record = transformMARCXML4XSLT( $self->biblionumber, $record, $opac );
+ my @marcnotes;
foreach my $field ( $record->field($scope) ) {
my $tag = $field->tag();
next if $hiddenlist{ $tag };
};
subtest 'get_marc_notes() MARC21 tests' => sub {
- plan tests => 13;
+ plan tests => 14;
$schema->storage->txn_begin;
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' ),
+ MARC::Field->new( '544', '', '', a => 'Note5' ),
MARC::Field->new( '590', '', '', a => 'CODE' ),
+ MARC::Field->new( '545', '', '', a => 'Invisible on OPAC' ),
);
Koha::AuthorisedValueCategory->new({ category_name => 'TEST' })->store;
- Koha::AuthorisedValue->new({ category => 'TEST', authorised_value => 'CODE', lib => 'Description should show', lib_opac => 'Description should show OPAC' })->store;
+ Koha::AuthorisedValue->new(
+ {
+ category => 'TEST',
+ authorised_value => 'CODE',
+ lib => 'Description should show',
+ lib_opac => 'Description should show OPAC'
+ }
+ )->store;
my $mss = Koha::MarcSubfieldStructures->find({tagfield => "590", tagsubfield => "a", frameworkcode => $biblio->frameworkcode });
$mss->update({ authorised_value => "TEST" });
+ $mss = Koha::MarcSubfieldStructures->find({tagfield => "545", tagsubfield => "a", frameworkcode => $biblio->frameworkcode });
+ $mss->update({ hidden => 1 });
+
my $cache = Koha::Caches->get_instance;
$cache->clear_from_cache("MarcStructure-0-");
$cache->clear_from_cache("MarcStructure-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}, 'Note4 skipped on opac',"Not shows if not opac" );
+ is( $notes->[3]->{marcnote}, 'Note4 skipped on opac',"Note shows if not opac (Hidden by Indicator)" );
is( $notes->[4]->{marcnote}, 'Note5', 'Fifth note' );
is( $notes->[5]->{marcnote}, 'Description should show', 'Authorised value is correctly parsed to show description rather than code' );
- is( @$notes, 6, 'No more notes' );
+ is( $notes->[6]->{marcnote}, 'Invisible on OPAC', 'Note shows if not opac (Hidden by framework)' );
+ is( @$notes, 7, 'No more notes' );
$notes = $biblio->get_marc_notes({ opac => 1 });
is( $notes->[0]->{marcnote}, 'Note1', 'First note' );
is( $notes->[1]->{marcnote}, 'Note2', 'Second note' );