5 use C4::Auth qw( get_template_and_user );
7 use C4::AuthoritiesMarc qw( GetAuthority );
11 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
13 template_name => "tools/export.tt",
16 flagsrequired => { catalogue => 1 },
20 my $op = $query->param("op");
21 my $format = $query->param("format");
23 if ( $op eq "export" ) {
24 my $authid = $query->param("authid");
27 my $marc = GetAuthority($authid);
29 if ( $format =~ /marcxml/ ) {
30 $marc = marc2marcxml($marc, 'UTF-8', C4::Context->preference("marcflavour") eq 'UNIMARC' ? 'UNIMARCAUTH' : 'MARC21' );
32 elsif ($format=~ /mads/) {
33 $marc = marc2madsxml($marc);
35 elsif ( $format =~ /marc8/ ) {
36 $marc = changeEncoding( $marc, "MARC", "MARC21", "MARC-8" );
37 $marc = $marc->as_usmarc();
39 elsif ( $format =~ /utf8/ ) {
40 C4::Charset::SetUTF8Flag( $marc, 1 );
41 $marc = $marc->as_usmarc();
44 -type => 'application/octet-stream',
45 -attachment => "auth-$authid.$format"