Lines 170-176
sub get {
Link Here
|
170 |
my ( @rv, $res); |
170 |
my ( @rv, $res); |
171 |
foreach my $r ( @$temp ) { |
171 |
foreach my $r ( @$temp ) { |
172 |
undef $res; |
172 |
undef $res; |
173 |
foreach( qw[id hashvalue filesize categorycode public permanent] ) { |
173 |
foreach( qw[id hashvalue filesize uploadcategorycode public permanent] ) { |
174 |
$res->{$_} = $r->{$_}; |
174 |
$res->{$_} = $r->{$_}; |
175 |
} |
175 |
} |
176 |
$res->{name} = $r->{filename}; |
176 |
$res->{name} = $r->{filename}; |
Lines 340-347
sub _done {
Link Here
|
340 |
sub _register { |
340 |
sub _register { |
341 |
my ( $self, $filename, $size ) = @_; |
341 |
my ( $self, $filename, $size ) = @_; |
342 |
my $dbh= C4::Context->dbh; |
342 |
my $dbh= C4::Context->dbh; |
343 |
my $sql= "INSERT INTO uploaded_files (hashvalue, filename, dir, filesize, |
343 |
my $sql= 'INSERT INTO uploaded_files (hashvalue, filename, dir, filesize, |
344 |
owner, categorycode, public, permanent) VALUES (?,?,?,?,?,?,?,?)"; |
344 |
owner, uploadcategorycode, public, permanent) VALUES (?,?,?,?,?,?,?,?)'; |
345 |
my @pars= ( |
345 |
my @pars= ( |
346 |
$self->{files}->{$filename}->{hash}, |
346 |
$self->{files}->{$filename}->{hash}, |
347 |
$filename, |
347 |
$filename, |
Lines 361-384
sub _lookup {
Link Here
|
361 |
my ( $self, $params ) = @_; |
361 |
my ( $self, $params ) = @_; |
362 |
my $dbh = C4::Context->dbh; |
362 |
my $dbh = C4::Context->dbh; |
363 |
my $sql = q| |
363 |
my $sql = q| |
364 |
SELECT id,hashvalue,filename,dir,filesize,categorycode,public,permanent |
364 |
SELECT id,hashvalue,filename,dir,filesize,uploadcategorycode,public,permanent |
365 |
FROM uploaded_files |
365 |
FROM uploaded_files |
366 |
|; |
366 |
|; |
367 |
my @pars; |
367 |
my @pars; |
368 |
if( $params->{id} ) { |
368 |
if( $params->{id} ) { |
369 |
return [] if $params->{id} !~ /^\d+(,\d+)*$/; |
369 |
return [] if $params->{id} !~ /^\d+(,\d+)*$/; |
370 |
$sql.= "WHERE id IN ($params->{id})"; |
370 |
$sql.= 'WHERE id IN ('.$params->{id}.')'; |
371 |
@pars = (); |
371 |
@pars = (); |
372 |
} elsif( $params->{hashvalue} ) { |
372 |
} elsif( $params->{hashvalue} ) { |
373 |
$sql.= "WHERE hashvalue=?"; |
373 |
$sql.= 'WHERE hashvalue=?'; |
374 |
@pars = ( $params->{hashvalue} ); |
374 |
@pars = ( $params->{hashvalue} ); |
375 |
} elsif( $params->{term} ) { |
375 |
} elsif( $params->{term} ) { |
376 |
$sql.= "WHERE (filename LIKE ? OR hashvalue LIKE ?)"; |
376 |
$sql.= 'WHERE (filename LIKE ? OR hashvalue LIKE ?)'; |
377 |
@pars = ( '%'.$params->{term}.'%', '%'.$params->{term}.'%' ); |
377 |
@pars = ( '%'.$params->{term}.'%', '%'.$params->{term}.'%' ); |
378 |
} else { |
378 |
} else { |
379 |
return []; |
379 |
return []; |
380 |
} |
380 |
} |
381 |
$sql.= $self->{public}? " AND public=1": ''; |
381 |
$sql.= $self->{public}? ' AND public=1': ''; |
382 |
$sql.= ' ORDER BY id'; |
382 |
$sql.= ' ORDER BY id'; |
383 |
my $temp= $dbh->selectall_arrayref( $sql, { Slice => {} }, @pars ); |
383 |
my $temp= $dbh->selectall_arrayref( $sql, { Slice => {} }, @pars ); |
384 |
return $temp; |
384 |
return $temp; |