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

(-)a/C4/Acquisition.pm (-1 / +1 lines)
Lines 2996-3002 sub FillWithDefaultValues { Link Here
2996
            next unless $tag;
2996
            next unless $tag;
2997
            next if $tag == $itemfield;
2997
            next if $tag == $itemfield;
2998
            for my $subfield ( sort keys %{ $tagslib->{$tag} } ) {
2998
            for my $subfield ( sort keys %{ $tagslib->{$tag} } ) {
2999
                next unless ref $tagslib->{$tag}{$subfield}; # Not a valid subfield (mandatory, tab, lib)
2999
                next if IsMarcStructureInternal($tagslib->{$tag}{$subfield});
3000
                my $defaultvalue = $tagslib->{$tag}{$subfield}{defaultvalue};
3000
                my $defaultvalue = $tagslib->{$tag}{$subfield}{defaultvalue};
3001
                if ( defined $defaultvalue and $defaultvalue ne '' ) {
3001
                if ( defined $defaultvalue and $defaultvalue ne '' ) {
3002
                    my @fields = $record->field($tag);
3002
                    my @fields = $record->field($tag);
(-)a/C4/Biblio.pm (+22 lines)
Lines 91-96 BEGIN { Link Here
91
91
92
      &GetAuthorisedValueDesc
92
      &GetAuthorisedValueDesc
93
      &GetMarcStructure
93
      &GetMarcStructure
94
      &IsMarcStructureInternal
94
      &GetMarcFromKohaField
95
      &GetMarcFromKohaField
95
      &GetMarcSubfieldStructureFromKohaField
96
      &GetMarcSubfieldStructureFromKohaField
96
      &GetFrameworkCode
97
      &GetFrameworkCode
Lines 1080-1085 sub GetBiblioItemInfosOf { Link Here
1080
1081
1081
=head1 FUNCTIONS FOR HANDLING MARC MANAGEMENT
1082
=head1 FUNCTIONS FOR HANDLING MARC MANAGEMENT
1082
1083
1084
=head2 IsMarcStructureInternal
1085
1086
    my $tagslib = C4::Biblio::GetMarcStructure();
1087
    for my $tag ( sort keys %$tagslib ) {
1088
        next unless $tag;
1089
        for my $subfield ( sort keys %{ $tagslib->{$tag} } ) {
1090
            next if IsMarcStructureInternal($tagslib->{$tag}{$subfield});
1091
        }
1092
        # Process subfield
1093
    }
1094
1095
GetMarcStructure creates keys (lib, tab, mandatory, repeatable) for a display purpose.
1096
These different values should not be processed as valid subfields.
1097
1098
=cut
1099
1100
sub IsMarcStructureInternal {
1101
    my ( $subfield ) = @_;
1102
    return ref $subfield ? 0 : 1;
1103
}
1104
1083
=head2 GetMarcStructure
1105
=head2 GetMarcStructure
1084
1106
1085
  $res = GetMarcStructure($forlibrarian,$frameworkcode);
1107
  $res = GetMarcStructure($forlibrarian,$frameworkcode);
(-)a/C4/Items.pm (-1 / +1 lines)
Lines 2939-2945 sub PrepareItemrecordDisplay { Link Here
2939
            # loop through each subfield
2939
            # loop through each subfield
2940
            my $cntsubf;
2940
            my $cntsubf;
2941
            foreach my $subfield ( sort keys %{ $tagslib->{$tag} } ) {
2941
            foreach my $subfield ( sort keys %{ $tagslib->{$tag} } ) {
2942
                next unless ref $tagslib->{$tag}{$subfield}; # Not a valid subfield (mandatory, tab, lib)
2942
                next if IsMarcStructureInternal($tagslib->{$tag}{$subfield});
2943
                next if ( $tagslib->{$tag}->{$subfield}->{'tab'} ne "10" );
2943
                next if ( $tagslib->{$tag}->{$subfield}->{'tab'} ne "10" );
2944
                my %subfield_data;
2944
                my %subfield_data;
2945
                $subfield_data{tag}           = $tag;
2945
                $subfield_data{tag}           = $tag;
(-)a/cataloguing/additem.pl (-1 / +1 lines)
Lines 890-896 $itemrecord = $cookieitemrecord if ($prefillitem and not $justaddeditem and $op Link Here
890
# We generate form, and fill with values if defined
890
# We generate form, and fill with values if defined
891
foreach my $tag ( keys %{$tagslib}){
891
foreach my $tag ( keys %{$tagslib}){
892
    foreach my $subtag (keys %{$tagslib->{$tag}}){
892
    foreach my $subtag (keys %{$tagslib->{$tag}}){
893
        next unless ref $tagslib->{$tag}{$subtag}; # Not a valid subfield (mandatory, tab, lib)
893
        next if IsMarcStructureInternal($tagslib->{$tag}{$subtag});
894
        next if ($tagslib->{$tag}->{$subtag}->{'tab'} ne "10");
894
        next if ($tagslib->{$tag}->{$subtag}->{'tab'} ne "10");
895
        next if any { /^$tag$subtag$/ }  @fields;
895
        next if any { /^$tag$subtag$/ }  @fields;
896
896
(-)a/t/db_dependent/Biblio.t (-1 / +21 lines)
Lines 17-25 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 5;
20
use Test::More tests => 6;
21
use Test::MockModule;
21
use Test::MockModule;
22
22
23
use List::MoreUtils qw( uniq );
23
use MARC::Record;
24
use MARC::Record;
24
use t::lib::Mocks qw( mock_preference );
25
use t::lib::Mocks qw( mock_preference );
25
26
Lines 315-318 subtest 'GetMarcSubfieldStructureFromKohaField' => sub { Link Here
315
    is($marc_subfield_structure, undef, "invalid kohafield returns undef");
316
    is($marc_subfield_structure, undef, "invalid kohafield returns undef");
316
};
317
};
317
318
319
subtest 'IsMarcStructureInternal' => sub {
320
    plan tests => 6;
321
    my $tagslib = GetMarcStructure();
322
    my @internals;
323
    for my $tag ( sort keys %$tagslib ) {
324
        next unless $tag;
325
        for my $subfield ( sort keys %{ $tagslib->{$tag} } ) {
326
            push @internals, $subfield if IsMarcStructureInternal($tagslib->{$tag}{$subfield});
327
        }
328
    }
329
    @internals = uniq @internals;
330
    is( scalar(@internals), 4, '');
331
    is( grep( /^lib$/, @internals ), 1, '' );
332
    is( grep( /^tab$/, @internals ), 1, '' );
333
    is( grep( /^mandatory$/, @internals ), 1, '' );
334
    is( grep( /^repeatable$/, @internals ), 1, '' );
335
    is( grep( /^a$/, @internals ), 0, '' );
336
};
337
318
1;
338
1;
(-)a/tools/batchMod.pl (-2 / +1 lines)
Lines 308-314 my @subfieldsToAllow = split(/ /, $subfieldsToAllowForBatchmod); Link Here
308
foreach my $tag (sort keys %{$tagslib}) {
308
foreach my $tag (sort keys %{$tagslib}) {
309
    # loop through each subfield
309
    # loop through each subfield
310
    foreach my $subfield (sort keys %{$tagslib->{$tag}}) {
310
    foreach my $subfield (sort keys %{$tagslib->{$tag}}) {
311
        next unless ref $tagslib->{$tag}{$subfield}; # Not a valid subfield (mandatory, tab, lib)
311
        next if IsMarcStructureInternal( $tagslib->{$tag}{$subfield} );
312
        next if (not $allowAllSubfields and $restrictededition && !grep { $tag . '$' . $subfield eq $_ } @subfieldsToAllow );
312
        next if (not $allowAllSubfields and $restrictededition && !grep { $tag . '$' . $subfield eq $_ } @subfieldsToAllow );
313
    	next if ($tagslib->{$tag}->{$subfield}->{'tab'} ne "10");
313
    	next if ($tagslib->{$tag}->{$subfield}->{'tab'} ne "10");
314
        # barcode and stocknumber are not meant to be batch-modified
314
        # barcode and stocknumber are not meant to be batch-modified
315
- 

Return to bug 5404