View | Details | Raw Unified | Return to bug 30744
Collapse All | Expand All

(-)a/Koha/Biblio.pm (-6 / +16 lines)
Lines 24-30 use URI; Link Here
24
use URI::Escape qw( uri_escape_utf8 );
24
use URI::Escape qw( uri_escape_utf8 );
25
25
26
use C4::Koha qw( GetNormalizedISBN );
26
use C4::Koha qw( GetNormalizedISBN );
27
use C4::XSLT qw( transformMARCXML4XSLT );
28
27
29
use Koha::Database;
28
use Koha::Database;
30
use Koha::DateUtils qw( dt_from_string );
29
use Koha::DateUtils qw( dt_from_string );
Lines 42-47 use Koha::Items; Link Here
42
use Koha::Libraries;
41
use Koha::Libraries;
43
use Koha::Old::Checkouts;
42
use Koha::Old::Checkouts;
44
use Koha::Recalls;
43
use Koha::Recalls;
44
use Koha::RecordProcessor;
45
use Koha::Suggestions;
45
use Koha::Suggestions;
46
use Koha::Subscriptions;
46
use Koha::Subscriptions;
47
use Koha::SearchEngine;
47
use Koha::SearchEngine;
Lines 925-935 sub get_marc_notes { Link Here
925
    my ( $self, $params ) = @_;
925
    my ( $self, $params ) = @_;
926
926
927
    my $marcflavour = C4::Context->preference('marcflavour');
927
    my $marcflavour = C4::Context->preference('marcflavour');
928
    my $opac = $params->{opac};
928
    my $opac = $params->{opac} // '0';
929
    my $interface = $params->{opac} ? 'opac' : 'intranet';
929
930
930
    my $scope = $marcflavour eq "UNIMARC"? '3..': '5..';
931
    my $record = $self->metadata->record;
931
    my @marcnotes;
932
    my $record_processor = Koha::RecordProcessor->new(
933
        {
934
            filters => [ 'ViewPolicy', 'AuthorizedValues' ],
935
            options => {
936
                interface     => $interface,
937
                frameworkcode => $self->frameworkcode
938
            }
939
        }
940
    );
941
    $record_processor->process($record);
932
942
943
    my $scope = $marcflavour eq "UNIMARC"? '3..': '5..';
933
    #MARC21 specs indicate some notes should be private if first indicator 0
944
    #MARC21 specs indicate some notes should be private if first indicator 0
934
    my %maybe_private = (
945
    my %maybe_private = (
935
        541 => 1,
946
        541 => 1,
Lines 941-949 sub get_marc_notes { Link Here
941
952
942
    my %hiddenlist = map { $_ => 1 }
953
    my %hiddenlist = map { $_ => 1 }
943
        split( /,/, C4::Context->preference('NotesToHide'));
954
        split( /,/, C4::Context->preference('NotesToHide'));
944
    my $record = $self->metadata->record;
945
    $record = transformMARCXML4XSLT( $self->biblionumber, $record, $opac );
946
955
956
    my @marcnotes;
947
    foreach my $field ( $record->field($scope) ) {
957
    foreach my $field ( $record->field($scope) ) {
948
        my $tag = $field->tag();
958
        my $tag = $field->tag();
949
        next if $hiddenlist{ $tag };
959
        next if $hiddenlist{ $tag };
(-)a/t/db_dependent/Koha/Biblio.t (-6 / +17 lines)
Lines 668-674 subtest 'subscriptions() tests' => sub { Link Here
668
};
668
};
669
669
670
subtest 'get_marc_notes() MARC21 tests' => sub {
670
subtest 'get_marc_notes() MARC21 tests' => sub {
671
    plan tests => 13;
671
    plan tests => 14;
672
672
673
    $schema->storage->txn_begin;
673
    $schema->storage->txn_begin;
674
674
Lines 681-695 subtest 'get_marc_notes() MARC21 tests' => sub { Link Here
681
        MARC::Field->new( '505', '', '', a => 'Note2', u => 'http://someserver.com' ),
681
        MARC::Field->new( '505', '', '', a => 'Note2', u => 'http://someserver.com' ),
682
        MARC::Field->new( '520', '', '', a => 'Note3 skipped' ),
682
        MARC::Field->new( '520', '', '', a => 'Note3 skipped' ),
683
        MARC::Field->new( '541', '0', '', a => 'Note4 skipped on opac' ),
683
        MARC::Field->new( '541', '0', '', a => 'Note4 skipped on opac' ),
684
        MARC::Field->new( '541', '', '', a => 'Note5' ),
684
        MARC::Field->new( '544', '', '', a => 'Note5' ),
685
        MARC::Field->new( '590', '', '', a => 'CODE' ),
685
        MARC::Field->new( '590', '', '', a => 'CODE' ),
686
        MARC::Field->new( '545', '', '', a => 'Invisible on OPAC' ),
686
    );
687
    );
687
688
688
    Koha::AuthorisedValueCategory->new({ category_name => 'TEST' })->store;
689
    Koha::AuthorisedValueCategory->new({ category_name => 'TEST' })->store;
689
    Koha::AuthorisedValue->new({ category => 'TEST', authorised_value => 'CODE', lib => 'Description should show', lib_opac => 'Description should show OPAC' })->store;
690
    Koha::AuthorisedValue->new(
691
        {
692
            category         => 'TEST',
693
            authorised_value => 'CODE',
694
            lib              => 'Description should show',
695
            lib_opac         => 'Description should show OPAC'
696
        }
697
    )->store;
690
    my $mss = Koha::MarcSubfieldStructures->find({tagfield => "590", tagsubfield => "a", frameworkcode => $biblio->frameworkcode });
698
    my $mss = Koha::MarcSubfieldStructures->find({tagfield => "590", tagsubfield => "a", frameworkcode => $biblio->frameworkcode });
691
    $mss->update({ authorised_value => "TEST" });
699
    $mss->update({ authorised_value => "TEST" });
692
700
701
    $mss = Koha::MarcSubfieldStructures->find({tagfield => "545", tagsubfield => "a", frameworkcode => $biblio->frameworkcode });
702
    $mss->update({ hidden => 1 });
703
693
    my $cache = Koha::Caches->get_instance;
704
    my $cache = Koha::Caches->get_instance;
694
    $cache->clear_from_cache("MarcStructure-0-");
705
    $cache->clear_from_cache("MarcStructure-0-");
695
    $cache->clear_from_cache("MarcStructure-1-");
706
    $cache->clear_from_cache("MarcStructure-1-");
Lines 703-712 subtest 'get_marc_notes() MARC21 tests' => sub { Link Here
703
    is( $notes->[0]->{marcnote}, 'Note1', 'First note' );
714
    is( $notes->[0]->{marcnote}, 'Note1', 'First note' );
704
    is( $notes->[1]->{marcnote}, 'Note2', 'Second note' );
715
    is( $notes->[1]->{marcnote}, 'Note2', 'Second note' );
705
    is( $notes->[2]->{marcnote}, 'http://someserver.com', 'URL separated' );
716
    is( $notes->[2]->{marcnote}, 'http://someserver.com', 'URL separated' );
706
    is( $notes->[3]->{marcnote}, 'Note4 skipped on opac',"Not shows if not opac" );
717
    is( $notes->[3]->{marcnote}, 'Note4 skipped on opac',"Note shows if not opac (Hidden by Indicator)" );
707
    is( $notes->[4]->{marcnote}, 'Note5', 'Fifth note' );
718
    is( $notes->[4]->{marcnote}, 'Note5', 'Fifth note' );
708
    is( $notes->[5]->{marcnote}, 'Description should show', 'Authorised value is correctly parsed to show description rather than code' );
719
    is( $notes->[5]->{marcnote}, 'Description should show', 'Authorised value is correctly parsed to show description rather than code' );
709
    is( @$notes, 6, 'No more notes' );
720
    is( $notes->[6]->{marcnote}, 'Invisible on OPAC', 'Note shows if not opac (Hidden by framework)' );
721
    is( @$notes, 7, 'No more notes' );
710
    $notes = $biblio->get_marc_notes({ opac => 1 });
722
    $notes = $biblio->get_marc_notes({ opac => 1 });
711
    is( $notes->[0]->{marcnote}, 'Note1', 'First note' );
723
    is( $notes->[0]->{marcnote}, 'Note1', 'First note' );
712
    is( $notes->[1]->{marcnote}, 'Note2', 'Second note' );
724
    is( $notes->[1]->{marcnote}, 'Note2', 'Second note' );
713
- 

Return to bug 30744