diff --git a/Koha/Upload.pm b/Koha/Upload.pm
index 9da26377d0..5cd1c62214 100644
--- a/Koha/Upload.pm
+++ b/Koha/Upload.pm
@@ -170,7 +170,7 @@ sub get {
my ( @rv, $res);
foreach my $r ( @$temp ) {
undef $res;
- foreach( qw[id hashvalue filesize uploadcategorycode public permanent] ) {
+ foreach( qw[id hashvalue filesize uploadcategorycode public permanent owner] ) {
$res->{$_} = $r->{$_};
}
$res->{name} = $r->{filename};
@@ -366,7 +366,7 @@ sub _lookup {
my ( $self, $params ) = @_;
my $dbh = C4::Context->dbh;
my $sql = q|
-SELECT id,hashvalue,filename,dir,filesize,uploadcategorycode,public,permanent
+SELECT id,hashvalue,filename,dir,filesize,uploadcategorycode,public,permanent,owner
FROM uploaded_files
|;
my @pars;
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc
index 4ef2a8e668..25de0b139f 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc
@@ -117,4 +117,7 @@
[% IF ( CAN_user_tools_edit_quotes ) %]
Quote editor
[% END %]
+ [% IF ( CAN_user_tools_upload_general_files ) %]
+ Upload any file
+ [% END %]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt
index 514900a5cd..220c2bf4f2 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt
@@ -109,6 +109,11 @@
Manage EDIfact transmissions
[% END %]
+ [% IF ( CAN_user_tools_upload_general_files ) %]
+ Upload
+ Upload any type of file, manage uploads
+ [% END %]
+
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt
index 6e20a8f6e7..686b50873f 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt
@@ -182,7 +182,9 @@
Choose
[% END %]
Download
-
Delete
+ [% IF record.owner == owner || CAN_user_tools_upload_manage %]
+
Delete
+ [% END %]
[% END %]
@@ -334,7 +336,6 @@ $(document).ready(function() {
Upload
-
[% PROCESS submitter %]
@@ -354,8 +355,14 @@ $(document).ready(function() {
[% END %]
[% END %]
-
+[% IF !plugin %]
+
+ [% INCLUDE 'tools-menu.inc' %]
+
+[% END %]
+
+
[% INCLUDE 'intranet-bottom.inc' %]
diff --git a/tools/upload.pl b/tools/upload.pl
index 5d9c8e7719..45b8d1cc37 100755
--- a/tools/upload.pl
+++ b/tools/upload.pl
@@ -38,13 +38,14 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
query => $input,
type => "intranet",
authnotrequired => 0,
- flagsrequired => { editcatalogue => '*' },
+ flagsrequired => { tools => 'upload_general_files' },
}
);
$template->param(
- plugin => $plugin,
- index => $index,
+ index => $index,
+ owner => $loggedinuser,
+ plugin => $plugin,
);
my $upar = $plugin ? { public => 1 } : {};
@@ -54,6 +55,7 @@ if ( $op eq 'new' ) {
uploadcategories => Koha::Upload->getCategories,
);
output_html_with_http_headers $input, $cookie, $template->output;
+
} elsif ( $op eq 'search' ) {
my $h = $id ? { id => $id } : { term => $term };
my @uploads = Koha::Upload->new($upar)->get($h);
@@ -63,8 +65,8 @@ if ( $op eq 'new' ) {
uploads => \@uploads,
);
output_html_with_http_headers $input, $cookie, $template->output;
-} elsif ( $op eq 'delete' ) {
+} elsif ( $op eq 'delete' ) {
# delete only takes the id parameter
my $upl = Koha::Upload->new($upar);
my ($fn) = $upl->delete( { id => $id } );
@@ -79,6 +81,7 @@ if ( $op eq 'new' ) {
uploadcategories => $upl->getCategories,
);
output_html_with_http_headers $input, $cookie, $template->output;
+
} elsif ( $op eq 'download' ) {
my $upl = Koha::Upload->new($upar);
my $rec = $upl->get( { id => $id, filehandle => 1 } );