Bug 15451: (followup) fix filename extension for csv file
authorBernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Thu, 28 Apr 2016 01:28:08 +0000 (22:28 -0300)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 22 Jul 2016 17:18:37 +0000 (17:18 +0000)
This patch does the same as basket/downloadcart.pl
to set '.csv' as filename extension for downloadshelf.pl

To test:
1) Define a CSV MARC profile
2) On staff download a list, extension is '.NN'
with 'NN' the CSV profile id.
3) Apply the patch
4) Download again, check extension is now '.csv'

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

virtualshelves/downloadshelf.pl

index 4d1bde2..d988161 100755 (executable)
@@ -83,6 +83,10 @@ if ($shelfid && $format) {
                     }
                 }
             }
+
+            # If it was a CSV export we change the format after the export so the file extension is fine
+            $format = "csv" if ($format =~ m/^\d+$/);
+
             print $query->header(
             -type => 'application/octet-stream',
             -'Content-Transfer-Encoding' => 'binary',
@@ -95,9 +99,6 @@ if ($shelfid && $format) {
     } else {
         push @messages, { type => 'error', code => 'does_not_exist' };
     }
-
-    # If it was a CSV export we change the format after the export so the file extension is fine
-    $format = "csv" if ($format =~ m/^\d+$/);
 }
 else {
     $template->param(csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc' }) ]);