Bug 21704: (follow-up) Remove unused 'frameworkcode' template param
[koha.git] / admin / import_export_framework.pl
index 41511b4..237be1d 100755 (executable)
@@ -18,8 +18,7 @@
 # along with Koha; if not, see <http://www.gnu.org/licenses>.
 
 
-use strict;
-use warnings;
+use Modern::Perl;
 use CGI qw ( -utf8 );
 use CGI::Cookie;
 use C4::Context;
@@ -46,13 +45,14 @@ unless ($authenticated) {
     exit 0;
 }
 
-my $frameworkcode = $input->param('frameworkcode') || '';
+my $framework_name = $input->param('frameworkcode') || 'default';
+my $frameworkcode = ($framework_name eq 'default') ? q{} : $framework_name;
 my $action = $input->param('action') || 'export';
 
 ## Exporting
 if ($action eq 'export' && $input->request_method() eq 'GET') {
     my $strXml = '';
-    my $format = $input->param('type_export_' . $frameworkcode);
+    my $format = $input->param('type_export_' . $framework_name);
     ExportFramework($frameworkcode, \$strXml, $format);
 
     if ($format eq 'csv') {
@@ -60,30 +60,30 @@ if ($action eq 'export' && $input->request_method() eq 'GET') {
 
         # Correctly set the encoding to output plain text in UTF-8
         binmode(STDOUT,':encoding(UTF-8)');
-        print $input->header(-type => 'application/vnd.ms-excel', -attachment => 'export_' . $frameworkcode . '.csv');
+        print $input->header(-type => 'application/vnd.ms-excel', -attachment => 'export_' . $framework_name . '.csv');
         print $strXml;
     } elsif ($format eq 'excel') {
         # Excel-xml file
-        print $input->header(-type => 'application/excel', -attachment => 'export_' . $frameworkcode . '.xml');
+        print $input->header(-type => 'application/excel', -attachment => 'export_' . $framework_name . '.xml');
         print $strXml;
     } else {
         # ODS file
         my $strODS = '';
         createODS($strXml, 'en', \$strODS);
-        print $input->header(-type => 'application/vnd.oasis.opendocument.spreadsheet', -attachment => 'export_' . $frameworkcode . '.ods');
+        print $input->header(-type => 'application/vnd.oasis.opendocument.spreadsheet', -attachment => 'export_' . $framework_name . '.ods');
         print $strODS;
     }
 ## Importing
 } elsif ($input->request_method() eq 'POST') {
     my $ok = -1;
-    my $fieldname = 'file_import_' . $frameworkcode;
+    my $fieldname = 'file_import_' . $framework_name;
     my $filename = $input->param($fieldname);
     # upload the input file
     if ($filename && $filename =~ /\.(csv|ods|xml)$/i) {
         my $extension = $1;
         my $uploadFd = $input->upload($fieldname);
         if ($uploadFd && !$input->cgi_error) {
-            my $tmpfilename = $input->tmpFileName($input->param($fieldname));
+            my $tmpfilename = $input->tmpFileName(scalar $input->param($fieldname));
             $filename = $tmpfilename . '.' . $extension; # rename the tmp file with the extension
             $ok = ImportFramework($filename, $frameworkcode, 1) if (rename($tmpfilename, $filename));
         }