@@ -, +, @@ permission -1) Having done requirements of previous patches, like adding 'accessdir' to koha-conf... --- .../bz11317-add-permission-for-tools-access-file.sql | 1 + installer/data/mysql/userpermissions.sql | 1 + koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc | 1 + .../{reports/report_files.tt => tools/access_files.tt} | 6 +++--- koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt | 4 +++- reports/report_files.pl => tools/access_files.pl | 11 ++++++----- 6 files changed, 15 insertions(+), 9 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bz11317-add-permission-for-tools-access-file.sql rename koha-tmpl/intranet-tmpl/prog/en/modules/{reports/report_files.tt => tools/access_files.tt} (88%) rename reports/report_files.pl => tools/access_files.pl (93%) --- 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 @@ -0,0 +1, @@ +INSERT INTO permissions (module_bit, code, description) VALUES (13, 'access_files', 'Access to the files stored on the server'); --- a/installer/data/mysql/userpermissions.sql +++ a/installer/data/mysql/userpermissions.sql @@ -57,6 +57,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES (13, 'records_batchmod', 'Perform batch modification of records (biblios or authorities)'), (13, 'marc_modification_templates', 'Manage marc modification templates'), (13, 'records_batchdel', 'Perform batch deletion of records (bibliographic or authority)'), + (13, 'access_files', 'Access to the files stored on the server'), (15, 'check_expiration', 'Check the expiration of a serial'), (15, 'claim_serials', 'Claim missing serials'), (15, 'create_subscription', 'Create a new subscription'), --- a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc @@ -100,5 +100,6 @@ [%- CASE 'report' -%]Use report plugins [%- CASE 'tool' -%]Use tool plugins [%- CASE 'delete_public_lists' -%]Delete public lists + [%- CASE 'access_files' -%]Access to the files stored on the server [%- END -%] [%- END -%] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/report_files.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/report_files.tt @@ -22,7 +22,7 @@ [% INCLUDE 'header.inc' %] [% INCLUDE 'cat-search.inc' %] - +
@@ -46,7 +46,7 @@ [% FOREACH file IN files_loop %] - [% file.name %] + [% file.name %] [% file.size %] [% file.date %] @@ -61,7 +61,7 @@
-[% INCLUDE 'reports-menu.inc' %] +[% INCLUDE 'tools-menu.inc' %]
[% INCLUDE 'intranet-bottom.inc' %] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt @@ -109,8 +109,10 @@
Manage EDIfact transmissions
[% END %] -
Report/log files
+ [% IF CAN_user_tools_access_files %] +
Report/log files
Report/log files
+ [% END %] --- a/reports/report_files.pl +++ a/reports/report_files.pl @@ -4,7 +4,7 @@ # # 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 -# "reports" permission. +# "access_files" permission. # # This file is part of Koha. # @@ -23,12 +23,13 @@ use strict; use warnings; + use C4::Auth; use CGI; use C4::Context; use C4::Output; use C4::Koha; -use File::stat; +use File::stat qw(stat); use Digest::MD5 qw(md5_hex); my $input = new CGI; @@ -37,11 +38,11 @@ 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", + = get_template_and_user({template_name => "tools/access_files.tt", query => $input, type => "intranet", authnotrequired => 0, - flagsrequired => {reports => '*'}, + flagsrequired => { tools => 'access_files' }, }); unless(@directories) { @@ -76,7 +77,7 @@ else { 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} ){ + if(defined $file_id and exists $files_hash{$file_id} ){ my $filename = $files_hash{$file_id}->{name}; my $dir = $files_hash{$file_id}->{accessdir}; binmode STDOUT; --