summaryrefslogtreecommitdiff
path: root/inc/mod.php
diff options
context:
space:
mode:
authorSavetheinternet <savetheinternet@n0v4.com>2011-01-01 21:42:22 +1100
committerSavetheinternet <savetheinternet@n0v4.com>2011-01-01 21:42:22 +1100
commit1fa0f64038d74cbcfba35d79e6bc0d2ea8146359 (patch)
tree488bace5f0465299ecef66d9365dcd182a719175 /inc/mod.php
parent472e12e405df15733ae8364337636b4fa68b2dad (diff)
Rebuild threads after a post is deleted
Diffstat (limited to 'inc/mod.php')
-rw-r--r--inc/mod.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/inc/mod.php b/inc/mod.php
index 65675dff..dd16a1a6 100644
--- a/inc/mod.php
+++ b/inc/mod.php
@@ -139,6 +139,19 @@
'</fieldset>';
}
+ // Remove file from post
+ function deleteFile($id) {
+ global $board;
+
+ $query = prepare(sprintf("SELECT `thread`,`thumb`,`file` FROM `posts_%s` WHERE `id` = :id AND `thread` IS NOT NULL", $board['uri']));
+ $query->bindValue(':id', $id, PDO::PARAM_INT);
+ $query->execute() or error(db_error($query));
+
+ if($query->rowCount() < 1) {
+ error(ERROR_INVALIDPOST);
+ }
+ }
+
// Delete a post (reply or thread)
function deletePost($id) {
global $board;
@@ -157,6 +170,9 @@
if(!$post['thread']) {
// Delete thread HTML page
@unlink($board['dir'] . DIR_RES . sprintf(FILE_PAGE, $post['id']));
+ } elseif($query->rowCount() == 1) {
+ // Rebuild thread
+ $rebuild = $post['thread'];
}
if($post['thumb']) {
// Delete thumbnail
@@ -171,5 +187,9 @@
$query = prepare(sprintf("DELETE FROM `posts_%s` WHERE `id` = :id OR `thread` = :id", $board['uri']));
$query->bindValue(':id', $id, PDO::PARAM_INT);
$query->execute() or error(db_error($query));
+
+ if(isset($rebuild)) {
+ buildThread($rebuild);
+ }
}
?> \ No newline at end of file