View | Details | Raw Unified | Return to bug 11317
Collapse All | Expand All

(-)a/debian/templates/koha-conf-site.xml.in (-1 / +1 lines)
Lines 297-303 __END_SRU_PUBLICSERVER__ Link Here
297
 <api_secret_passphrase>__API_SECRET__</api_secret_passphrase>
297
 <api_secret_passphrase>__API_SECRET__</api_secret_passphrase>
298
298
299
 <!-- Accessible directory from the staff client, uncomment the following line and define a valid path to let the intranet user access it-->
299
 <!-- Accessible directory from the staff client, uncomment the following line and define a valid path to let the intranet user access it-->
300
 <!-- <accessdir></accessdir> -->
300
 <!-- <access_dir></access_dir> -->
301
301
302
 <!-- true type font mapping according to type from $font_types in C4/Creators/Lib.pm -->
302
 <!-- true type font mapping according to type from $font_types in C4/Creators/Lib.pm -->
303
 <ttf>
303
 <ttf>
(-)a/etc/koha-conf.xml (-1 / +1 lines)
Lines 128-134 __PAZPAR2_TOGGLE_XML_POST__ Link Here
128
 <api_secret_passphrase>CHANGEME</api_secret_passphrase>
128
 <api_secret_passphrase>CHANGEME</api_secret_passphrase>
129
129
130
 <!-- Accessible directory from the staff client, uncomment the following line and define a valid path to let the intranet user access it-->
130
 <!-- Accessible directory from the staff client, uncomment the following line and define a valid path to let the intranet user access it-->
131
 <!-- <accessdir></accessdir> -->
131
 <!-- <access_dir></access_dir> -->
132
132
133
 <!-- true type font mapping accoding to type from $font_types in C4/Creators/Lib.pm -->
133
 <!-- true type font mapping accoding to type from $font_types in C4/Creators/Lib.pm -->
134
 <ttf>
134
 <ttf>
(-)a/installer/data/mysql/atomicupdate/bz11317-add-permission-for-tools-access-file.sql (-1 / +1 lines)
Line 1 Link Here
1
INSERT INTO permissions (module_bit, code, description) VALUES (13, 'access_files', 'Access to the files stored on the server');
1
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 (-2 / +2 lines)
Lines 19-25 Link Here
19
    <h1>Report/log files</h1>
19
    <h1>Report/log files</h1>
20
20
21
[% IF ( error_no_dir ) %]
21
[% IF ( error_no_dir ) %]
22
    <div class="dialog alert"><strong>Error : </strong>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.</div>
22
    <div class="dialog alert"><strong>Error : </strong>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.</div>
23
[% ELSE %]
23
[% ELSE %]
24
    [% IF ( files_loop ) %]
24
    [% IF ( files_loop ) %]
25
        <table id="files">
25
        <table id="files">
Lines 64-67 Link Here
64
    });
64
    });
65
    //]]>
65
    //]]>
66
</script>
66
</script>
67
[% INCLUDE 'intranet-bottom.inc' %]
67
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/tools/access_files.pl (-9 / +12 lines)
Lines 3-9 Link Here
3
# Frédérick Capovilla, 2011 - Libéo
3
# Frédérick Capovilla, 2011 - Libéo
4
#
4
#
5
# Show a list of all the files in the directory specified by the option
5
# Show a list of all the files in the directory specified by the option
6
# "accessdir" in koha-conf.xml so they can be downloaded by users with the
6
# "access_dir" in koha-conf.xml so they can be downloaded by users with the
7
# "access_files" permission.
7
# "access_files" permission.
8
#
8
#
9
# This file is part of Koha.
9
# This file is part of Koha.
Lines 30-40 use C4::Output; Link Here
30
use C4::Koha;
30
use C4::Koha;
31
use File::stat qw(stat);
31
use File::stat qw(stat);
32
use Digest::MD5 qw(md5_hex);
32
use Digest::MD5 qw(md5_hex);
33
use Encode;
33
34
34
my $input = new CGI;
35
my $input = new CGI;
35
my $file_id = $input->param("id");
36
my $file_id = $input->param("id");
36
my $accessdir = C4::Context->config('accessdir');
37
my $access_dir = C4::Context->config('access_dir');
37
my @directories = $accessdir ? (ref $accessdir ? @{$accessdir} : ($accessdir)) : ();
38
my @directories = $access_dir ? (ref $access_dir ? @{$access_dir} : ($access_dir)) : ();
38
39
39
my ($template, $borrowernumber, $cookie)
40
my ($template, $borrowernumber, $cookie)
40
    = get_template_and_user({template_name => "tools/access_files.tt",
41
    = get_template_and_user({template_name => "tools/access_files.tt",
Lines 54-63 else { Link Here
54
        opendir(DIR, $dir);
55
        opendir(DIR, $dir);
55
        foreach my $filename (readdir(DIR)) {
56
        foreach my $filename (readdir(DIR)) {
56
            my $full_path = "$dir/$filename";
57
            my $full_path = "$dir/$filename";
57
        my $id = md5_hex($full_path);
58
            my $id = md5_hex($full_path);
58
            next if ($filename =~ /^\./ or -d $full_path);
59
            next if ($filename =~ /^\./ or -d $full_path);
59
60
60
            my $st = stat($full_path);
61
            # Make sure the filename is unicode-friendly
62
            my $decoded_filename = decode('utf8', $filename);
63
            my $st = stat("$dir/$decoded_filename");
64
61
            my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime($st->mtime);
65
            my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime($st->mtime);
62
            my $dt=DateTime->new(year      => $year + 1900,
66
            my $dt=DateTime->new(year      => $year + 1900,
63
                                  month    => $mon + 1,
67
                                  month    => $mon + 1,
Lines 65-72 else { Link Here
65
                                  hour     => $hour,
69
                                  hour     => $hour,
66
                                  minute   => $min,
70
                                  minute   => $min,
67
                            );
71
                            );
68
            push(@files_list, {name => $filename,
72
            push(@files_list, {name => $decoded_filename,
69
                               accessdir => $dir,
73
                               access_dir => $dir,
70
                               date =>Koha::DateUtils::output_pref($dt),
74
                               date =>Koha::DateUtils::output_pref($dt),
71
                               size => $st->size,
75
                               size => $st->size,
72
                               id   => $id});
76
                               id   => $id});
Lines 78-84 else { Link Here
78
    # If we received a file_id and it is valid, send the file to the browser
82
    # If we received a file_id and it is valid, send the file to the browser
79
    if(defined $file_id and exists $files_hash{$file_id} ){
83
    if(defined $file_id and exists $files_hash{$file_id} ){
80
        my $filename = $files_hash{$file_id}->{name};
84
        my $filename = $files_hash{$file_id}->{name};
81
        my $dir = $files_hash{$file_id}->{accessdir};
85
        my $dir = $files_hash{$file_id}->{access_dir};
82
        binmode STDOUT;
86
        binmode STDOUT;
83
        # Open the selected file and send it to the browser
87
        # Open the selected file and send it to the browser
84
        print $input->header(-type => 'application/x-download',
88
        print $input->header(-type => 'application/x-download',
85
- 

Return to bug 11317