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

(-)a/C4/Biblio.pm (+37 lines)
Lines 136-141 BEGIN { Link Here
136
      &TransformHtmlToMarc
136
      &TransformHtmlToMarc
137
      &TransformHtmlToXml
137
      &TransformHtmlToXml
138
      prepare_host_field
138
      prepare_host_field
139
      &RemoveItemsAndAuthidsFromRecord
139
    );
140
    );
140
}
141
}
141
142
Lines 2777-2782 sub get_koha_field_from_marc { Link Here
2777
    return $kohafield;
2778
    return $kohafield;
2778
}
2779
}
2779
2780
2781
=head2 RemoveItemsAndAuthidsFromRecord
2782
2783
  RemoveItemsAndAuthidsFromRecord($record);
2784
2785
  Remove all items (952) from the record.
2786
  Also removes all authids (subfield 9 in headings)
2787
2788
=cut
2789
2790
sub RemoveItemsAndAuthidsFromRecord {
2791
    my $record = shift;
2792
    my $frameworkcode = shift || '';
2793
2794
    if (!$record) {
2795
        carp('RemoveItemsAndAuthidsFromRecord called with undefined record');
2796
        return;
2797
    }
2798
2799
    my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField( "items.itemnumber", $frameworkcode );
2800
2801
    # Remove all the items from the record
2802
    foreach my $item ($record->field($itemtag)) {
2803
        $record->delete_field($item);
2804
    }
2805
2806
    # Remove all subfield ($9) in the record (marcflavour independent)
2807
    my @fields = $record->fields();
2808
    foreach my $field (@fields) {
2809
       next if ( $field->is_control_field());
2810
       $field->delete_subfield(code => '9');
2811
       unless($field->subfields()) {
2812
          $record->delete_field($field);
2813
       }
2814
    }
2815
}
2816
2780
=head2 TransformMarcToKohaOneField
2817
=head2 TransformMarcToKohaOneField
2781
2818
2782
  $result = TransformMarcToKohaOneField( $kohatable, $kohafield, $record, $result, $frameworkcode )
2819
  $result = TransformMarcToKohaOneField( $kohatable, $kohafield, $record, $result, $frameworkcode )
(-)a/acqui/neworderempty.pl (-4 / +2 lines)
Lines 145-154 if ( $ordernumber eq '' and defined $params->{'breedingid'}){ Link Here
145
    my ($marcrecord, $encoding) = MARCfindbreeding($params->{'breedingid'});
145
    my ($marcrecord, $encoding) = MARCfindbreeding($params->{'breedingid'});
146
    die("Could not find the selected record in the reservoir, bailing") unless $marcrecord;
146
    die("Could not find the selected record in the reservoir, bailing") unless $marcrecord;
147
147
148
    # Remove all the items (952) from the imported record
148
    # Do a cleanup on the imported record
149
    foreach my $item ($marcrecord->field('952')) {
149
    RemoveItemsAndAuthidsFromRecord($marcrecord, $params->{'frameworkcode'});
150
        $marcrecord->delete_field($item);
151
    }
152
150
153
    my $duplicatetitle;
151
    my $duplicatetitle;
154
#look for duplicates
152
#look for duplicates
(-)a/cataloguing/addbiblio.pl (-1 / +2 lines)
Lines 795-801 if (($biblionumber) && !($breedingid)){ Link Here
795
	$record = GetMarcBiblio($biblionumber);
795
	$record = GetMarcBiblio($biblionumber);
796
}
796
}
797
if ($breedingid) {
797
if ($breedingid) {
798
    ( $record, $encoding ) = MARCfindbreeding( $breedingid ) ;
798
    ( $record, $encoding ) = MARCfindbreeding( $breedingid );
799
    RemoveItemsAndAuthidsFromRecord($record, $frameworkcode) if $record;
799
}
800
}
800
801
801
#populate hostfield if hostbiblionumber is available
802
#populate hostfield if hostbiblionumber is available
(-)a/t/Biblio.t (-2 / +8 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 42;
20
use Test::More tests => 44;
21
use Test::Warn;
21
use Test::Warn;
22
22
23
BEGIN {
23
BEGIN {
Lines 155-158 warning_is { $ret = RemoveAllNsb() } Link Here
155
155
156
ok( !defined $ret, 'RemoveAllNsb returns undef if not passed rec');
156
ok( !defined $ret, 'RemoveAllNsb returns undef if not passed rec');
157
157
158
159
warning_is { @arr = RemoveItemsAndAuthidsFromRecord(undef, q{}) }
160
           { carped => 'RemoveItemsAndAuthidsFromRecord called with undefined record'},
161
           "RemoveItemsAndAuthidsFromRecord returns carped warning on undef record";
162
163
ok( !defined $ret, 'RemoveItemsAndAuthidsFromRecord returns undef if not passed rec');
164
158
1;
165
1;
159
- 

Return to bug 6681