View | Details | Raw Unified | Return to bug 14321
Collapse All | Expand All

(-)a/Koha/Upload.pm (-1 / +4 lines)
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;
(-)a/installer/data/mysql/atomicupdate/14321a_public.sql (+2 lines)
Line 0 Link Here
1
ALTER TABLE uploaded_files ADD COLUMN public tinyint;
2
UPDATE uploaded_files SET public=1 WHERE categorycode IS NOT NULL;
(-)a/installer/data/mysql/kohastructure.sql (-1 / +1 lines)
Lines 3374-3379 CREATE TABLE uploaded_files ( Link Here
3374
    dtcreated timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
3374
    dtcreated timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
3375
    categorycode tinytext,
3375
    categorycode tinytext,
3376
    owner int(11),
3376
    owner int(11),
3377
    public tinyint,
3377
    PRIMARY KEY (id)
3378
    PRIMARY KEY (id)
3378
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3379
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
3379
3380
3380
- 

Return to bug 14321