summaryrefslogtreecommitdiff
path: root/inc/functions.php
diff options
context:
space:
mode:
authorSavetheinternet <savetheinternet@tinyboard.org>2011-06-04 17:46:01 +1000
committerSavetheinternet <savetheinternet@tinyboard.org>2011-06-04 17:46:01 +1000
commit2511dc447c1839c6da25afdd820d05cc03bf8472 (patch)
tree238f67d1c6d7955ee7821b12c1831736b93216e2 /inc/functions.php
parent51a4b5fa495147631ab90da7bbdbad82185caab0 (diff)
ability to delete OP image
Diffstat (limited to 'inc/functions.php')
-rw-r--r--inc/functions.php8
1 files changed, 6 insertions, 2 deletions
diff --git a/inc/functions.php b/inc/functions.php
index fce90697..4eabcd84 100644
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -608,7 +608,7 @@
function deleteFile($id, $remove_entirely_if_already=true) {
global $board, $config;
- $query = prepare(sprintf("SELECT `thread`,`thumb`,`file` FROM `posts_%s` WHERE `id` = :id AND `thread` IS NOT NULL LIMIT 1", $board['uri']));
+ $query = prepare(sprintf("SELECT `thread`,`thumb`,`file` FROM `posts_%s` WHERE `id` = :id LIMIT 1", $board['uri']));
$query->bindValue(':id', $id, PDO::PARAM_INT);
$query->execute() or error(db_error($query));
@@ -618,6 +618,9 @@
$post = $query->fetch();
+ if($post['file'] == 'deleted' && !$post['thread'])
+ return; // Can't delete OP's image completely.
+
$query = prepare(sprintf("UPDATE `posts_%s` SET `thumb` = NULL, `thumbwidth` = NULL, `thumbheight` = NULL, `filewidth` = NULL, `fileheight` = NULL, `filesize` = NULL, `filename` = NULL, `filehash` = NULL, `file` = :file WHERE `id` = :id OR `thread` = :id", $board['uri']));
if($post['file'] == 'deleted' && $remove_entirely_if_already) {
// Already deleted; remove file fully
@@ -637,7 +640,8 @@
$query->bindValue(':id', $id, PDO::PARAM_INT);
$query->execute() or error(db_error($query));
- buildThread($post['thread']);
+ if($post['thread'])
+ buildThread($post['thread']);
}
// Delete a post (reply or thread)