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

(-)a/C4/Biblio.pm (-35 / +50 lines)
Lines 1109-1151 sub GetMarcSubfieldStructure { Link Here
1109
1109
1110
=head2 GetMarcFromKohaField
1110
=head2 GetMarcFromKohaField
1111
1111
1112
  ($MARCfield,$MARCsubfield)=GetMarcFromKohaField($kohafield,$frameworkcode);
1112
    ( $field,$subfield ) = GetMarcFromKohaField( $kohafield );
1113
    @fields = GetMarcFromKohaField( $kohafield );
1114
    $field = GetMarcFromKohaField( $kohafield );
1113
1115
1114
Returns the MARC fields & subfields mapped to the koha field 
1116
    Returns the MARC fields & subfields mapped to $kohafield.
1115
for the given frameworkcode or default framework if $frameworkcode is missing
1117
    Since the Default framework is considered as authoritative for such
1118
    mappings, the former frameworkcode parameter is obsoleted.
1119
1120
    In list context all mappings are returned; there can be multiple
1121
    mappings. Note that in the above example you could miss a second
1122
    mappings in the first call.
1123
    In scalar context only the field tag of the first mapping is returned.
1116
1124
1117
=cut
1125
=cut
1118
1126
1119
sub GetMarcFromKohaField {
1127
sub GetMarcFromKohaField {
1120
    my ( $kohafield, $frameworkcode ) = @_;
1128
    my ( $kohafield ) = @_;
1121
    return (0, undef) unless $kohafield;
1129
    return unless $kohafield;
1122
    my $mss = GetMarcSubfieldStructure( $frameworkcode );
1130
    # The next call uses the Default framework since it is AUTHORITATIVE
1131
    # for all Koha to MARC mappings.
1132
    my $mss = GetMarcSubfieldStructure( '' ); # Do not change framework
1123
    my @retval;
1133
    my @retval;
1124
    foreach( @{ $mss->{$kohafield} } ) {
1134
    foreach( @{ $mss->{$kohafield} } ) {
1125
        push @retval, $_->{tagfield}, $_->{tagsubfield};
1135
        push @retval, $_->{tagfield}, $_->{tagsubfield};
1126
    }
1136
    }
1127
    return wantarray ? @retval : $retval[0];
1137
    return wantarray ? @retval : ( @retval ? $retval[0] : undef );
1128
}
1138
}
1129
1139
1130
=head2 GetMarcSubfieldStructureFromKohaField
1140
=head2 GetMarcSubfieldStructureFromKohaField
1131
1141
1132
    my $subfield_structure = &GetMarcSubfieldStructureFromKohaField($kohafield, $frameworkcode);
1142
    my $str = GetMarcSubfieldStructureFromKohaField( $kohafield );
1133
1134
Returns a hashref where keys are marc_subfield_structure column names for the
1135
row where kohafield=$kohafield for the given framework code.
1136
In list context returns a list of those hashrefs in case duplicate Koha to
1137
MARC mappings exist.
1138
1143
1139
$frameworkcode is optional. If not given, then the default framework is used.
1144
    Returns marc subfield structure information for $kohafield.
1145
    The Default framework is used, since it is authoritative for kohafield
1146
    mappings.
1147
    In list context returns a list of all hashrefs, since there may be
1148
    multiple mappings. In scalar context the first hashref is returned.
1140
1149
1141
=cut
1150
=cut
1142
1151
1143
sub GetMarcSubfieldStructureFromKohaField {
1152
sub GetMarcSubfieldStructureFromKohaField {
1144
    my ( $kohafield, $frameworkcode ) = @_;
1153
    my ( $kohafield ) = @_;
1145
1154
1146
    return unless $kohafield;
1155
    return unless $kohafield;
1147
1156
1148
    my $mss = GetMarcSubfieldStructure( $frameworkcode );
1157
    # The next call uses the Default framework since it is AUTHORITATIVE
1158
    # for all Koha to MARC mappings.
1159
    my $mss = GetMarcSubfieldStructure(''); # Do not change framework
1149
    return unless $mss->{$kohafield};
1160
    return unless $mss->{$kohafield};
1150
    return wantarray ? @{$mss->{$kohafield}} : $mss->{$kohafield}->[0];
1161
    return wantarray ? @{$mss->{$kohafield}} : $mss->{$kohafield}->[0];
1151
}
1162
}
Lines 2158-2181 sub GetFrameworkCode { Link Here
2158
2169
2159
=head2 TransformKohaToMarc
2170
=head2 TransformKohaToMarc
2160
2171
2161
    $record = TransformKohaToMarc( $hash )
2172
    $record = TransformKohaToMarc( $hash [, $params ]  )
2162
2173
2163
This function builds partial MARC::Record from a hash
2174
This function builds a (partial) MARC::Record from a hash.
2164
Hash entries can be from biblio or biblioitems.
2175
Hash entries can be from biblio, biblioitems or items.
2176
The params hash includes the parameter no_split used in C4::Items.
2165
2177
2166
This function is called in acquisition module, to create a basic catalogue
2178
This function is called in acquisition module, to create a basic catalogue
2167
entry from user entry
2179
entry from user entry.
2168
2180
2169
=cut
2181
=cut
2170
2182
2171
2183
2172
sub TransformKohaToMarc {
2184
sub TransformKohaToMarc {
2173
    my ( $hash, $frameworkcode, $params ) = @_;
2185
    my ( $hash, $params ) = @_;
2174
    my $record = MARC::Record->new();
2186
    my $record = MARC::Record->new();
2175
    SetMarcUnicodeFlag( $record, C4::Context->preference("marcflavour") );
2187
    SetMarcUnicodeFlag( $record, C4::Context->preference("marcflavour") );
2176
    # NOTE: Many older calls do not include a frameworkcode. In that case
2188
2177
    # we default to Default framework.
2189
    # In the next call we use the Default framework, since it is considered
2178
    my $mss = GetMarcSubfieldStructure( $frameworkcode//'' );
2190
    # authoritative for Koha to Marc mappings.
2191
    my $mss = GetMarcSubfieldStructure( '' ); # do not change framework
2179
    my $tag_hr = {};
2192
    my $tag_hr = {};
2180
    while ( my ($kohafield, $value) = each %$hash ) {
2193
    while ( my ($kohafield, $value) = each %$hash ) {
2181
        foreach my $fld ( @{ $mss->{$kohafield} } ) {
2194
        foreach my $fld ( @{ $mss->{$kohafield} } ) {
Lines 2560-2578 sub TransformHtmlToMarc { Link Here
2560
2573
2561
=head2 TransformMarcToKoha
2574
=head2 TransformMarcToKoha
2562
2575
2563
  $result = TransformMarcToKoha( $record, $frameworkcode, $limit )
2576
    $result = TransformMarcToKoha( $record, undef, $limit )
2564
2577
2565
Extract data from a MARC bib record into a hashref representing
2578
Extract data from a MARC bib record into a hashref representing
2566
Koha biblio, biblioitems, and items fields. 
2579
Koha biblio, biblioitems, and items fields.
2567
2580
2568
If passed an undefined record will log the error and return an empty
2581
If passed an undefined record will log the error and return an empty
2569
hash_ref
2582
hash_ref.
2570
2583
2571
=cut
2584
=cut
2572
2585
2573
sub TransformMarcToKoha {
2586
sub TransformMarcToKoha {
2574
    my ( $record, $frameworkcode, $limit_table ) = @_;
2587
    my ( $record, $frameworkcode, $limit_table ) = @_;
2575
    $frameworkcode //= q{};
2588
    # FIXME  Parameter $frameworkcode is obsolete and will be removed
2576
    $limit_table //= q{};
2589
    $limit_table //= q{};
2577
2590
2578
    my $result = {};
2591
    my $result = {};
Lines 2586-2598 sub TransformMarcToKoha { Link Here
2586
        %tables = ( items => 1 );
2599
        %tables = ( items => 1 );
2587
    }
2600
    }
2588
2601
2589
    my $mss = GetMarcSubfieldStructure( $frameworkcode );
2602
    # The next call acknowledges Default as the authoritative framework
2603
    # for Koha to MARC mappings.
2604
    my $mss = GetMarcSubfieldStructure(''); # Do not change framework
2590
    foreach my $kohafield ( keys %{ $mss } ) {
2605
    foreach my $kohafield ( keys %{ $mss } ) {
2591
        my ( $table, $column ) = split /[.]/, $kohafield, 2;
2606
        my ( $table, $column ) = split /[.]/, $kohafield, 2;
2592
        next unless $tables{$table};
2607
        next unless $tables{$table};
2593
        my $val = TransformMarcToKohaOneField(
2608
        my $val = TransformMarcToKohaOneField( $kohafield, $record );
2594
            $kohafield, $record, $frameworkcode,
2595
        );
2596
        next if !defined $val;
2609
        next if !defined $val;
2597
        my $key = _disambiguate( $table, $column );
2610
        my $key = _disambiguate( $table, $column );
2598
        $result->{$key} = $val;
2611
        $result->{$key} = $val;
Lines 2641-2655 sub _disambiguate { Link Here
2641
2654
2642
=head2 TransformMarcToKohaOneField
2655
=head2 TransformMarcToKohaOneField
2643
2656
2644
    $val = TransformMarcToKohaOneField( 'biblio.title', $marc, $frameworkcode );
2657
    $val = TransformMarcToKohaOneField( 'biblio.title', $marc );
2658
2659
    Note: The authoritative Default framework is used implicitly.
2645
2660
2646
=cut
2661
=cut
2647
2662
2648
sub TransformMarcToKohaOneField {
2663
sub TransformMarcToKohaOneField {
2649
    my ( $kohafield, $marc, $frameworkcode ) = @_;
2664
    my ( $kohafield, $marc ) = @_;
2650
2665
2651
    my ( @rv, $retval );
2666
    my ( @rv, $retval );
2652
    my @mss = GetMarcSubfieldStructureFromKohaField($kohafield, $frameworkcode);
2667
    my @mss = GetMarcSubfieldStructureFromKohaField($kohafield);
2653
    foreach my $fldhash ( @mss ) {
2668
    foreach my $fldhash ( @mss ) {
2654
        my $tag = $fldhash->{tagfield};
2669
        my $tag = $fldhash->{tagfield};
2655
        my $sub = $fldhash->{tagsubfield};
2670
        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 = C4::Biblio::GetFrameworkCode( $biblionumber );
1495
    my $framework = C4::Biblio::GetFrameworkCode( $biblionumber );
1497
    my $itemmarc = C4::Biblio::TransformKohaToMarc(
1496
    my $itemmarc = C4::Biblio::TransformKohaToMarc(
1498
        $mungeditem, $framework, { no_split => 1},
1497
        $mungeditem, { no_split => 1},
1499
    );
1498
    );
1500
    my ( $itemtag, $itemsubfield ) = C4::Biblio::GetMarcFromKohaField(
1499
    my ( $itemtag, $itemsubfield ) = C4::Biblio::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