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

(-)a/debian/templates/koha-conf-site.xml.in (-1 / +4 lines)
Lines 296-302 __END_SRU_PUBLICSERVER__ Link Here
296
 <!-- Secret passphrase used by Mojolicious for signed cookies -->
296
 <!-- Secret passphrase used by Mojolicious for signed cookies -->
297
 <api_secret_passphrase>__API_SECRET__</api_secret_passphrase>
297
 <api_secret_passphrase>__API_SECRET__</api_secret_passphrase>
298
298
299
 <!-- true type font mapping accoding to type from $font_types in C4/Creators/Lib.pm -->
299
 <!-- Accessible directory from the staff client, uncomment the following line and define a valid path to let the intranet user access it-->
300
 <!-- <access_dir></access_dir> -->
301
302
 <!-- true type font mapping according to type from $font_types in C4/Creators/Lib.pm -->
300
 <ttf>
303
 <ttf>
301
    <font type="TR" >/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif.ttf</font>
304
    <font type="TR" >/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif.ttf</font>
302
    <font type="TB" >/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif-Bold.ttf</font>
305
    <font type="TB" >/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif-Bold.ttf</font>
(-)a/etc/koha-conf.xml (+3 lines)
Lines 127-132 __PAZPAR2_TOGGLE_XML_POST__ Link Here
127
 <!-- Secret passphrase used by Mojolicious for signed cookies -->
127
 <!-- Secret passphrase used by Mojolicious for signed cookies -->
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-->
131
 <!-- <access_dir></access_dir> -->
132
130
 <!-- 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 -->
131
 <ttf>
134
 <ttf>
132
    <font type="TR" >__FONT_DIR__/DejaVuSerif.ttf</font>
135
    <font type="TR" >__FONT_DIR__/DejaVuSerif.ttf</font>
(-)a/installer/data/mysql/atomicupdate/bz11317-add-permission-for-tools-access-file.sql (+1 lines)
Line 0 Link Here
1
INSERT IGNORE INTO permissions (module_bit, code, description) VALUES (13, 'access_files', 'Access to the files stored on the server');
(-)a/installer/data/mysql/userpermissions.sql (+1 lines)
Lines 58-63 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
58
   (13, 'records_batchmod', 'Perform batch modification of records (biblios or authorities)'),
58
   (13, 'records_batchmod', 'Perform batch modification of records (biblios or authorities)'),
59
   (13, 'marc_modification_templates', 'Manage marc modification templates'),
59
   (13, 'marc_modification_templates', 'Manage marc modification templates'),
60
   (13, 'records_batchdel', 'Perform batch deletion of records (bibliographic or authority)'),
60
   (13, 'records_batchdel', 'Perform batch deletion of records (bibliographic or authority)'),
61
   (13, 'access_files', 'Access to the files stored on the server'),
61
   (13, 'upload_general_files', 'Upload any file'),
62
   (13, 'upload_general_files', 'Upload any file'),
62
   (13, 'upload_manage', 'Manage uploaded files'),
63
   (13, 'upload_manage', 'Manage uploaded files'),
63
   (15, 'check_expiration', 'Check the expiration of a serial'),
