Bug 26911: (bug 18936 follow-up) Remove invalid data before copying the circ rules
[koha.git] / authorities / export.pl
blobee21e1e14e407bce05d50fe95f6d115daea571ed
1 #!/usr/bin/perl
2 use Modern::Perl;
4 use C4::Record;
5 use C4::Auth;
6 use C4::Output;
7 use C4::AuthoritiesMarc;
8 use CGI qw ( -utf8 );
10 my $query = CGI->new;
11 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
13 template_name => "tools/export.tt",
14 query => $query,
15 type => "intranet",
16 flagsrequired => { catalogue => 1 },
17 debug => 1,
21 my $op = $query->param("op");
22 my $format = $query->param("format");
23 my $error = '';
24 if ( $op eq "export" ) {
25 my $authid = $query->param("authid");
26 if ($authid) {
28 my $marc = GetAuthority($authid);
30 if ( $format =~ /marcxml/ ) {
31 $marc = marc2marcxml($marc, 'UTF-8', C4::Context->preference("marcflavour") eq 'UNIMARC' ? 'UNIMARCAUTH' : 'MARC21' );
33 elsif ($format=~ /mads/) {
34 $marc = marc2madsxml($marc);
36 elsif ( $format =~ /marc8/ ) {
37 $marc = changeEncoding( $marc, "MARC", "MARC21", "MARC-8" );
38 $marc = $marc->as_usmarc();
40 elsif ( $format =~ /utf8/ ) {
41 C4::Charset::SetUTF8Flag( $marc, 1 );
42 $marc = $marc->as_usmarc();
44 print $query->header(
45 -type => 'application/octet-stream',
46 -attachment => "auth-$authid.$format"
48 print $marc;