Bug 27694: use HTML filtering on News Tool textarea
[koha-ffzg.git] / basket / downloadcart.pl
index f5cec95..f847877 100755 (executable)
@@ -32,14 +32,13 @@ use C4::Ris;
 use Koha::CsvProfiles;
 
 use utf8;
-my $query = new CGI;
+my $query = CGI->new;
 
 my ( $template, $borrowernumber, $cookie ) = get_template_and_user (
     {
         template_name   => "basket/downloadcart.tt",
         query           => $query,
         type            => "intranet",
-        authnotrequired => 0,
         flagsrequired   => { catalogue => 1 },
     }
 );
@@ -65,11 +64,15 @@ if ($bib_list && $format) {
 
         foreach my $biblio (@bibs) {
 
-            my $record = GetMarcBiblio($biblio, 1);
+            my $record = GetMarcBiblio({
+                biblionumber => $biblio,
+                embed_items  => 1 });
             next unless $record;
 
             if ($format eq 'iso2709') {
-                $output .= $record->as_usmarc();
+                #NOTE: If we don't explicitly UTF-8 encode the output,
+                #the browser will guess the encoding, and it won't always choose UTF-8.
+                $output .= encode("UTF-8", $record->as_usmarc()) // q{};
             }
             elsif ($format eq 'ris') {
                 $output .= marc2ris($record);
@@ -90,7 +93,7 @@ if ($bib_list && $format) {
     print $output;
 
 } else { 
-    $template->param(csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc' }) ]);
+    $template->param(csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' }) ]);
     $template->param(bib_list => $bib_list); 
     output_html_with_http_headers $query, $cookie, $template->output;
 }