The commit
b5ecefd485a75d54a5fa26fff5a0cc890541e2c3
Date: Mon Feb 3 18:46:00 2003 +0000
had a funny description:
Added function to check if a MARC subfield name is "koha-internal"
(instead of checking it for 'lib' and 'tag' everywhere); temporarily
added to Koha.pm
"Temporarily", since 2003, everything is relative, isn't it? :)
The thing is that GetMarcStructure returns hash like
field_200 => {
subfield_a => {
%attributes_of_subfield_a
},
%attributes_of_field_200
}
The attributes for field_200 can be 'repeatable', 'mandatory', 'tag', 'lib'.
We don't want to loop on these values when looping on subfields.
Since there are just { k => v } with v is a scalar (string), it's easier
to test if we are processing a subfield testing the reference.
At some places, we don't need to test that, we are looping on values
from MARC::Field->subfields which are always valid subfields.
Test plan:
1/ Edit items using the batch item mod tool
2/ display and edit items via the cataloguing module.
You should not see any changes between before and after the patch
applied.
Tech notes:
We need to check what we are processing when we loop on 'subfields' from
GetMarcStructure, not from MARC::Field->subfields.
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com>
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;
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);
# 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;
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(
- &subfield_is_koha_internal_p
&GetPrinters &GetPrinter
&GetItemTypes &getitemtypeinfo
&GetItemTypesCategorized &GetItemTypesByCategory
=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);
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;
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;
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;
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/;
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);
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);
# 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;
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;
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;
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/;
{
# 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' => {
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;
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