Lines 169-174
sub _init {
Link Here
|
169 |
} |
169 |
} |
170 |
$self->{files} = {}; |
170 |
$self->{files} = {}; |
171 |
$self->{uid} = C4::Context->userenv->{number} if C4::Context->userenv; |
171 |
$self->{uid} = C4::Context->userenv->{number} if C4::Context->userenv; |
|
|
172 |
$self->{public} = $params->{public}? 1: undef; |
172 |
} |
173 |
} |
173 |
|
174 |
|
174 |
sub _fh { |
175 |
sub _fh { |
Lines 251-263
sub _register {
Link Here
|
251 |
my ( $self, $filename, $size ) = @_; |
252 |
my ( $self, $filename, $size ) = @_; |
252 |
my $dbh= C4::Context->dbh; |
253 |
my $dbh= C4::Context->dbh; |
253 |
my $sql= "INSERT INTO uploaded_files (hashvalue, filename, dir, filesize, |
254 |
my $sql= "INSERT INTO uploaded_files (hashvalue, filename, dir, filesize, |
254 |
owner, categorycode) VALUES (?,?,?,?,?,?)"; |
255 |
owner, categorycode, public) VALUES (?,?,?,?,?,?,?)"; |
255 |
my @pars= ( $self->{files}->{$filename}->{hash}, |
256 |
my @pars= ( $self->{files}->{$filename}->{hash}, |
256 |
$filename, |
257 |
$filename, |
257 |
$self->{temporary}? KOHA_UPLOAD: $self->{category}, |
258 |
$self->{temporary}? KOHA_UPLOAD: $self->{category}, |
258 |
$size, |
259 |
$size, |
259 |
$self->{uid}, |
260 |
$self->{uid}, |
260 |
$self->{category}, |
261 |
$self->{category}, |
|
|
262 |
$self->{category}? $self->{public}: undef, |
261 |
); |
263 |
); |
262 |
$dbh->do( $sql, undef, @pars ); |
264 |
$dbh->do( $sql, undef, @pars ); |
263 |
my $i = $dbh->last_insert_id(undef, undef, 'uploaded_files', undef); |
265 |
my $i = $dbh->last_insert_id(undef, undef, 'uploaded_files', undef); |
Lines 274-279
sub _lookup {
Link Here
|
274 |
} else { |
276 |
} else { |
275 |
$sql.= "WHERE hashvalue=?"; |
277 |
$sql.= "WHERE hashvalue=?"; |
276 |
} |
278 |
} |
|
|
279 |
$sql.= $self->{public}? " AND public=1": ''; |
277 |
my $temp= $dbh->selectall_arrayref( $sql, { Slice => {} }, |
280 |
my $temp= $dbh->selectall_arrayref( $sql, { Slice => {} }, |
278 |
( $params->{id} // $params->{hashvalue} // 0 ) ); |
281 |
( $params->{id} // $params->{hashvalue} // 0 ) ); |
279 |
return $temp; |
282 |
return $temp; |