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

(-)a/C4/Biblio.pm (-48 lines)
Lines 38-44 BEGIN { Link Here
38
        GetMarcSubjects
38
        GetMarcSubjects
39
        GetMarcAuthors
39
        GetMarcAuthors
40
        GetMarcSeries
40
        GetMarcSeries
41
        GetMarcHosts
42
        GetMarcUrls
41
        GetMarcUrls
43
        GetUsedMarcStructure
42
        GetUsedMarcStructure
44
        GetXmlBiblio
43
        GetXmlBiblio
Lines 1861-1913 sub GetMarcSeries { Link Here
1861
    return \@marcseries;
1860
    return \@marcseries;
1862
}    #end getMARCseriess
1861
}    #end getMARCseriess
1863
1862
1864
=head2 GetMarcHosts
1865
1866
  $marchostsarray = GetMarcHosts($record,$marcflavour);
1867
1868
Get all host records (773s MARC21, 461 UNIMARC) from the MARC record and returns them in an array.
1869
1870
=cut
1871
1872
sub GetMarcHosts {
1873
    my ( $record, $marcflavour ) = @_;
1874
    if (!$record) {
1875
        carp 'GetMarcHosts called on undefined record';
1876
        return;
1877
    }
1878
1879
    my ( $tag,$title_subf,$bibnumber_subf,$itemnumber_subf);
1880
    $marcflavour ||="MARC21";
1881
    if ( $marcflavour eq "MARC21" || $marcflavour eq "NORMARC" ) {
1882
        $tag = "773";
1883
        $title_subf = "t";
1884
        $bibnumber_subf ="0";
1885
        $itemnumber_subf='9';
1886
    }
1887
    elsif ($marcflavour eq "UNIMARC") {
1888
        $tag = "461";
1889
        $title_subf = "t";
1890
        $bibnumber_subf ="0";
1891
        $itemnumber_subf='9';
1892
    };
1893
1894
    my @marchosts;
1895
1896
    foreach my $field ( $record->field($tag)) {
1897
1898
        my @fields_loop;
1899
1900
        my $hostbiblionumber = $field->subfield("$bibnumber_subf");
1901
        my $hosttitle = $field->subfield($title_subf);
1902
        my $hostitemnumber=$field->subfield($itemnumber_subf);
1903
        push @fields_loop, { hostbiblionumber => $hostbiblionumber, hosttitle => $hosttitle, hostitemnumber => $hostitemnumber};
1904
        push @marchosts, { MARCHOSTS_FIELDS_LOOP => \@fields_loop };
1905
1906
        }
1907
    my $marchostsarray = \@marchosts;
1908
    return $marchostsarray;
1909
}
1910
1911
=head2 UpsertMarcSubfield
1863
=head2 UpsertMarcSubfield
1912
1864
1913
    my $record = C4::Biblio::UpsertMarcSubfield($MARC::Record, $fieldTag, $subfieldCode, $subfieldContent);
1865
    my $record = C4::Biblio::UpsertMarcSubfield($MARC::Record, $fieldTag, $subfieldCode, $subfieldContent);
(-)a/t/Biblio.t (-8 / +1 lines)
Lines 21-27 use Test::More; Link Here
21
use Test::MockModule;
21
use Test::MockModule;
22
use Test::Warn;
22
use Test::Warn;
23
23
24
plan tests => 43;
24
plan tests => 41;
25
25
26
use_ok('C4::Biblio');
26
use_ok('C4::Biblio');
27
27
Lines 117-128 warning_is { $ret = GetMarcSeries() } Link Here
117
117
118
ok( !defined $ret, 'GetMarcSeries returns undef if not passed rec');
118
ok( !defined $ret, 'GetMarcSeries returns undef if not passed rec');
119
119
120
warning_is { $ret = GetMarcHosts() }
121
           { carped => 'GetMarcHosts called on undefined record'},
122
           "GetMarcHosts returns carped warning on undef record";
123
124
ok( !defined $ret, 'GetMarcHosts returns undef if not passed rec');
125
126
my $hash_ref;
120
my $hash_ref;
127
121
128
warning_is { $hash_ref = TransformMarcToKoha( undef) }
122
warning_is { $hash_ref = TransformMarcToKoha( undef) }
129
- 

Return to bug 26133