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

(-)a/C4/XSLT.pm (-11 / +8 lines)
Lines 31-38 use Koha::ItemTypes; Link Here
31
use Koha::XSLT::Base;
31
use Koha::XSLT::Base;
32
use Koha::Libraries;
32
use Koha::Libraries;
33
33
34
35
36
my $engine; #XSLT Handler object
34
my $engine; #XSLT Handler object
37
my %authval_per_framework;
35
my %authval_per_framework;
38
    # Cache for tagfield-tagsubfield to decode per framework.
36
    # Cache for tagfield-tagsubfield to decode per framework.
Lines 60-71 C4::XSLT - Functions for displaying XSLT-generated content Link Here
60
=head2 transformMARCXML4XSLT
58
=head2 transformMARCXML4XSLT
61
59
62
Replaces codes with authorized values in a MARC::Record object
60
Replaces codes with authorized values in a MARC::Record object
63
Is only used in this module currently.
64
61
65
=cut
62
=cut
66
63
67
sub transformMARCXML4XSLT {
64
sub transformMARCXML4XSLT {
68
    my ($biblionumber, $record) = @_;
65
    my ($biblionumber, $record, $opac) = @_;
69
    my $frameworkcode = GetFrameworkCode($biblionumber) || '';
66
    my $frameworkcode = GetFrameworkCode($biblionumber) || '';
70
    my $tagslib = &GetMarcStructure(1, $frameworkcode, { unsafe => 1 });
67
    my $tagslib = &GetMarcStructure(1, $frameworkcode, { unsafe => 1 });
71
    my @fields;
68
    my @fields;
Lines 84-90 sub transformMARCXML4XSLT { Link Here
84
                    my ( $letter, $value ) = @$subfield;
81
                    my ( $letter, $value ) = @$subfield;
85
                    # Replace the field value with the authorised value *except* for MARC21/NORMARC field 942$n (suppression in opac)
82
                    # Replace the field value with the authorised value *except* for MARC21/NORMARC field 942$n (suppression in opac)
86
                    if ( !( $tag eq '942' && $subfield->[0] eq 'n' ) || $marcflavour eq 'UNIMARC' ) {
83
                    if ( !( $tag eq '942' && $subfield->[0] eq 'n' ) || $marcflavour eq 'UNIMARC' ) {
87
                        $value = GetAuthorisedValueDesc( $tag, $letter, $value, '', $tagslib )
84
                        $value = GetAuthorisedValueDesc( $tag, $letter, $value, '', $tagslib, undef, $opac )
88
                            if $av->{ $tag }->{ $letter };
85
                            if $av->{ $tag }->{ $letter };
89
                    }
86
                    }
90
                    push( @new_subfields, $letter, $value );
87
                    push( @new_subfields, $letter, $value );
Lines 397-409 sub buildKohaItemsNamespace { Link Here
397
        else {
394
        else {
398
            $status = "available";
395
            $status = "available";
399
        }
396
        }
400
        my $homebranch     = xml_escape($branches{$item->homebranch});
397
        my $homebranch     = C4::Koha::xml_escape($branches{$item->homebranch});
401
        my $holdingbranch  = xml_escape($branches{$item->holdingbranch});
398
        my $holdingbranch  = C4::Koha::xml_escape($branches{$item->holdingbranch});
402
        my $resultbranch   = C4::Context->preference('OPACResultsLibrary') eq 'homebranch' ? $homebranch : $holdingbranch;
399
        my $resultbranch   = C4::Context->preference('OPACResultsLibrary') eq 'homebranch' ? $homebranch : $holdingbranch;
403
        my $location       = xml_escape($item->location && exists $shelflocations->{$item->location} ? $shelflocations->{$item->location} : $item->location);
400
        my $location       = C4::Koha::xml_escape($item->location && exists $shelflocations->{$item->location} ? $shelflocations->{$item->location} : $item->location);
404
        my $ccode          = xml_escape($item->ccode    && exists $ccodes->{$item->ccode}            ? $ccodes->{$item->ccode}            : $item->ccode);
401
        my $ccode          = C4::Koha::xml_escape($item->ccode    && exists $ccodes->{$item->ccode}            ? $ccodes->{$item->ccode}            : $item->ccode);
405
        my $itemcallnumber = xml_escape($item->itemcallnumber);
402
        my $itemcallnumber = C4::Koha::xml_escape($item->itemcallnumber);
406
        my $stocknumber    = xml_escape($item->stocknumber);
403
        my $stocknumber    = C4::Koha::xml_escape($item->stocknumber);
407
        $xml .=
404
        $xml .=
408
            "<item>"
405
            "<item>"
409
          . "<homebranch>$homebranch</homebranch>"
406
          . "<homebranch>$homebranch</homebranch>"
(-)a/Koha/Biblio.pm (-1 / +5 lines)
Lines 24-29 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 );
27
28
28
use Koha::Database;
29
use Koha::Database;
29
use Koha::DateUtils qw( dt_from_string );
30
use Koha::DateUtils qw( dt_from_string );
Lines 829-835 sub get_marc_notes { Link Here
829
830
830
    my %hiddenlist = map { $_ => 1 }
831
    my %hiddenlist = map { $_ => 1 }
831
        split( /,/, C4::Context->preference('NotesToHide'));
832
        split( /,/, C4::Context->preference('NotesToHide'));
832
    foreach my $field ( $self->metadata->record->field($scope) ) {
833
    my $record = $self->metadata->record;
834
    $record = transformMARCXML4XSLT( $self->biblionumber, $record, $opac );
835
836
    foreach my $field ( $record->field($scope) ) {
833
        my $tag = $field->tag();
837
        my $tag = $field->tag();
834
        next if $hiddenlist{ $tag };
838
        next if $hiddenlist{ $tag };
835
        next if $opac && $maybe_private{$tag} && !$field->indicator(1);
839
        next if $opac && $maybe_private{$tag} && !$field->indicator(1);
(-)a/t/db_dependent/Koha/Biblio.t (-4 / +16 lines)
Lines 22-27 use Test::More tests => 14; Link Here
22
use C4::Biblio qw( AddBiblio ModBiblio );
22
use C4::Biblio qw( AddBiblio ModBiblio );
23
use Koha::Database;
23
use Koha::Database;
24
use Koha::Acquisition::Orders;
24
use Koha::Acquisition::Orders;
25
use Koha::AuthorisedValueCategories;
26
use Koha::AuthorisedValues;
27
use Koha::MarcSubfieldStructures;
25
28
26
use t::lib::TestBuilder;
29
use t::lib::TestBuilder;
27
use t::lib::Mocks;
30
use t::lib::Mocks;
Lines 580-586 subtest 'subscriptions() tests' => sub { Link Here
580
};
583
};
581
584
582
subtest 'get_marc_notes() MARC21 tests' => sub {
585
subtest 'get_marc_notes() MARC21 tests' => sub {
583
    plan tests => 11;
586
    plan tests => 13;
584
587
585
    $schema->storage->txn_begin;
588
    $schema->storage->txn_begin;
586
589
Lines 594-615 subtest 'get_marc_notes() MARC21 tests' => sub { Link Here
594
        MARC::Field->new( '520', '', '', a => 'Note3 skipped' ),
597
        MARC::Field->new( '520', '', '', a => 'Note3 skipped' ),
595
        MARC::Field->new( '541', '0', '', a => 'Note4 skipped on opac' ),
598
        MARC::Field->new( '541', '0', '', a => 'Note4 skipped on opac' ),
596
        MARC::Field->new( '541', '', '', a => 'Note5' ),
599
        MARC::Field->new( '541', '', '', a => 'Note5' ),
600
        MARC::Field->new( '590', '', '', a => 'CODE' ),
597
    );
601
    );
602
603
    Koha::AuthorisedValueCategory->new({ category_name => 'TEST' })->store;
604
    Koha::AuthorisedValue->new({ category => 'TEST', authorised_value => 'CODE', lib => 'Description should show', lib_opac => 'Description should show OPAC' })->store;
605
    my $mss = Koha::MarcSubfieldStructures->find({tagfield => "590", tagsubfield => "a", frameworkcode => $biblio->frameworkcode });
606
    $mss->update({ authorised_value => "TEST" });
607
598
    C4::Biblio::ModBiblio( $record, $biblio->biblionumber );
608
    C4::Biblio::ModBiblio( $record, $biblio->biblionumber );
599
    $biblio = Koha::Biblios->find( $biblio->biblionumber);
609
    $biblio = Koha::Biblios->find( $biblio->biblionumber);
610
600
    my $notes = $biblio->get_marc_notes({ marcflavour => 'MARC21' });
611
    my $notes = $biblio->get_marc_notes({ marcflavour => 'MARC21' });
601
    is( $notes->[0]->{marcnote}, 'Note1', 'First note' );
612
    is( $notes->[0]->{marcnote}, 'Note1', 'First note' );
602
    is( $notes->[1]->{marcnote}, 'Note2', 'Second note' );
613
    is( $notes->[1]->{marcnote}, 'Note2', 'Second note' );
603
    is( $notes->[2]->{marcnote}, 'http://someserver.com', 'URL separated' );
614
    is( $notes->[2]->{marcnote}, 'http://someserver.com', 'URL separated' );
604
    is( $notes->[3]->{marcnote}, 'Note4 skipped on opac',"Not shows if not opac" );
615
    is( $notes->[3]->{marcnote}, 'Note4 skipped on opac',"Not shows if not opac" );
605
    is( $notes->[4]->{marcnote}, 'Note5', 'Fifth note' );
616
    is( $notes->[4]->{marcnote}, 'Note5', 'Fifth note' );
606
    is( @$notes, 5, 'No more notes' );
617
    is( $notes->[5]->{marcnote}, 'Description should show', 'Authorised value is correctly parsed to show description rather than code' );
618
    is( @$notes, 6, 'No more notes' );
607
    $notes = $biblio->get_marc_notes({ marcflavour => 'MARC21', opac => 1 });
619
    $notes = $biblio->get_marc_notes({ marcflavour => 'MARC21', opac => 1 });
608
    is( $notes->[0]->{marcnote}, 'Note1', 'First note' );
620
    is( $notes->[0]->{marcnote}, 'Note1', 'First note' );
609
    is( $notes->[1]->{marcnote}, 'Note2', 'Second note' );
621
    is( $notes->[1]->{marcnote}, 'Note2', 'Second note' );
610
    is( $notes->[2]->{marcnote}, 'http://someserver.com', 'URL separated' );
622
    is( $notes->[2]->{marcnote}, 'http://someserver.com', 'URL separated' );
611
    is( $notes->[3]->{marcnote}, 'Note5', 'Fifth note shows after fourth skipped' );
623
    is( $notes->[3]->{marcnote}, 'Note5', 'Fifth note shows after fourth skipped' );
612
    is( @$notes, 4, 'No more notes' );
624
    is( $notes->[4]->{marcnote}, 'Description should show OPAC', 'Authorised value is correctly parsed for OPAC to show description rather than code' );
625
    is( @$notes, 5, 'No more notes' );
613
626
614
    $schema->storage->txn_rollback;
627
    $schema->storage->txn_rollback;
615
};
628
};
616
- 

Return to bug 28734