@@ -, +, @@ subfield_a => { %attributes_of_subfield_a }, %attributes_of_field_200 --- C4/Acquisition.pm | 4 ++-- C4/Items.pm | 2 +- C4/Koha.pm | 12 ------------ authorities/authorities-home.pl | 2 +- authorities/authorities.pl | 2 +- cataloguing/addbiblio.pl | 4 ++-- cataloguing/additem.pl | 9 ++++----- labels/label-item-search.pl | 2 +- opac/opac-authorities-home.pl | 2 +- reports/guided_reports.pl | 2 +- t/db_dependent/Acquisition/FillWithDefaultValues.t | 8 ++++++-- tools/batchMod.pl | 6 +++--- 12 files changed, 23 insertions(+), 32 deletions(-) --- a/C4/Acquisition.pm +++ a/C4/Acquisition.pm @@ -33,7 +33,7 @@ use Koha::Acquisition::Bookseller; use Koha::Number::Price; use Koha::Libraries; -use C4::Koha qw( subfield_is_koha_internal_p ); +use C4::Koha; use MARC::Field; use MARC::Record; @@ -2996,7 +2996,7 @@ sub FillWithDefaultValues { next unless $tag; next if $tag == $itemfield; for my $subfield ( sort keys %{ $tagslib->{$tag} } ) { - next if ( subfield_is_koha_internal_p($subfield) ); + next unless ref $tagslib->{$tag}{$subfield}; # Not a valid subfield (mandatory, tab, lib) my $defaultvalue = $tagslib->{$tag}{$subfield}{defaultvalue}; if ( defined $defaultvalue and $defaultvalue ne '' ) { my @fields = $record->field($tag); --- a/C4/Items.pm +++ a/C4/Items.pm @@ -2943,7 +2943,7 @@ sub PrepareItemrecordDisplay { # loop through each subfield my $cntsubf; foreach my $subfield ( sort keys %{ $tagslib->{$tag} } ) { - next if ( subfield_is_koha_internal_p($subfield) ); + next unless ref $tagslib->{$tag}{$subfield}; # Not a valid subfield (mandatory, tab, lib) next if ( $tagslib->{$tag}->{$subfield}->{'tab'} ne "10" ); my %subfield_data; $subfield_data{tag} = $tag; --- a/C4/Koha.pm +++ a/C4/Koha.pm @@ -39,7 +39,6 @@ BEGIN { require Exporter; @ISA = qw(Exporter); @EXPORT = qw( - &subfield_is_koha_internal_p &GetPrinters &GetPrinter &GetItemTypes &getitemtypeinfo &GetItemTypesCategorized &GetItemTypesByCategory @@ -94,17 +93,6 @@ Koha.pm provides many functions for Koha scripts. =cut -# FIXME.. this should be moved to a MARC-specific module -sub subfield_is_koha_internal_p { - my ($subfield) = @_; - - # We could match on 'lib' and 'tab' (and 'mandatory', & more to come!) - # But real MARC subfields are always single-character - # so it really is safer just to check the length - - return length $subfield != 1; -} - =head2 GetSupportName $itemtypename = &GetSupportName($codestring); --- a/authorities/authorities-home.pl +++ a/authorities/authorities-home.pl @@ -29,7 +29,7 @@ use C4::Auth; use C4::Output; use C4::AuthoritiesMarc; use C4::Acquisition; -use C4::Koha; # XXX subfield_is_koha_internal_p +use C4::Koha; use C4::Biblio; use C4::Search::History; --- a/authorities/authorities.pl +++ a/authorities/authorities.pl @@ -26,7 +26,7 @@ use C4::Output; use C4::AuthoritiesMarc; use C4::ImportBatch; #GetImportRecordMarc use C4::Context; -use C4::Koha; # XXX subfield_is_koha_internal_p +use C4::Koha; use Date::Calc qw(Today); use MARC::File::USMARC; use MARC::File::XML; --- a/cataloguing/addbiblio.pl +++ a/cataloguing/addbiblio.pl @@ -30,8 +30,8 @@ use C4::AuthoritiesMarc; use C4::Context; use MARC::Record; use C4::Log; -use C4::Koha; # XXX subfield_is_koha_internal_p -use C4::Branch; # XXX subfield_is_koha_internal_p +use C4::Koha; +use C4::Branch; use C4::ClassSource; use C4::ImportBatch; use C4::Charset; --- a/cataloguing/additem.pl +++ a/cataloguing/additem.pl @@ -28,8 +28,8 @@ use C4::Biblio; use C4::Items; use C4::Context; use C4::Circulation; -use C4::Koha; # XXX subfield_is_koha_internal_p -use C4::Branch; # XXX subfield_is_koha_internal_p +use C4::Koha; +use C4::Branch; use C4::ClassSource; use Koha::DateUtils; use List::MoreUtils qw/any/; @@ -606,7 +606,7 @@ if ($op eq "additem") { my $tag = $field->{_tag}; foreach my $subfield ($field->subfields()){ my $subfieldtag = $subfield->[0]; - if (subfield_is_koha_internal_p($subfieldtag) || $tagslib->{$tag}->{$subfieldtag}->{'tab'} ne "10" + if ($tagslib->{$tag}->{$subfieldtag}->{'tab'} ne "10" || abs($tagslib->{$tag}->{$subfieldtag}->{hidden})>4 ){ my $fieldItem = $itemrecord->field($tag); $itemrecord->delete_field($fieldItem); @@ -871,7 +871,6 @@ if($itemrecord){ my $value = $subfield->[1]; my $subfieldlib = $tagslib->{$tag}->{$subfieldtag}; - next if subfield_is_koha_internal_p($subfieldtag); next if ($tagslib->{$tag}->{$subfieldtag}->{'tab'} ne "10"); my $subfield_data = generate_subfield_form($tag, $subfieldtag, $value, $tagslib, $subfieldlib, $branches, $biblionumber, $temp, \@loop_data, $i, $restrictededition); @@ -891,7 +890,7 @@ $itemrecord = $cookieitemrecord if ($prefillitem and not $justaddeditem and $op # We generate form, and fill with values if defined foreach my $tag ( keys %{$tagslib}){ foreach my $subtag (keys %{$tagslib->{$tag}}){ - next if subfield_is_koha_internal_p($subtag); + next unless ref $tagslib->{$tag}{$subtag}; # Not a valid subfield (mandatory, tab, lib) next if ($tagslib->{$tag}->{$subtag}->{'tab'} ne "10"); next if any { /^$tag$subtag$/ } @fields; --- a/labels/label-item-search.pl +++ a/labels/label-item-search.pl @@ -31,7 +31,7 @@ use C4::Context; use C4::Search qw(SimpleSearch); use C4::Biblio qw(TransformMarcToKoha); use C4::Items qw(GetItemInfosOf get_itemnumbers_of); -use C4::Koha qw(GetItemTypes); # XXX subfield_is_koha_internal_p +use C4::Koha qw(GetItemTypes); use C4::Creators::Lib qw(html_table); use C4::Debug; use Koha::DateUtils; --- a/opac/opac-authorities-home.pl +++ a/opac/opac-authorities-home.pl @@ -28,7 +28,7 @@ use C4::Context; use C4::Auth; use C4::Output; use C4::AuthoritiesMarc; -use C4::Koha; # XXX subfield_is_koha_internal_p +use C4::Koha; use C4::Search::History; use Koha::Authority::Types; --- a/reports/guided_reports.pl +++ a/reports/guided_reports.pl @@ -28,8 +28,8 @@ use C4::Reports::Guided; use C4::Auth qw/:DEFAULT get_session/; use C4::Output; use C4::Debug; -use C4::Branch; # XXX subfield_is_koha_internal_p use C4::Koha qw/GetFrameworksLoop/; +use C4::Branch; use C4::Context; use C4::Log; use Koha::DateUtils qw/dt_from_string output_pref/; --- a/t/db_dependent/Acquisition/FillWithDefaultValues.t +++ a/t/db_dependent/Acquisition/FillWithDefaultValues.t @@ -21,8 +21,12 @@ $biblio_module->mock( { # default value for an existing field '245' => { - c => { defaultvalue => $default_author }, - }, + c => { defaultvalue => $default_author }, + mandatory => 0, + repeatable => 0, + tab => 0, + lib => 'a lib', + }, # default for a nonexisting field '099' => { --- a/tools/batchMod.pl +++ a/tools/batchMod.pl @@ -27,8 +27,8 @@ use C4::Biblio; use C4::Items; use C4::Circulation; use C4::Context; -use C4::Koha; # XXX subfield_is_koha_internal_p -use C4::Branch; # XXX subfield_is_koha_internal_p +use C4::Koha; +use C4::Branch; use C4::BackgroundJob; use C4::ClassSource; use C4::Debug; @@ -308,7 +308,7 @@ my @subfieldsToAllow = split(/ /, $subfieldsToAllowForBatchmod); foreach my $tag (sort keys %{$tagslib}) { # loop through each subfield foreach my $subfield (sort keys %{$tagslib->{$tag}}) { - next if subfield_is_koha_internal_p($subfield); + next unless ref $tagslib->{$tag}{$subfield}; # Not a valid subfield (mandatory, tab, lib) next if (not $allowAllSubfields and $restrictededition && !grep { $tag . '$' . $subfield eq $_ } @subfieldsToAllow ); next if ($tagslib->{$tag}->{$subfield}->{'tab'} ne "10"); # barcode and stocknumber are not meant to be batch-modified --