--- a/installer/data/mysql/atomicupdate/bz11317-add-permission-for-tools-access-file.sql
+++ a/installer/data/mysql/atomicupdate/bz11317-add-permission-for-tools-access-file.sql
@@ -1, +1, @@
-INSERT INTO permissions (module_bit, code, description) VALUES (13, 'access_files', 'Access to the files stored on the server');
+INSERT IGNORE INTO permissions (module_bit, code, description) VALUES (13, 'access_files', 'Access to the files stored on the server');
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/access_files.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/access_files.tt
@@ -19,7 +19,7 @@
Report/log files
[% IF ( error_no_dir ) %]
- Error : Report/log files could not be found because the "accessdir" option was not set in "koha-conf.xml". Contact your system administrator to add this option.
+ Error : Report/log files could not be found because the "access_dir" option was not set in "koha-conf.xml". Contact your system administrator to add this option.
[% ELSE %]
[% IF ( files_loop ) %]
@@ -64,4 +64,4 @@
});
//]]>
-[% INCLUDE 'intranet-bottom.inc' %]
+[% INCLUDE 'intranet-bottom.inc' %]
--- a/tools/access_files.pl
+++ a/tools/access_files.pl
@@ -3,7 +3,7 @@
# Frédérick Capovilla, 2011 - Libéo
#
# Show a list of all the files in the directory specified by the option
-# "accessdir" in koha-conf.xml so they can be downloaded by users with the
+# "access_dir" in koha-conf.xml so they can be downloaded by users with the
# "access_files" permission.
#
# This file is part of Koha.
@@ -30,11 +30,12 @@ use C4::Output;
use C4::Koha;
use File::stat qw(stat);
use Digest::MD5 qw(md5_hex);
+use Encode;
my $input = new CGI;
my $file_id = $input->param("id");
-my $accessdir = C4::Context->config('accessdir');
-my @directories = $accessdir ? (ref $accessdir ? @{$accessdir} : ($accessdir)) : ();
+my $access_dir = C4::Context->config('access_dir');
+my @directories = $access_dir ? (ref $access_dir ? @{$access_dir} : ($access_dir)) : ();
my ($template, $borrowernumber, $cookie)
= get_template_and_user({template_name => "tools/access_files.tt",
@@ -54,10 +55,13 @@ else {
opendir(DIR, $dir);
foreach my $filename (readdir(DIR)) {
my $full_path = "$dir/$filename";
- my $id = md5_hex($full_path);
+ my $id = md5_hex($full_path);
next if ($filename =~ /^\./ or -d $full_path);
- my $st = stat($full_path);
+ # Make sure the filename is unicode-friendly
+ my $decoded_filename = decode('utf8', $filename);
+ my $st = stat("$dir/$decoded_filename");
+
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime($st->mtime);
my $dt=DateTime->new(year => $year + 1900,
month => $mon + 1,
@@ -65,8 +69,8 @@ else {
hour => $hour,
minute => $min,
);
- push(@files_list, {name => $filename,
- accessdir => $dir,
+ push(@files_list, {name => $decoded_filename,
+ access_dir => $dir,
date =>Koha::DateUtils::output_pref($dt),
size => $st->size,
id => $id});
@@ -78,7 +82,7 @@ else {
# If we received a file_id and it is valid, send the file to the browser
if(defined $file_id and exists $files_hash{$file_id} ){
my $filename = $files_hash{$file_id}->{name};
- my $dir = $files_hash{$file_id}->{accessdir};
+ my $dir = $files_hash{$file_id}->{access_dir};
binmode STDOUT;
# Open the selected file and send it to the browser
print $input->header(-type => 'application/x-download',
--