64
   (15, 'check_expiration', 'Check the expiration of a serial'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc (+1 lines)
Lines 107-112 Link Here
107
    [%- CASE 'delete_public_lists' -%]<span>Delete public lists</span>
107
    [%- CASE 'delete_public_lists' -%]<span>Delete public lists</span>
108
    [%- CASE 'upload_general_files' -%]<span>Upload any file</span>
108
    [%- CASE 'upload_general_files' -%]<span>Upload any file</span>
109
    [%- CASE 'upload_manage' -%]<span>Manage uploaded files (<i>Useless without upload_general_files</i>)</span>
109
    [%- CASE 'upload_manage' -%]<span>Manage uploaded files (<i>Useless without upload_general_files</i>)</span>
110
    [%- CASE 'access_files' -%]<span>Access to the files stored on the server</span>
110
    [%- CASE 'edit_clubs' -%]<span>Create and edit clubs</span>
111
    [%- CASE 'edit_clubs' -%]<span>Create and edit clubs</span>
111
    [%- CASE 'edit_templates' -%]<span>Create and edit club templates</span>
112
    [%- CASE 'edit_templates' -%]<span>Create and edit club templates</span>
112
    [%- CASE 'enroll' -%]<span>Enroll patrons in clubs</span>
113
    [%- CASE 'enroll' -%]<span>Enroll patrons in clubs</span>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc (+3 lines)
Lines 108-111 Link Here
108
    [% IF ( CAN_user_tools_upload_general_files ) %]
108
    [% IF ( CAN_user_tools_upload_general_files ) %]
109
       <li><a href="/cgi-bin/koha/tools/upload.pl">Upload any file</a></li>
109
       <li><a href="/cgi-bin/koha/tools/upload.pl">Upload any file</a></li>
110
    [% END %]
110
    [% END %]
111
    [% IF ( CAN_user_tools_access_files ) %]
112
    <li><a href="/cgi-bin/koha/tools/access_files.pl">Report/log files</a></li>
113
    [% END %]
111
</ul></div></div>
114
</ul></div></div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reports-home.tt (-18 / +20 lines)
Lines 63-89 Link Here
63
63
64
    </div>
64
    </div>
65
65
66
<<<<<<< 3dd4c261c3d9d152edb12ead6b10b71b44418eab
66
    <div class="col-xs-6"><h2>Top lists</h2>
67
    <div class="col-xs-6"><h2>Top lists</h2>
67
	<ul>
68
        <ul>
68
        <li><a href="/cgi-bin/koha/reports/bor_issues_top.pl">Patrons with the most checkouts</a></li>
69
            <li><a href="/cgi-bin/koha/reports/bor_issues_top.pl">Patrons with the most checkouts</a></li>
69
        <li><a href="/cgi-bin/koha/reports/cat_issues_top.pl">Most-circulated items</a></li>
70
            <li><a href="/cgi-bin/koha/reports/cat_issues_top.pl">Most-circulated items</a></li>
70
    </ul>
71
        </ul>
71
72
72
    <h2>Inactive</h2>
73
        <h2>Inactive</h2>
73
    <ul>
74
        <ul>
74
        <li><a href="/cgi-bin/koha/reports/borrowers_out.pl">Patrons who haven't checked out</a></li>
75
                <li><a href="/cgi-bin/koha/reports/borrowers_out.pl">Patrons who haven't checked out</a></li>
75
        <li><a href="/cgi-bin/koha/reports/catalogue_out.pl">Items with no checkouts</a></li>
76
                <li><a href="/cgi-bin/koha/reports/catalogue_out.pl">Items with no checkouts</a></li>
76
    </ul>
77
        </ul>
77
78
78
    <h2>Other</h2>
79
        <h2>Other</h2>
79
    <ul>
80
        <ul>
80
        <li><a href="/cgi-bin/koha/reports/itemslost.pl">Items lost</a></li>
81
            <li><a href="/cgi-bin/koha/reports/itemslost.pl">Items lost</a></li>
81
                <li><a href="/cgi-bin/koha/reports/orders_by_fund.pl">Orders by fund</a></li>
82
            <li><a href="/cgi-bin/koha/reports/orders_by_fund.pl">Orders by fund</a></li>
82
        <li><a href="/cgi-bin/koha/reports/manager.pl?report_name=itemtypes">Catalog by itemtype</a></li>
83
            <li><a href="/cgi-bin/koha/reports/manager.pl?report_name=itemtypes">Catalog by item type</a></li>
83
        <li><a href="/cgi-bin/koha/reports/issues_avg_stats.pl">Average loan time</a></li>
84
            <li><a href="/cgi-bin/koha/reports/issues_avg_stats.pl">Average loan time</a></li>
84
                <li><a href="http://schema.koha-community.org/" target="blank">Koha database schema</a></li>
85
            <li><a href="http://schema.koha-community.org/" target="blank">Koha database schema</a></li>
85
                <li><a href="http://wiki.koha-community.org/wiki/SQL_Reports_Library" target="blank">Koha reports library</a></li>
86
            <li><a href="http://wiki.koha-community.org/wiki/SQL_Reports_Library" target="blank">Koha reports library</a></li>
86
</ul></div>
87
            <!--<li><a href="/cgi-bin/koha/reports/stats.screen.pl">Till reconciliation</a></li> -->
88
        </ul></div>
87
</div>
89
</div>
88
90
89
91
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/access_files.tt (+71 lines)
Line 0 Link Here
1
[% SET footerjs = 1 %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
<title>Report/log files</title>
4
[% INCLUDE 'doc-head-close.inc' %]
5
<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables_[% KOHA_VERSION %].css" />
6
</head>
7
<body>
8
[% INCLUDE 'header.inc' %]
9
[% INCLUDE 'cat-search.inc' %]
10
11
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo; Report/log files</div>
12
13
<div id="doc3" class="yui-t2">
14
   <div id="bd">
15
    <div id="yui-main">
16
    <div class="yui-b">
17
18
    <h1>Report/log files</h1>
19
20
[% IF ( error_no_dir ) %]
21
    <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>
22
[% ELSE %]
23
    [% IF ( files_loop ) %]
24
        <table id="files">
25
            <thead>
26
                <tr>
27
                    <th>Name</th>
28
                    <th>Size (bytes)</th>
29
                    <th>Date last modified</th>
30
                </tr>
31
            </thead>
32
            <tbody>
33
                [% FOREACH file IN files_loop %]
34
                <tr>
35
                    <td><a href="/cgi-bin/koha/tools/access_files.pl?id=[% file.id |url %]">[% file.name %]</a></td>
36
                    <td align="right">[% file.size %]</td>
37
                    <td>[% file.date %]</td>
38
                </tr>
39
                [% END %]
40
            </tbody>
41
        </table>
42
    [% ELSE %]
43
        No file found.
44
    [% END %]
45
[% END %]
46
47
</div>
48
</div>
49
<div class="yui-b">
50
[% INCLUDE 'tools-menu.inc' %]
51
</div>
52
</div>
53
54
[% MACRO jsinclude BLOCK %]
55
    <script type="text/javascript" src="[% interface %]/[% theme %]/js/tools-menu_[% KOHA_VERSION %].js"></script>
56
    [% INCLUDE 'datatables.inc' %]
57
    <script type="text/javascript">
58
    //<![CDATA[
59
        $(document).ready(function() {
60
            $("#files").dataTable($.extend(true, {}, dataTablesDefaults, {
61
                "sDom": 't',
62
                "aoColumnDefs": [
63
                    { "aTargets": [ -1 ], "asSorting" : [ "desc", "asc" ], "bSearchable": false }
64
                ],
65
                "bPaginate": false
66
            }));
67
    });
68
    //]]>
69
</script>
70
[% END %]
71
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt (+6 lines)
Lines 113-118 Link Here
113
    <dt><a href="/cgi-bin/koha/tools/upload.pl">Upload</a></dt>
113
    <dt><a href="/cgi-bin/koha/tools/upload.pl">Upload</a></dt>
114
    <dd>Upload any type of file, manage uploads</dd>
114
    <dd>Upload any type of file, manage uploads</dd>
115
    [% END %]
115
    [% END %]
116
117
    [% IF CAN_user_tools_access_files %]
118
    <dt><a href="/cgi-bin/koha/tools/access_files.pl">Report/log files</a></dt>
119
    <dd>Access report or log files</dd>
120
    [% END %]
121
116
</dl>
122
</dl>
117
</div>
123
</div>
118
124
(-)a/tools/access_files.pl (-1 / +111 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# Frédérick Capovilla, 2011 - Libéo
4
#
5
# Show a list of all the files in the directory specified by the option
6
# "access_dir" in koha-conf.xml so they can be downloaded by users with the
7
# "access_files" permission.
8
#
9
# This file is part of Koha.
10
#
11
# Koha is free software; you can redistribute it and/or modify it under the
12
# terms of the GNU General Public License as published by the Free Software
13
# Foundation; either version 3 of the License, or (at your option) any later
14
# version.
15
#
16
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
17
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
19
#
20
# You should have received a copy of the GNU General Public License along
21
# with Koha; if not, write to the Free Software Foundation, Inc.,
22
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23
24
use Modern::Perl;
25
26
use C4::Auth;
27
use CGI;
28
use C4::Context;
29
use C4::Output;
30
use C4::Koha;
31
use File::stat qw(stat);
32
use Digest::MD5 qw(md5_hex);
33
use Encode;
34
35
my $input = new CGI;
36
my $file_id = $input->param("id");
37
my $access_dir = C4::Context->config('access_dir');
38
my @directories = $access_dir ? (ref $access_dir ? @{$access_dir} : ($access_dir)) : ();
39
40
my ($template, $borrowernumber, $cookie)
41
    = get_template_and_user({template_name => "tools/access_files.tt",
42
                query => $input,
43
                type => "intranet",
44
                authnotrequired => 0,
45
                flagsrequired => { tools => 'access_files' },
46
                });
47
48
unless(@directories) {
49
    $template->param(error_no_dir => 1);
50
}
51
else {
52
    #Get the files list
53
    my @files_list;
54
    foreach my $dir(@directories){
55
        opendir(DIR, $dir);
56
        foreach my $filename (readdir(DIR)) {
57
            my $full_path = "$dir/$filename";
58
            my $id = md5_hex($full_path);
59
            next if ($filename =~ /^\./ or -d $full_path);
60
61
            # Make sure the filename is unicode-friendly
62
            my $decoded_filename = decode('utf8', $filename);
63
            my $st = stat("$dir/$decoded_filename");
64
65
            my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime($st->mtime);
66
            my $dt=DateTime->new(year      => $year + 1900,
67
                                  month    => $mon + 1,
68
                                  day      => $mday,
69
                                  hour     => $hour,
70
                                  minute   => $min,
71
                            );
72
            push(@files_list, {name => $decoded_filename,
73
                               access_dir => $dir,
74
                               date =>Koha::DateUtils::output_pref($dt),
75
                               size => $st->size,
76
                               id   => $id});
77
        }
78
        closedir(DIR);
79
    }
80
81
    my %files_hash = map { $_->{id} => $_ } @files_list;
82
    # If we received a file_id and it is valid, send the file to the browser
83
    if(defined $file_id and exists $files_hash{$file_id} ){
84
        my $filename = $files_hash{$file_id}->{name};
85
        my $dir = $files_hash{$file_id}->{access_dir};
86
        binmode STDOUT;
87
        # Open the selected file and send it to the browser
88
        print $input->header(-type => 'application/x-download',
89
                             -name => "$filename",
90
                             -Content_length => -s "$dir/$filename",
91
                             -attachment => "$filename");
92
93
        my $fh;
94
        open $fh, "<:encoding(UTF-8)", "$dir/$filename";
95
        binmode $fh;
96
97
        my $buf;
98
        while(read($fh, $buf, 65536)) {
99
            print $buf;
100
        }
101
        close $fh;
102
103
        exit(0);
104
    }
105
    else{
106
        # Send the file list to the template
107
        $template->param(files_loop => \@files_list);
108
    }
109
}
110
111
output_html_with_http_headers $input, $cookie, $template->output;

Return to bug 11317