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

(-)a/C4/Biblio.pm (-35 / +50 lines)
Lines 1105-1147 sub GetMarcSubfieldStructure { Link Here
1105
1105
1106
=head2 GetMarcFromKohaField
1106
=head2 GetMarcFromKohaField
1107
1107
1108
  ($MARCfield,$MARCsubfield)=GetMarcFromKohaField($kohafield,$frameworkcode);
1108
    ( $field,$subfield ) = GetMarcFromKohaField( $kohafield );
1109
    @fields = GetMarcFromKohaField( $kohafield );
1110
    $field = GetMarcFromKohaField( $kohafield );
1109
1111
1110
Returns the MARC fields & subfields mapped to the koha field 
1112
    Returns the MARC fields & subfields mapped to $kohafield.
1111
for the given frameworkcode or default framework if $frameworkcode is missing
1113
    Since the Default framework is considered as authoritative for such
1114
    mappings, the former frameworkcode parameter is obsoleted.
1115
1116
    In list context all mappings are returned; there can be multiple
1117
    mappings. Note that in the above example you could miss a second
1118
    mappings in the first call.
1119
    In scalar context only the field tag of the first mapping is returned.
1112
1120
1113
=cut
1121
=cut
1114
1122
1115
sub GetMarcFromKohaField {
1123
sub GetMarcFromKohaField {
1116
    my ( $kohafield, $frameworkcode ) = @_;
1124
    my ( $kohafield ) = @_;
1117
    return (0, undef) unless $kohafield;
1125
    return unless $kohafield;
1118
    my $mss = GetMarcSubfieldStructure( $frameworkcode );
1126
    # The next call uses the Default framework since it is AUTHORITATIVE
1127
    # for all Koha to MARC mappings.
1128
    my $mss = GetMarcSubfieldStructure( '' ); # Do not change framework
1119
    my @retval;
1129
    my @retval;
1120
    foreach( @{ $mss->{$kohafield} } ) {
1130
    foreach( @{ $mss->{$kohafield} } ) {
1121
        push @retval, $_->{tagfield}, $_->{tagsubfield};
1131
        push @retval, $_->{tagfield}, $_->{tagsubfield};
1122
    }
1132
    }
1123
    return wantarray ? @retval : $retval[0];
1133
    return wantarray ? @retval : ( @retval ? $retval[0] : undef );
1124
}
1134
}
1125
1135
1126
=head2 GetMarcSubfieldStructureFromKohaField
1136
=head2 GetMarcSubfieldStructureFromKohaField
1127
1137
1128
    my $subfield_structure = &GetMarcSubfieldStructureFromKohaField($kohafield, $frameworkcode);
1138
    my $str = GetMarcSubfieldStructureFromKohaField( $kohafield );
1129
1130
Returns a hashref where keys are marc_subfield_structure column names for the
1131
row where kohafield=$kohafield for the given framework code.
1132
In list context returns a list of those hashrefs in case duplicate Koha to
1133
MARC mappings exist.
1134
1139
1135
$frameworkcode is optional. If not given, then the default framework is used.
1140
    Returns marc subfield structure information for $kohafield.
1141
    The Default framework is used, since it is authoritative for kohafield
1142
    mappings.
1143
    In list context returns a list of all hashrefs, since there may be
1144
    multiple mappings. In scalar context the first hashref is returned.
1136
1145
1137
=cut
1146
=cut
1138
1147
1139
sub GetMarcSubfieldStructureFromKohaField {
1148
sub GetMarcSubfieldStructureFromKohaField {
1140
    my ( $kohafield, $frameworkcode ) = @_;
1149
    my ( $kohafield ) = @_;
1141
1150
1142
    return unless $kohafield;
1151
    return unless $kohafield;
1143
1152
1144
    my $mss = GetMarcSubfieldStructure( $frameworkcode );
1153
    # The next call uses the Default framework since it is AUTHORITATIVE
1154
    # for all Koha to MARC mappings.
1155
    my $mss = GetMarcSubfieldStructure(''); # Do not change framework
1145
    return unless $mss->{$kohafield};
1156
    return unless $mss->{$kohafield};
1146
    return wantarray ? @{$mss->{$kohafield}} : $mss->{$kohafield}->[0];
1157
    return wantarray ? @{$mss->{$kohafield}} : $mss->{$kohafield}->[0];
1147
}
1158
}
Lines 2140-2163 sub GetFrameworkCode { Link Here
2140
2151
2141
=head2 TransformKohaToMarc
2152
=head2 TransformKohaToMarc
2142
2153
2143
    $record = TransformKohaToMarc( $hash )
2154
    $record = TransformKohaToMarc( $hash [, $params ]  )
2144
2155
2145
This function builds partial MARC::Record from a hash
2156
This function builds a (partial) MARC::Record from a hash.
2146
Hash entries can be from biblio or biblioitems.
2157
Hash entries can be from biblio, biblioitems or items.
2158
The params hash includes the parameter no_split used in C4::Items.
2147
2159
2148
This function is called in acquisition module, to create a basic catalogue
2160
This function is called in acquisition module, to create a basic catalogue
2149
entry from user entry
2161
entry from user entry.
2150
2162
2151
=cut
2163
=cut
2152
2164
2153
2165
2154
sub TransformKohaToMarc {
2166
sub TransformKohaToMarc {
2155
    my ( $hash, $frameworkcode, $params ) = @_;
2167
    my ( $hash, $params ) = @_;
2156
    my $record = MARC::Record->new();
2168
    my $record = MARC::Record->new();
2157
    SetMarcUnicodeFlag( $record, C4::Context->preference("marcflavour") );
2169
    SetMarcUnicodeFlag( $record, C4::Context->preference("marcflavour") );
2158
    # NOTE: Many older calls do not include a frameworkcode. In that case
2170
2159
    # we default to Default framework.
2171
    # In the next call we use the Default framework, since it is considered
2160
    my $mss = GetMarcSubfieldStructure( $frameworkcode//'' );
2172
    # authoritative for Koha to Marc mappings.
2173
    my $mss = GetMarcSubfieldStructure( '' ); # do not change framework
2161
    my $tag_hr = {};
2174
    my $tag_hr = {};
2162
    while ( my ($kohafield, $value) = each %$hash ) {
2175
    while ( my ($kohafield, $value) = each %$hash ) {
2163
        foreach my $fld ( @{ $mss->{$kohafield} } ) {
2176
        foreach my $fld ( @{ $mss->{$kohafield} } ) {
Lines 2542-2560 sub TransformHtmlToMarc { Link Here
2542
2555
2543
=head2 TransformMarcToKoha
2556
=head2 TransformMarcToKoha
2544
2557
2545
  $result = TransformMarcToKoha( $record, $frameworkcode, $limit )
2558
    $result = TransformMarcToKoha( $record, undef, $limit )
2546
2559
2547
Extract data from a MARC bib record into a hashref representing
2560
Extract data from a MARC bib record into a hashref representing
2548
Koha biblio, biblioitems, and items fields. 
2561
Koha biblio, biblioitems, and items fields.
2549
2562
2550
If passed an undefined record will log the error and return an empty
2563
If passed an undefined record will log the error and return an empty
2551
hash_ref
2564
hash_ref.
2552
2565
2553
=cut
2566
=cut
2554
2567
2555
sub TransformMarcToKoha {
2568
sub TransformMarcToKoha {
2556
    my ( $record, $frameworkcode, $limit_table ) = @_;
2569
    my ( $record, $frameworkcode, $limit_table ) = @_;
2557
    $frameworkcode //= q{};
2570
    # FIXME  Parameter $frameworkcode is obsolete and will be removed
2558
    $limit_table //= q{};
2571
    $limit_table //= q{};
2559
2572
2560
    my $result = {};
2573
    my $result = {};
Lines 2568-2580 sub TransformMarcToKoha { Link Here
2568
        %tables = ( items => 1 );
2581
        %tables = ( items => 1 );
2569
    }
2582
    }
2570
2583
2571
    my $mss = GetMarcSubfieldStructure( $frameworkcode );
2584
    # The next call acknowledges Default as the authoritative framework
2585
    # for Koha to MARC mappings.
2586
    my $mss = GetMarcSubfieldStructure(''); # Do not change framework
2572
    foreach my $kohafield ( keys %{ $mss } ) {
2587
    foreach my $kohafield ( keys %{ $mss } ) {
2573
        my ( $table, $column ) = split /[.]/, $kohafield, 2;
2588
        my ( $table, $column ) = split /[.]/, $kohafield, 2;
2574
        next unless $tables{$table};
2589
        next unless $tables{$table};
2575
        my $val = TransformMarcToKohaOneField(
2590
        my $val = TransformMarcToKohaOneField( $kohafield, $record );
2576
            $kohafield, $record, $frameworkcode,
2577
        );
2578
        next if !defined $val;
2591
        next if !defined $val;
2579
        my $key = _disambiguate( $table, $column );
2592
        my $key = _disambiguate( $table, $column );
2580
        $result->{$key} = $val;
2593
        $result->{$key} = $val;
Lines 2623-2637 sub _disambiguate { Link Here
2623
2636
2624
=head2 TransformMarcToKohaOneField
2637
=head2 TransformMarcToKohaOneField
2625
2638
2626
    $val = TransformMarcToKohaOneField( 'biblio.title', $marc, $frameworkcode );
2639
    $val = TransformMarcToKohaOneField( 'biblio.title', $marc );
2640
2641
    Note: The authoritative Default framework is used implicitly.
2627
2642
2628
=cut
2643
=cut
2629
2644
2630
sub TransformMarcToKohaOneField {
2645
sub TransformMarcToKohaOneField {
2631
    my ( $kohafield, $marc, $frameworkcode ) = @_;
2646
    my ( $kohafield, $marc ) = @_;
2632
2647
2633
    my ( @rv, $retval );
2648
    my ( @rv, $retval );
2634
    my @mss = GetMarcSubfieldStructureFromKohaField($kohafield, $frameworkcode);
2649
    my @mss = GetMarcSubfieldStructureFromKohaField($kohafield);
2635
    foreach my $fldhash ( @mss ) {
2650
    foreach my $fldhash ( @mss ) {
2636
        my $tag = $fldhash->{tagfield};
2651
        my $tag = $fldhash->{tagfield};
2637
        my $sub = $fldhash->{tagsubfield};
2652
        my $sub = $fldhash->{tagsubfield};
(-)a/C4/Breeding.pm (-1 / +1 lines)
Lines 332-338 sub _add_rowdata { Link Here
332
        date2 => 'biblioitems.publicationyear', #UNIMARC
332
        date2 => 'biblioitems.publicationyear', #UNIMARC
333
    );
333
    );
334
    foreach my $k (keys %fetch) {
334
    foreach my $k (keys %fetch) {
335
        $row->{$k} = C4::Biblio::TransformMarcToKohaOneField( $fetch{$k}, $record, q{} ); # default framework
335
        $row->{$k} = C4::Biblio::TransformMarcToKohaOneField( $fetch{$k}, $record );
336
    }
336
    }
337
    $row->{date}//= $row->{date2};
337
    $row->{date}//= $row->{date2};
338
    $row->{isbn}=_isbn_replace($row->{isbn});
338
    $row->{isbn}=_isbn_replace($row->{isbn});
(-)a/C4/Items.pm (-8 / +7 lines)
Lines 441-450 Returns item record Link Here
441
=cut
441
=cut
442
442
443
sub _build_default_values_for_mod_marc {
443
sub _build_default_values_for_mod_marc {
444
    my ($frameworkcode) = @_;
444
    # Has no framework parameter anymore, since Default is authoritative
445
    # for Koha to MARC mappings.
445
446
446
    my $cache     = Koha::Caches->get_instance();
447
    my $cache     = Koha::Caches->get_instance();
447
    my $cache_key = "default_value_for_mod_marc-$frameworkcode";
448
    my $cache_key = "default_value_for_mod_marc-";
448
    my $cached    = $cache->get_from_cache($cache_key);
449
    my $cached    = $cache->get_from_cache($cache_key);
449
    return $cached if $cached;
450
    return $cached if $cached;
450
451
Lines 483-492 sub _build_default_values_for_mod_marc { Link Here
483
    while ( my ( $field, $default_value ) = each %$default_values ) {
484
    while ( my ( $field, $default_value ) = each %$default_values ) {
484
        my $kohafield = $field;
485
        my $kohafield = $field;
485
        $kohafield =~ s|^([^\.]+)$|items.$1|;
486
        $kohafield =~ s|^([^\.]+)$|items.$1|;
486
        $default_values_for_mod_from_marc{$field} =
487
        $default_values_for_mod_from_marc{$field} = $default_value
487
          $default_value
488
            if C4::Biblio::GetMarcFromKohaField( $kohafield );
488
          if C4::Koha::IsKohaFieldLinked(
489
            { kohafield => $kohafield, frameworkcode => $frameworkcode } );
490
    }
489
    }
491
490
492
    $cache->set_in_cache($cache_key, \%default_values_for_mod_from_marc);
491
    $cache->set_in_cache($cache_key, \%default_values_for_mod_from_marc);
Lines 505-511 sub ModItemFromMarc { Link Here
505
    my $localitemmarc = MARC::Record->new;
504
    my $localitemmarc = MARC::Record->new;
506
    $localitemmarc->append_fields( $item_marc->field($itemtag) );
505
    $localitemmarc->append_fields( $item_marc->field($itemtag) );
507
    my $item = &TransformMarcToKoha( $localitemmarc, $frameworkcode, 'items' );
506
    my $item = &TransformMarcToKoha( $localitemmarc, $frameworkcode, 'items' );
508
    my $default_values = _build_default_values_for_mod_marc($frameworkcode);
507
    my $default_values = _build_default_values_for_mod_marc();
509
    foreach my $item_field ( keys %$default_values ) {
508
    foreach my $item_field ( keys %$default_values ) {
510
        $item->{$item_field} = $default_values->{$item_field}
509
        $item->{$item_field} = $default_values->{$item_field}
511
          unless exists $item->{$item_field};
510
          unless exists $item->{$item_field};
Lines 1495-1501 sub Item2Marc { Link Here
1495
    };
1494
    };
1496
    my $framework = GetFrameworkCode( $biblionumber );
1495
    my $framework = GetFrameworkCode( $biblionumber );
1497
    my $itemmarc = TransformKohaToMarc(
1496
    my $itemmarc = TransformKohaToMarc(
1498
        $mungeditem, $framework, { no_split => 1},
1497
        $mungeditem, { no_split => 1},
1499
    );
1498
    );
1500
    my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField(
1499
    my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField(
1501
        "items.itemnumber", $framework,
1500
        "items.itemnumber", $framework,
(-)a/C4/Koha.pm (-26 lines)
Lines 1002-1033 sub GetVariationsOfISSNs { Link Here
1002
    return wantarray ? @issns : join( " | ", @issns );
1002
    return wantarray ? @issns : join( " | ", @issns );
1003
}
1003
}
1004
1004
1005
1006
=head2 IsKohaFieldLinked
1007
1008
    my $is_linked = IsKohaFieldLinked({
1009
        kohafield => $kohafield,
1010
        frameworkcode => $frameworkcode,
1011
    });
1012
1013
    Return 1 if the field is linked
1014
1015
=cut
1016
1017
sub IsKohaFieldLinked {
1018
    my ( $params ) = @_;
1019
    my $kohafield = $params->{kohafield};
1020
    my $frameworkcode = $params->{frameworkcode} || '';
1021
    my $dbh = C4::Context->dbh;
1022
    my $is_linked = $dbh->selectcol_arrayref( q|
1023
        SELECT COUNT(*)
1024
        FROM marc_subfield_structure
1025
        WHERE frameworkcode = ?
1026
        AND kohafield = ?
1027
    |,{}, $frameworkcode, $kohafield );
1028
    return $is_linked->[0];
1029
}
1030
1031
1;
1005
1;
1032
1006
1033
__END__
1007
__END__
(-)a/C4/XISBN.pm (-3 / +1 lines)
Lines 72-80 sub _get_biblio_from_xisbn { Link Here
72
    return unless ( !$errors && scalar @$results );
72
    return unless ( !$errors && scalar @$results );
73
73
74
    my $record = C4::Search::new_record_from_zebra( 'biblioserver', $results->[0] );
74
    my $record = C4::Search::new_record_from_zebra( 'biblioserver', $results->[0] );
75
    my $biblionumber = C4::Biblio::TransformMarcToKohaOneField(
75
    my $biblionumber = C4::Biblio::TransformMarcToKohaOneField( 'biblio.biblionumber', $record );
76
        'biblio.biblionumber', $record, # Default framework used
77
    );
78
    return unless $biblionumber;
76
    return unless $biblionumber;
79
77
80
    my $biblio = Koha::Biblios->find( $biblionumber );
78
    my $biblio = Koha::Biblios->find( $biblionumber );
(-)a/Koha/MetadataRecord.pm (-1 / +1 lines)
Lines 118-124 sub createMergeHash { Link Here
118
sub getKohaField {
118
sub getKohaField {
119
    my ($self, $kohafield) = @_;
119
    my ($self, $kohafield) = @_;
120
    if ($self->schema =~ m/marc/) {
120
    if ($self->schema =~ m/marc/) {
121
        return C4::Biblio::TransformMarcToKohaOneField($kohafield, $self->record); # Default framework used
121
        return C4::Biblio::TransformMarcToKohaOneField($kohafield, $self->record);
122
    }
122
    }
123
}
123
}
124
124
(-)a/admin/biblio_framework.pl (-2 / +2 lines)
Lines 80-86 if ( $op eq 'add_form' ) { Link Here
80
    }
80
    }
81
    $cache->clear_from_cache("MarcStructure-0-$frameworkcode");
81
    $cache->clear_from_cache("MarcStructure-0-$frameworkcode");
82
    $cache->clear_from_cache("MarcStructure-1-$frameworkcode");
82
    $cache->clear_from_cache("MarcStructure-1-$frameworkcode");
83
    $cache->clear_from_cache("default_value_for_mod_marc-$frameworkcode");
83
    $cache->clear_from_cache("default_value_for_mod_marc-");
84
    $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode");
84
    $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode");
85
    $op = 'list';
85
    $op = 'list';
86
} elsif ( $op eq 'delete_confirm' ) {
86
} elsif ( $op eq 'delete_confirm' ) {
Lines 111-117 if ( $op eq 'add_form' ) { Link Here
111
    }
111
    }
112
    $cache->clear_from_cache("MarcStructure-0-$frameworkcode");
112
    $cache->clear_from_cache("MarcStructure-0-$frameworkcode");
113
    $cache->clear_from_cache("MarcStructure-1-$frameworkcode");
113
    $cache->clear_from_cache("MarcStructure-1-$frameworkcode");
114
    $cache->clear_from_cache("default_value_for_mod_marc-$frameworkcode");
114
    $cache->clear_from_cache("default_value_for_mod_marc-");
115
    $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode");
115
    $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode");
116
    $op = 'list';
116
    $op = 'list';
117
}
117
}
(-)a/admin/marc_subfields_structure.pl (-2 / +2 lines)
Lines 338-344 elsif ( $op eq 'add_validate' ) { Link Here
338
    $sth_update->finish;
338
    $sth_update->finish;
339
    $cache->clear_from_cache("MarcStructure-0-$frameworkcode");
339
    $cache->clear_from_cache("MarcStructure-0-$frameworkcode");
340
    $cache->clear_from_cache("MarcStructure-1-$frameworkcode");
340
    $cache->clear_from_cache("MarcStructure-1-$frameworkcode");
341
    $cache->clear_from_cache("default_value_for_mod_marc-$frameworkcode");
341
    $cache->clear_from_cache("default_value_for_mod_marc-");
342
    $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode");
342
    $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode");
343
343
344
    print $input->redirect("/cgi-bin/koha/admin/marc_subfields_structure.pl?tagfield=$tagfield&frameworkcode=$frameworkcode");
344
    print $input->redirect("/cgi-bin/koha/admin/marc_subfields_structure.pl?tagfield=$tagfield&frameworkcode=$frameworkcode");
Lines 384-390 elsif ( $op eq 'delete_confirmed' ) { Link Here
384
    }
384
    }
385
    $cache->clear_from_cache("MarcStructure-0-$frameworkcode");
385
    $cache->clear_from_cache("MarcStructure-0-$frameworkcode");
386
    $cache->clear_from_cache("MarcStructure-1-$frameworkcode");
386
    $cache->clear_from_cache("MarcStructure-1-$frameworkcode");
387
    $cache->clear_from_cache("default_value_for_mod_marc-$frameworkcode");
387
    $cache->clear_from_cache("default_value_for_mod_marc-");
388
    $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode");
388
    $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode");
389
    print $input->redirect("/cgi-bin/koha/admin/marc_subfields_structure.pl?tagfield=$tagfield&frameworkcode=$frameworkcode");
389
    print $input->redirect("/cgi-bin/koha/admin/marc_subfields_structure.pl?tagfield=$tagfield&frameworkcode=$frameworkcode");
390
    exit;
390
    exit;
(-)a/admin/marctagstructure.pl (-2 / +2 lines)
Lines 149-155 if ($op eq 'add_form') { Link Here
149
        }
149
        }
150
        $cache->clear_from_cache("MarcStructure-0-$frameworkcode");
150
        $cache->clear_from_cache("MarcStructure-0-$frameworkcode");
151
        $cache->clear_from_cache("MarcStructure-1-$frameworkcode");
151
        $cache->clear_from_cache("MarcStructure-1-$frameworkcode");
152
        $cache->clear_from_cache("default_value_for_mod_marc-$frameworkcode");
152
        $cache->clear_from_cache("default_value_for_mod_marc-");
153
        $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode");
153
        $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode");
154
    }
154
    }
155
    print $input->redirect("/cgi-bin/koha/admin/marctagstructure.pl?searchfield=$tagfield&frameworkcode=$frameworkcode");
155
    print $input->redirect("/cgi-bin/koha/admin/marctagstructure.pl?searchfield=$tagfield&frameworkcode=$frameworkcode");
Lines 177-183 if ($op eq 'add_form') { Link Here
177
        $sth2->execute($searchfield, $frameworkcode);
177
        $sth2->execute($searchfield, $frameworkcode);
178
        $cache->clear_from_cache("MarcStructure-0-$frameworkcode");
178
        $cache->clear_from_cache("MarcStructure-0-$frameworkcode");
179
        $cache->clear_from_cache("MarcStructure-1-$frameworkcode");
179
        $cache->clear_from_cache("MarcStructure-1-$frameworkcode");
180
        $cache->clear_from_cache("default_value_for_mod_marc-$frameworkcode");
180
        $cache->clear_from_cache("default_value_for_mod_marc-");
181
        $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode");
181
        $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode");
182
	}
182
	}
183
	$template->param(
183
	$template->param(
(-)a/reports/acquisitions_stats.pl (-1 / +1 lines)
Lines 186-192 else { Link Here
186
186
187
    my @branches = Koha::Libraries->search({}, { order_by => 'branchname' });
187
    my @branches = Koha::Libraries->search({}, { order_by => 'branchname' });
188
188
189
    my $ccode_subfield_structure = GetMarcSubfieldStructureFromKohaField('items.ccode', '');
189
    my $ccode_subfield_structure = GetMarcSubfieldStructureFromKohaField('items.ccode');
190
    my $ccode_label;
190
    my $ccode_label;
191
    my $ccode_avlist;
191
    my $ccode_avlist;
192
    if($ccode_subfield_structure) {
192
    if($ccode_subfield_structure) {
(-)a/t/db_dependent/Koha/IsKohaFieldLinked.t (-45 lines)
Lines 1-44 Link Here
1
use Modern::Perl;
2
use Test::More;
3
4
use C4::Context;
5
use C4::Koha;
6
7
my $dbh = C4::Context->dbh;
8
$dbh->{RaiseError} = 1;
9
$dbh->{AutoCommit} = 0;
10
11
my $frameworkcode = 'FCUT';
12
$dbh->do( qq|
13
    INSERT INTO marc_subfield_structure(
14
        tagfield, tagsubfield, liblibrarian, kohafield, frameworkcode
15
    ) VALUES
16
        ('952', 'p', 'Barcode', 'items.barcode', '$frameworkcode'),
17
        ('952', '8', 'Collection code', 'items.ccode', '$frameworkcode'),
18
        ('952', '7', 'Not for loan', 'items.notforloan', '$frameworkcode'),
19
        ('952', 'y', 'Koha item type', 'items.itype', '$frameworkcode'),
20
        ('952', 'c', 'Permanent location', '', '$frameworkcode')
21
|);
22
23
is ( C4::Koha::IsKohaFieldLinked( {
24
    kohafield => 'items.barcode',
25
    frameworkcode => $frameworkcode,
26
}), 1, 'items.barcode is linked' );
27
28
is ( C4::Koha::IsKohaFieldLinked( {
29
    kohafield => 'items.notforloan',
30
    frameworkcode => $frameworkcode,
31
}), 1, 'items.notforloan is linked' );
32
33
is ( C4::Koha::IsKohaFieldLinked( {
34
    kohafield => 'notforloan',
35
    frameworkcode => $frameworkcode,
36
}), 0, 'notforloan is not linked' );
37
38
is ( C4::Koha::IsKohaFieldLinked( {
39
    kohafield => 'items.permanent_location',
40
    frameworkcode => $frameworkcode,
41
}), 0, 'items.permanent_location is not linked' );
42
43
44
done_testing;
45
- 

Return to bug 19096