@@ -, +, @@ without category.) --- Koha/Upload.pm | 5 ++++- installer/data/mysql/atomicupdate/14321a_public.sql | 2 ++ installer/data/mysql/kohastructure.sql | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/14321a_public.sql --- a/Koha/Upload.pm +++ a/Koha/Upload.pm @@ -169,6 +169,7 @@ sub _init { } $self->{files} = {}; $self->{uid} = C4::Context->userenv->{number} if C4::Context->userenv; + $self->{public} = $params->{public}? 1: undef; } sub _fh { @@ -251,13 +252,14 @@ sub _register { my ( $self, $filename, $size ) = @_; my $dbh= C4::Context->dbh; my $sql= "INSERT INTO uploaded_files (hashvalue, filename, dir, filesize, - owner, categorycode) VALUES (?,?,?,?,?,?)"; + owner, categorycode, public) VALUES (?,?,?,?,?,?,?)"; my @pars= ( $self->{files}->{$filename}->{hash}, $filename, $self->{temporary}? KOHA_UPLOAD: $self->{category}, $size, $self->{uid}, $self->{category}, + $self->{category}? $self->{public}: undef, ); $dbh->do( $sql, undef, @pars ); my $i = $dbh->last_insert_id(undef, undef, 'uploaded_files', undef); @@ -274,6 +276,7 @@ sub _lookup { } else { $sql.= "WHERE hashvalue=?"; } + $sql.= $self->{public}? " AND public=1": ''; my $temp= $dbh->selectall_arrayref( $sql, { Slice => {} }, ( $params->{id} // $params->{hashvalue} // 0 ) ); return $temp; --- a/installer/data/mysql/atomicupdate/14321a_public.sql +++ a/installer/data/mysql/atomicupdate/14321a_public.sql @@ -0,0 +1,2 @@ +ALTER TABLE uploaded_files ADD COLUMN public tinyint; +UPDATE uploaded_files SET public=1 WHERE categorycode IS NOT NULL; --- a/installer/data/mysql/kohastructure.sql +++ a/installer/data/mysql/kohastructure.sql @@ -3374,6 +3374,7 @@ CREATE TABLE uploaded_files ( dtcreated timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, categorycode tinytext, owner int(11), + public tinyint, PRIMARY KEY (id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; --