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 92-97 BEGIN { Link Here
92
92
93
      &GetAuthorisedValueDesc
93
      &GetAuthorisedValueDesc
94
      &GetMarcStructure
94
      &GetMarcStructure
95
      &IsMarcStructureInternal
95
      &GetMarcFromKohaField
96
      &GetMarcFromKohaField
96
      &GetMarcSubfieldStructureFromKohaField
97
      &GetMarcSubfieldStructureFromKohaField
97
      &GetFrameworkCode
98
      &GetFrameworkCode
Lines 1081-1086 sub GetBiblioItemInfosOf { Link Here
1081
1082
1082
=head1 FUNCTIONS FOR HANDLING MARC MANAGEMENT
1083
=head1 FUNCTIONS FOR HANDLING MARC MANAGEMENT
1083
1084
1085
=head2 IsMarcStructureInternal
1086
1087
    my $tagslib = C4::Biblio::GetMarcStructure();
1088
    for my $tag ( sort keys %$tagslib ) {
1089
        next unless $tag;
1090
        for my $subfield ( sort keys %{ $tagslib->{$tag} } ) {
1091
            next if IsMarcStructureInternal($tagslib->{$tag}{$subfield});
1092
        }
1093
        # Process subfield
1094
    }
1095
1096
GetMarcStructure creates keys (lib, tab, mandatory, repeatable) for a display purpose.
1097
These different values should not be processed as valid subfields.
1098
1099
=cut
1100
1101
sub IsMarcStructureInternal {
1102
    my ( $subfield ) = @_;
1103
    return ref $subfield ? 0 : 1;
1104
}
1105
1084
=head2 GetMarcStructure
1106
=head2 GetMarcStructure
1085
1107
1086
  $res = GetMarcStructure($forlibrarian,$frameworkcode);
1108
  $res = GetMarcStructure($forlibrarian,$frameworkcode);
(-)a/C4/Items.pm (-1 / +1 lines)
Lines 2943-2949 sub PrepareItemrecordDisplay { Link Here
2943
            # loop through each subfield
2943
            # loop through each subfield
2944
            my $cntsubf;
2944
            my $cntsubf;
2945
            foreach my $subfield ( sort keys %{ $tagslib->{$tag} } ) {
2945
            foreach my $subfield ( sort keys %{ $tagslib->{$tag} } ) {
2946
                next unless ref $tagslib->{$tag}{$subfield}; # Not a valid subfield (mandatory, tab, lib)
2946
                next if IsMarcStructureInternal($tagslib->{$tag}{$subfield});
2947
                next if ( $tagslib->{$tag}->{$subfield}->{'tab'} ne "10" );
2947
                next if ( $tagslib->{$tag}->{$subfield}->{'tab'} ne "10" );
2948
                my %subfield_data;
2948
                my %subfield_data;
2949
                $subfield_data{tag}           = $tag;
2949
                $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 323-326 subtest 'GetMarcSubfieldStructureFromKohaField' => sub { Link Here
323
    is($marc_subfield_structure, undef, "invalid kohafield returns undef");
324
    is($marc_subfield_structure, undef, "invalid kohafield returns undef");
324
};
325
};
325
326
327
subtest 'IsMarcStructureInternal' => sub {
328
    plan tests => 6;
329
    my $tagslib = GetMarcStructure();
330
    my @internals;
331
    for my $tag ( sort keys %$tagslib ) {
332
        next unless $tag;
333
        for my $subfield ( sort keys %{ $tagslib->{$tag} } ) {
334
            push @internals, $subfield if IsMarcStructureInternal($tagslib->{$tag}{$subfield});
335
        }
336
    }
337
    @internals = uniq @internals;
338
    is( scalar(@internals), 4, '');
339
    is( grep( /^lib$/, @internals ), 1, '' );
340
    is( grep( /^tab$/, @internals ), 1, '' );
341
    is( grep( /^mandatory$/, @internals ), 1, '' );
342
    is( grep( /^repeatable$/, @internals ), 1, '' );
343
    is( grep( /^a$/, @internals ), 0, '' );
344
};
345
326
1;
346
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