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 933-943 sub get_marc_notes { Link Here
933
    my ( $self, $params ) = @_;
933
    my ( $self, $params ) = @_;
934
934
935
    my $marcflavour = C4::Context->preference('marcflavour');
935
    my $marcflavour = C4::Context->preference('marcflavour');
936
    my $opac = $params->{opac};
936
    my $opac = $params->{opac} // '0';
937
    my $interface = $params->{opac} ? 'opac' : 'intranet';
937
938
938
    my $scope = $marcflavour eq "UNIMARC"? '3..': '5..';
939
    my $record = $params->{record} // $self->metadata->record;
939
    my @marcnotes;
940
    my $record_processor = Koha::RecordProcessor->new(
941
        {
942
            filters => [ 'ViewPolicy', 'ExpandCodedFields' ],
943
            options => {
944
                interface     => $interface,
945
                frameworkcode => $self->frameworkcode
946
            }
947
        }
948
    );
949
    $record_processor->process($record);
940
950
951
    my $scope = $marcflavour eq "UNIMARC"? '3..': '5..';
941
    #MARC21 specs indicate some notes should be private if first indicator 0
952
    #MARC21 specs indicate some notes should be private if first indicator 0
942
    my %maybe_private = (
953
    my %maybe_private = (
943
        541 => 1,
954
        541 => 1,
Lines 949-957 sub get_marc_notes { Link Here
949
960
950
    my %hiddenlist = map { $_ => 1 }
961
    my %hiddenlist = map { $_ => 1 }
951
        split( /,/, C4::Context->preference('NotesToHide'));
962
        split( /,/, C4::Context->preference('NotesToHide'));
952
    my $record = $params->{record} // $self->metadata->record;
953
    $record = transformMARCXML4XSLT( $self->biblionumber, $record, $opac );
954
963
964
    my @marcnotes;
955
    foreach my $field ( $record->field($scope) ) {
965
    foreach my $field ( $record->field($scope) ) {
956
        my $tag = $field->tag();
966
        my $tag = $field->tag();
957
        next if $hiddenlist{ $tag };
967
        next if $hiddenlist{ $tag };
(-)a/t/db_dependent/Koha/Biblio.t (-6 / +17 lines)
Lines 679-685 subtest 'subscriptions() tests' => sub { Link Here
679
};
679
};
680
680
681
subtest 'get_marc_notes() MARC21 tests' => sub {
681
subtest 'get_marc_notes() MARC21 tests' => sub {
682
    plan tests => 13;
682
    plan tests => 14;
683
683
684
    $schema->storage->txn_begin;
684
    $schema->storage->txn_begin;
685
685
Lines 692-706 subtest 'get_marc_notes() MARC21 tests' => sub { Link Here
692
        MARC::Field->new( '505', '', '', a => 'Note2', u => 'http://someserver.com' ),
692
        MARC::Field->new( '505', '', '', a => 'Note2', u => 'http://someserver.com' ),
693
        MARC::Field->new( '520', '', '', a => 'Note3 skipped' ),
693
        MARC::Field->new( '520', '', '', a => 'Note3 skipped' ),
694
        MARC::Field->new( '541', '0', '', a => 'Note4 skipped on opac' ),
694
        MARC::Field->new( '541', '0', '', a => 'Note4 skipped on opac' ),
695
        MARC::Field->new( '541', '', '', a => 'Note5' ),
695
        MARC::Field->new( '544', '', '', a => 'Note5' ),
696
        MARC::Field->new( '590', '', '', a => 'CODE' ),
696
        MARC::Field->new( '590', '', '', a => 'CODE' ),
697
        MARC::Field->new( '545', '', '', a => 'Invisible on OPAC' ),
697
    );
698
    );
698
699
699
    Koha::AuthorisedValueCategory->new({ category_name => 'TEST' })->store;
700
    Koha::AuthorisedValueCategory->new({ category_name => 'TEST' })->store;
700
    Koha::AuthorisedValue->new({ category => 'TEST', authorised_value => 'CODE', lib => 'Description should show', lib_opac => 'Description should show OPAC' })->store;
701
    Koha::AuthorisedValue->new(
702
        {
703
            category         => 'TEST',
704
            authorised_value => 'CODE',
705
            lib              => 'Description should show',
706
            lib_opac         => 'Description should show OPAC'
707
        }
708
    )->store;
701
    my $mss = Koha::MarcSubfieldStructures->find({tagfield => "590", tagsubfield => "a", frameworkcode => $biblio->frameworkcode });
709
    my $mss = Koha::MarcSubfieldStructures->find({tagfield => "590", tagsubfield => "a", frameworkcode => $biblio->frameworkcode });
702
    $mss->update({ authorised_value => "TEST" });
710
    $mss->update({ authorised_value => "TEST" });
703
711
712
    $mss = Koha::MarcSubfieldStructures->find({tagfield => "545", tagsubfield => "a", frameworkcode => $biblio->frameworkcode });
713
    $mss->update({ hidden => 1 });
714
704
    my $cache = Koha::Caches->get_instance;
715
    my $cache = Koha::Caches->get_instance;
705
    $cache->clear_from_cache("MarcStructure-0-");
716
    $cache->clear_from_cache("MarcStructure-0-");
706
    $cache->clear_from_cache("MarcStructure-1-");
717
    $cache->clear_from_cache("MarcStructure-1-");
Lines 714-723 subtest 'get_marc_notes() MARC21 tests' => sub { Link Here
714
    is( $notes->[0]->{marcnote}, 'Note1', 'First note' );
725
    is( $notes->[0]->{marcnote}, 'Note1', 'First note' );
715
    is( $notes->[1]->{marcnote}, 'Note2', 'Second note' );
726
    is( $notes->[1]->{marcnote}, 'Note2', 'Second note' );
716
    is( $notes->[2]->{marcnote}, 'http://someserver.com', 'URL separated' );
727
    is( $notes->[2]->{marcnote}, 'http://someserver.com', 'URL separated' );
717
    is( $notes->[3]->{marcnote}, 'Note4 skipped on opac',"Not shows if not opac" );
728
    is( $notes->[3]->{marcnote}, 'Note4 skipped on opac',"Note shows if not opac (Hidden by Indicator)" );
718
    is( $notes->[4]->{marcnote}, 'Note5', 'Fifth note' );
729
    is( $notes->[4]->{marcnote}, 'Note5', 'Fifth note' );
719
    is( $notes->[5]->{marcnote}, 'Description should show', 'Authorised value is correctly parsed to show description rather than code' );
730
    is( $notes->[5]->{marcnote}, 'Description should show', 'Authorised value is correctly parsed to show description rather than code' );
720
    is( @$notes, 6, 'No more notes' );
731
    is( $notes->[6]->{marcnote}, 'Invisible on OPAC', 'Note shows if not opac (Hidden by framework)' );
732
    is( @$notes, 7, 'No more notes' );
721
    $notes = $biblio->get_marc_notes({ opac => 1 });
733
    $notes = $biblio->get_marc_notes({ opac => 1 });
722
    is( $notes->[0]->{marcnote}, 'Note1', 'First note' );
734
    is( $notes->[0]->{marcnote}, 'Note1', 'First note' );
723
    is( $notes->[1]->{marcnote}, 'Note2', 'Second note' );
735
    is( $notes->[1]->{marcnote}, 'Note2', 'Second note' );
724
- 

Return to bug 30744