From 16c4f2719a3747ddf053237cf04a64f6f02e61e8 Mon Sep 17 00:00:00 2001 From: PupperWoff Date: Wed, 7 Jun 2017 02:21:52 +0200 Subject: [PATCH] Added Feature - Cutoff for deletion of threads by OP if they have a certain number of replies. --- inc/config.php | 3 +++ post.php | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/inc/config.php b/inc/config.php index c82be167..0f0fd61f 100644 --- a/inc/config.php +++ b/inc/config.php @@ -524,6 +524,8 @@ // Allow users to delete their own posts? $config['allow_delete'] = true; + // If thread has at least this number of replies, OP can't delete it anymore. (Set to false to disable) + $config['allow_delete_cutoff'] = 10; // How long after posting should you have to wait before being able to delete that post? (In seconds.) $config['delete_time'] = 10; // Reply limit (stops bumping thread when this is reached). @@ -1232,6 +1234,7 @@ $config['error']['fileexistsinthread'] = _('That file already exists in this thread!'); $config['error']['delete_too_soon'] = _('You\'ll have to wait another %s before deleting that.'); + $config['error']['delete_post_cutoff'] = _('You can\'t delete a post with this many replies.'); $config['error']['mime_exploit'] = _('MIME type detection XSS exploit (IE) detected; post discarded.'); $config['error']['invalid_embed'] = _('Couldn\'t make sense of the URL of the video you tried to embed.'); $config['error']['captcha'] = _('You seem to have mistyped the verification.'); diff --git a/post.php b/post.php index 86e31aab..7025e698 100644 --- a/post.php +++ b/post.php @@ -239,6 +239,14 @@ if (isset($_POST['delete'])) { deleteFile($id); modLog("User deleted file from his own post #$id"); } else { + + // Check if thread, and that the delete cutoff post count hasn't been reached + if($config['allow_delete_cutoff'] && $post['thread'] === NULL) { + $count_query = query(sprintf("SELECT COUNT(*) FROM ``posts_%s`` WHERE `thread` = %d", $board['uri'], (int)$id)); + if($count_query->fetchColumn(0) >= $config['allow_delete_cutoff']) + error($config['error']['delete_post_cutoff']); + } + // Delete entire post deletePost($id); modLog("User deleted his own post #$id");