Allow setting $image->posted
values
This commit is contained in:
parent
6a248a0a5c
commit
6bc1ec4f81
1 changed files with 11 additions and 4 deletions
|
@ -28,7 +28,7 @@ class Image
|
||||||
public ?array $tag_array;
|
public ?array $tag_array;
|
||||||
public int $owner_id;
|
public int $owner_id;
|
||||||
public string $owner_ip;
|
public string $owner_ip;
|
||||||
public string $posted;
|
public ?string $posted = null;
|
||||||
public ?string $source;
|
public ?string $source;
|
||||||
public bool $locked = false;
|
public bool $locked = false;
|
||||||
public ?bool $lossless = null;
|
public ?bool $lossless = null;
|
||||||
|
@ -368,6 +368,10 @@ class Image
|
||||||
global $database, $user;
|
global $database, $user;
|
||||||
$cut_name = substr($this->filename, 0, 255);
|
$cut_name = substr($this->filename, 0, 255);
|
||||||
|
|
||||||
|
if (is_null($this->posted) || $this->posted == "") {
|
||||||
|
$this->posted = date('c', time());
|
||||||
|
}
|
||||||
|
|
||||||
if (is_null($this->id)) {
|
if (is_null($this->id)) {
|
||||||
$database->execute(
|
$database->execute(
|
||||||
"INSERT INTO images(
|
"INSERT INTO images(
|
||||||
|
@ -382,13 +386,14 @@ class Image
|
||||||
:filename, :filesize,
|
:filename, :filesize,
|
||||||
:hash, :mime, :ext,
|
:hash, :mime, :ext,
|
||||||
0, 0,
|
0, 0,
|
||||||
now(), :source
|
:posted, :source
|
||||||
)",
|
)",
|
||||||
[
|
[
|
||||||
"owner_id" => $user->id, "owner_ip" => $_SERVER['REMOTE_ADDR'],
|
"owner_id" => $user->id, "owner_ip" => $_SERVER['REMOTE_ADDR'],
|
||||||
"filename" => $cut_name, "filesize" => $this->filesize,
|
"filename" => $cut_name, "filesize" => $this->filesize,
|
||||||
"hash" => $this->hash, "mime" => strtolower($this->mime),
|
"hash" => $this->hash, "mime" => strtolower($this->mime),
|
||||||
"ext" => strtolower($this->ext), "source" => $this->source
|
"ext" => strtolower($this->ext),
|
||||||
|
"posted" => $this->posted, "source" => $this->source
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
$this->id = $database->get_last_insert_id('images_id_seq');
|
$this->id = $database->get_last_insert_id('images_id_seq');
|
||||||
|
@ -396,7 +401,8 @@ class Image
|
||||||
$database->execute(
|
$database->execute(
|
||||||
"UPDATE images SET ".
|
"UPDATE images SET ".
|
||||||
"filename = :filename, filesize = :filesize, hash = :hash, ".
|
"filename = :filename, filesize = :filesize, hash = :hash, ".
|
||||||
"mime = :mime, ext = :ext, width = 0, height = 0, source = :source ".
|
"mime = :mime, ext = :ext, width = 0, height = 0, ".
|
||||||
|
"posted = :posted, source = :source ".
|
||||||
"WHERE id = :id",
|
"WHERE id = :id",
|
||||||
[
|
[
|
||||||
"filename" => $cut_name,
|
"filename" => $cut_name,
|
||||||
|
@ -404,6 +410,7 @@ class Image
|
||||||
"hash" => $this->hash,
|
"hash" => $this->hash,
|
||||||
"mime" => strtolower($this->mime),
|
"mime" => strtolower($this->mime),
|
||||||
"ext" => strtolower($this->ext),
|
"ext" => strtolower($this->ext),
|
||||||
|
"posted" => $this->posted,
|
||||||
"source" => $this->source,
|
"source" => $this->source,
|
||||||
"id" => $this->id,
|
"id" => $this->id,
|
||||||
]
|
]
|
||||||
|
|
Reference in a new issue