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

(-)a/C4/Record.pm (-1 / +26 lines)
Lines 77-83 Returns an ISO-2709 scalar Link Here
77
77
78
sub marc2marc {
78
sub marc2marc {
79
	my ($marc,$to_flavour,$from_flavour,$encoding) = @_;
79
	my ($marc,$to_flavour,$from_flavour,$encoding) = @_;
80
	my $error = "Feature not yet implemented\n";
80
	my $error;
81
    if ($to_flavour =~ m/marcstd/) {
82
        my $marc_record_obj;
83
        if ($marc =~ /^MARC::Record/) { # it's already a MARC::Record object
84
            $marc_record_obj = $marc;
85
        } else { # it's not a MARC::Record object, make it one
86
            eval { $marc_record_obj = MARC::Record->new_from_usmarc($marc) }; # handle exceptions
87
88
# conversion to MARC::Record object failed, populate $error
89
                if ($@) { $error .="\nCreation of MARC::Record object failed: ".$MARC::File::ERROR };
90
        }
91
        unless ($error) {
92
            my @privatefields;
93
            foreach my $field ($marc_record_obj->fields()) {
94
                if ($field->tag() =~ m/9/ && ($field->tag() != '490' || C4::Context->preference("marcflavour") eq 'UNIMARC')) {
95
                    push @privatefields, $field;
96
                } elsif (! ($field->is_control_field())) {
97
                    $field->delete_subfield(code => '9') if ($field->subfield('9'));
98
                }
99
            }
100
            $marc_record_obj->delete_field($_) for @privatefields;
101
            $marc = $marc_record_obj->as_usmarc();
102
        }
103
    } else {
104
        $error = "Feature not yet implemented\n";
105
    }
81
	return ($error,$marc);
106
	return ($error,$marc);
82
}
107
}
83
108
(-)a/catalogue/export.pl (+4 lines)
Lines 51-56 if ($op eq "export") { Link Here
51
				C4::Charset::SetUTF8Flag($marc, 1);
51
				C4::Charset::SetUTF8Flag($marc, 1);
52
				$marc = $marc->as_usmarc();
52
				$marc = $marc->as_usmarc();
53
			}
53
			}
54
            elsif ($format =~ /marcstd/) {
55
                C4::Charset::SetUTF8Flag($marc,1);
56
                ($error,$marc) = marc2marc($marc, 'marcstd', C4::Context->preference('marcflavour'));
57
            }
54
			print $query->header(
58
			print $query->header(
55
				-type => 'application/octet-stream',
59
				-type => 'application/octet-stream',
56
                -attachment=>"bib-$biblionumber.$format");
60
                -attachment=>"bib-$biblionumber.$format");
(-)a/opac/opac-export.pl (-1 / +4 lines)
Lines 66-71 elsif ($format =~ /utf8/) { Link Here
66
    C4::Charset::SetUTF8Flag($marc,1);
66
    C4::Charset::SetUTF8Flag($marc,1);
67
    $marc = $marc->as_usmarc();
67
    $marc = $marc->as_usmarc();
68
}
68
}
69
elsif ($format =~ /marcstd/) {
70
    C4::Charset::SetUTF8Flag($marc,1);
71
    ($error,$marc) = marc2marc($marc, 'marcstd', C4::Context->preference('marcflavour'));
72
}
69
else {
73
else {
70
    $error= "Format $format is not supported.";
74
    $error= "Format $format is not supported.";
71
}
75
}
72
- 

Return to bug 7345