Bugzilla – Attachment 62974 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]
Bug 11317 - Allows for multiple directories to be accessible
Bug-11317---Allows-for-multiple-directories-to-be-.patch (text/plain), 4.13 KB, created by
Blou
on 2017-05-02 15:07:08 UTC
(
hide
)
Description:
Bug 11317 - Allows for multiple directories to be accessible
Filename:
MIME Type:
Creator:
Blou
Created:
2017-05-02 15:07:08 UTC
Size:
4.13 KB
patch
obsolete
>From 56eecd3a76f660b4817ef81edbf2cbe60243f3f7 Mon Sep 17 00:00:00 2001 >From: Blou <philippe.blouin@inlibro.com> >Date: Thu, 3 Mar 2016 11:34:34 -0500 >Subject: [PATCH] Bug 11317 - Allows for multiple directories to be accessible > >It is now possible to add as many <accessdir>SOMEDIR</accessdir> as needed to the config file. > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > reports/report_files.pl | 52 ++++++++++++++++++++++++++----------------------- > 1 file changed, 28 insertions(+), 24 deletions(-) > >diff --git a/reports/report_files.pl b/reports/report_files.pl >index dc319e5..aea95a0 100755 >--- a/reports/report_files.pl >+++ b/reports/report_files.pl >@@ -31,9 +31,10 @@ use C4::Koha; > use File::stat; > use Digest::MD5 qw(md5_hex); > >-my $input = new CGI; >+my $input = new CGI; > my $file_id = $input->param("id"); >-my $directory = C4::Context->config('accessdir'); >+my $accessdir = C4::Context->config('accessdir'); >+my @directories = $accessdir ? (ref $accessdir ? @{$accessdir} : ($accessdir)) : (); > > my ($template, $borrowernumber, $cookie) > = get_template_and_user({template_name => "reports/report_files.tt", >@@ -43,47 +44,50 @@ my ($template, $borrowernumber, $cookie) > flagsrequired => {reports => '*'}, > }); > >-unless($directory) { >+unless(@directories) { > $template->param(error_no_dir => 1); > } > else { > #Get the files list > my @files_list; >- opendir(DIR, $directory); >+ foreach my $dir(@directories){ >+ opendir(DIR, $dir); >+ foreach my $filename (readdir(DIR)) { >+ my $id = md5_hex($filename); >+ my $full_path = "$dir/$filename"; >+ next if ($filename =~ /^\./ or -d $full_path); > >- foreach my $filename (readdir(DIR)) { >- my $id = md5_hex($filename); >- my $full_path = "$directory/$filename"; >- next if ($filename =~ /^\./ or -d $full_path); >- >- my $st = stat($full_path); >- my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime($st->mtime); >- my $dt=DateTime->new(year => $year + 1900, >- month => $mon + 1, >- day => $mday, >- hour => $hour, >- minute => $min, >- ); >- push(@files_list, {name => $filename, >- date =>Koha::DateUtils::output_pref($dt), >- size => $st->size, >- id => $id}); >+ my $st = stat($full_path); >+ my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime($st->mtime); >+ my $dt=DateTime->new(year => $year + 1900, >+ month => $mon + 1, >+ day => $mday, >+ hour => $hour, >+ minute => $min, >+ ); >+ push(@files_list, {name => $filename, >+ accessdir => $dir, >+ date =>Koha::DateUtils::output_pref($dt), >+ size => $st->size, >+ id => $id}); >+ } >+ closedir(DIR); > } >- closedir(DIR); > > my %files_hash = map { $_->{id} => $_ } @files_list; > # 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 exists $files_hash{$file_id} ){ > my $filename = $files_hash{$file_id}->{name}; >+ my $dir = $files_hash{$file_id}->{accessdir}; > 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", >+ -Content_length => -s "$dir/$filename", > -attachment => "$filename"); > > my $fh; >- open $fh, "<:encoding(UTF-8)", "$directory/$filename"; >+ open $fh, "<:encoding(UTF-8)", "$dir/$filename"; > binmode $fh; > > my $buf; >-- >2.1.0
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