Bugzilla – Attachment 25387 Details for
Bug 11317
Add a way to access files from the intranet
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
New version of the patch, now using datatables
0001-Adds-a-page-to-access-log-files-on-the-server-from-t.patch (text/plain), 7.20 KB, created by
Frédérick Capovilla
on 2014-02-18 17:01:52 UTC
(
hide
)
Description:
New version of the patch, now using datatables
Filename:
MIME Type:
Creator:
Frédérick Capovilla
Created:
2014-02-18 17:01:52 UTC
Size:
7.20 KB
patch
obsolete
>From 4086e5d8f36b0cc848dfe653fe8d4672f7d552fb Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Fr=C3=A9d=C3=A9rick?= <frederick.capovilla@libeo.com> >Date: Wed, 27 Nov 2013 13:46:24 -0500 >Subject: [PATCH] Adds a page to access log files on the server from the intranet. > >The directory used is defined by the "publiclogdir" preference in >koha-conf.xml. >--- > .../prog/en/modules/reports/report_files.tt | 68 ++++++++++++++ > .../prog/en/modules/reports/reports-home.tt | 1 + > reports/report_files.pl | 94 ++++++++++++++++++++ > 3 files changed, 163 insertions(+), 0 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/reports/report_files.tt > create mode 100755 reports/report_files.pl > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/report_files.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/report_files.tt >new file mode 100644 >index 0000000..6f8a7d8 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/report_files.tt >@@ -0,0 +1,68 @@ >+[% INCLUDE 'doc-head-open.inc' %] >+<title>Report/log files</title> >+[% INCLUDE 'doc-head-close.inc' %] >+<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" /> >+<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script> >+[% INCLUDE 'datatables-strings.inc' %] >+<script type="text/javascript" src="[% themelang %]/js/datatables.js"></script> >+<script type="text/JavaScript" language="JavaScript"> >+ //<![CDATA[ >+ $(document).ready(function() { >+ $("#files").dataTable($.extend(true, {}, dataTablesDefaults, { >+ "sDom": 't', >+ "aoColumnDefs": [ >+ { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false } >+ ], >+ "bPaginate": false >+ })); >+ }); >+ //]]> >+</script> >+</head> >+<body> >+[% INCLUDE 'header.inc' %] >+[% INCLUDE 'cat-search.inc' %] >+ >+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/reports/reports-home.pl">Reports</a> › Report/log files</div> >+ >+<div id="doc3" class="yui-t2"> >+ <div id="bd"> >+ <div id="yui-main"> >+ <div class="yui-b"> >+ >+ <h1>Report/log files</h1> >+ >+[% IF ( error_no_publiclogdir ) %] >+ <div class="dialog alert"><strong>Error : </strong>Report/log files could not be found because the "publiclogdir" option was not set in "koha-conf.xml". Contact your system administrator to add this option.</div> >+[% ELSE %] >+ [% IF ( files_loop ) %] >+ <table id="files"> >+ <thead> >+ <tr> >+ <th>Name</th> >+ <th>Size (bytes)</th> >+ <th>Date last modified</th> >+ </tr> >+ </thead> >+ <tbody> >+ [% FOREACH file IN files_loop %] >+ <tr> >+ <td><a href="/cgi-bin/koha/reports/report_files.pl?id=[% file.id |url %]">[% file.name %]</a></td> >+ <td align="right">[% file.size %]</td> >+ <td>[% file.date %]</td> >+ </tr> >+ [% END %] >+ </tbody> >+ </table> >+ [% ELSE %] >+ No file found. >+ [% END %] >+[% END %] >+ >+</div> >+</div> >+<div class="yui-b"> >+[% INCLUDE 'reports-menu.inc' %] >+</div> >+</div> >+[% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reports-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reports-home.tt >index c7744fa..1e61219 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reports-home.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/reports-home.tt >@@ -66,6 +66,7 @@ > <li><a href="http://schema.koha-community.org/" target="blank">Koha database schema</a></li> > <li><a href="http://wiki.koha-community.org/wiki/SQL_Reports_Library" target="blank">Koha reports library</a></li> > <!--<li><a href="/cgi-bin/koha/reports/stats.screen.pl">Till reconciliation</a></li> --> >+ <li><a href="/cgi-bin/koha/reports/report_files.pl">Report/log files</a></li> > </ul></div> > </div> > >diff --git a/reports/report_files.pl b/reports/report_files.pl >new file mode 100755 >index 0000000..85df685 >--- /dev/null >+++ b/reports/report_files.pl >@@ -0,0 +1,94 @@ >+#!/usr/bin/perl >+ >+# Frédérick Capovilla, 2011 - Libéo >+# >+# Show a list of all the files in the directory specified by the option >+# "publiclogdir" in koha-conf.xml so they can be downloaded by users with the >+# "reports" permission. >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 2 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use strict; >+use warnings; >+use C4::Auth; >+use CGI; >+use C4::Context; >+use C4::Output; >+use C4::Koha; >+use File::stat; >+ >+my $input = new CGI; >+my $file_id = $input->param("id"); >+my $directory = C4::Context->config('publiclogdir'); >+ >+my ($template, $borrowernumber, $cookie) >+ = get_template_and_user({template_name => "reports/report_files.tt", >+ query => $input, >+ type => "intranet", >+ authnotrequired => 0, >+ flagsrequired => {reports => '*'}, >+ }); >+ >+unless($directory) { >+ $template->param(error_no_publiclogdir => 1); >+} >+else { >+ #Get the files list >+ my @files_list; >+ opendir(DIR, $directory); >+ >+ my $i=0; >+ foreach my $filename (readdir(DIR)) { >+ my $full_path = "$directory/$filename"; >+ next if ($filename =~ /^\./ or -d $full_path); >+ >+ my $st = stat($full_path); >+ push(@files_list, {name => $filename, >+ date => scalar localtime($st->mtime), >+ size => $st->size, >+ id => $i}); >+ $i++; >+ } >+ closedir(DIR); >+ >+ # If we received a file_id and it is valid, send the file to the browser >+ if(defined $file_id and $file_id >= 0 and $file_id < scalar @files_list){ >+ my $filename = $files_list[$file_id]->{name}; >+ binmode STDOUT; >+ # Open the selected file and send it to the browser >+ print $input->header(-type => 'application/x-download', >+ -name => "$filename", >+ -Content_length => -s "$directory/$filename", >+ -attachment => "$filename"); >+ >+ open FILE, "<:utf8", "$directory/$filename"; >+ binmode FILE; >+ >+ my $buf; >+ while(read(FILE, $buf, 65536)) { >+ print $buf; >+ } >+ close FILE; >+ >+ exit(1); >+ } >+ else{ >+ # Send the file list to the template >+ $template->param(files_loop => \@files_list); >+ } >+} >+ >+output_html_with_http_headers $input, $cookie, $template->output; >-- >1.7.2.5 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 11317
:
23203
|
25387
|
27492
|
27579
|
27604
|
35938
|
35939
|
35940
|
36844
|
39783
|
39784
|
39785
|
39786
|
44859
|
44860
|
48629
|
48635
|
49941
|
49942
|
49943
|
49944
|
49945
|
49946
|
49947
|
50421
|
50424
|
50425
|
50440
|
53446
|
58220
|
58221
|
58222
|
58223
|
58224
|
58225
|
58226
|
62971
|
62972
|
62973
|
62974
|
62975
|
64088
|
64089
|
65691
|
65851
|
65855
|
65856
|
65857
|
65909
|
65910
|
65911
|
65912
|
65913
|
65914
|
65915
|
65918
|
66091
|
66092
|
66093
|
66094
|
66095
|
66096
|
66097
|
66098
|
66099
|
66100
|
72097
|
72309
|
72456
|
72457
|
72458
|
72459
|
72460
|
72461
|
72462
|
72463
|
72464
|
72465
|
74119
|
74379
|
74756
|
74911
|
74912
|
74916
|
74917
|
74918
|
74919
|
75019