Add TINYIB_UPDATEBUMPED

Update thread position when a reply is deleted.

Resolves #120.
This commit is contained in:
Trevor Slocum 2021-07-07 23:04:29 -07:00
parent 088353c25c
commit 13aff83a30
9 changed files with 65 additions and 2 deletions

View File

@ -269,6 +269,16 @@ function updatePostMessage($id, $message) {
}
}
function updatePostBumped($id, $bumped) {
$rows = $GLOBALS['db']->selectWhere(POSTS_FILE, new SimpleWhereClause(POST_ID, '=', $id, INTEGER_COMPARISON), 1);
if (count($rows) > 0) {
foreach ($rows as $post) {
$post[POST_BUMPED] = $bumped;
$GLOBALS['db']->updateRowById(POSTS_FILE, POST_ID, $post);
}
}
}
function approvePostByID($id, $moderated) {
$rows = $GLOBALS['db']->selectWhere(POSTS_FILE, new SimpleWhereClause(POST_ID, '=', $id, INTEGER_COMPARISON), 1);
if (count($rows) > 0) {

View File

@ -177,6 +177,10 @@ function updatePostMessage($id, $message) {
mysql_query("UPDATE `" . TINYIB_DBPOSTS . "` SET `message` = '" . mysql_real_escape_string($message) . "' WHERE `id` = " . $id . " LIMIT 1");
}
function updatePostBumped($id, $bumped) {
mysql_query("UPDATE `" . TINYIB_DBPOSTS . "` SET `bumped` = '" . mysql_real_escape_string($bumped) . "' WHERE `id` = " . $id . " LIMIT 1");
}
function approvePostByID($id, $moderated) {
mysql_query("UPDATE `" . TINYIB_DBPOSTS . "` SET `moderated` = $moderated WHERE `id` = " . $id . " LIMIT 1");
}

View File

@ -204,6 +204,11 @@ function updatePostMessage($id, $message) {
mysqli_query($link, "UPDATE `" . TINYIB_DBPOSTS . "` SET `message` = '" . mysqli_real_escape_string($link, $message) . "' WHERE `id` = " . $id . " LIMIT 1");
}
function updatePostBumped($id, $bumped) {
global $link;
mysqli_query($link, "UPDATE `" . TINYIB_DBPOSTS . "` SET `bumped` = '" . mysqli_real_escape_string($link, $bumped) . "' WHERE `id` = " . $id . " LIMIT 1");
}
function approvePostByID($id, $moderated) {
global $link;
mysqli_query($link, "UPDATE `" . TINYIB_DBPOSTS . "` SET `moderated` = " . $moderated . " WHERE `id` = " . $id . " LIMIT 1");

View File

@ -163,6 +163,10 @@ function updatePostMessage($id, $message) {
pdoQuery("UPDATE " . TINYIB_DBPOSTS . " SET message = ? WHERE id = ?", array($message, $id));
}
function updatePostBumped($id, $bumped) {
pdoQuery("UPDATE " . TINYIB_DBPOSTS . " SET bumped = ? WHERE id = ?", array($bumped, $id));
}
function approvePostByID($id, $moderated) {
pdoQuery("UPDATE " . TINYIB_DBPOSTS . " SET moderated = ? WHERE id = ?", array($moderated, $id));
}

View File

@ -155,6 +155,10 @@ function updatePostMessage($id, $message) {
sqlite_query($GLOBALS["db"], "UPDATE " . TINYIB_DBPOSTS . " SET message = '" . sqlite_escape_string($message) . "' WHERE id = " . $id);
}
function updatePostBumped($id, $bumped) {
sqlite_query($GLOBALS["db"], "UPDATE " . TINYIB_DBPOSTS . " SET bumped = '" . sqlite_escape_string($bumped) . "' WHERE id = " . $id);
}
function approvePostByID($id, $moderated) {
sqlite_query($GLOBALS["db"], "UPDATE " . TINYIB_DBPOSTS . " SET moderated = " . $moderated . " WHERE id = " . $id);
}

View File

@ -180,6 +180,11 @@ function updatePostMessage($id, $message) {
$db->exec("UPDATE " . TINYIB_DBPOSTS . " SET message = '" . $db->escapeString($message) . "' WHERE id = " . $id);
}
function updatePostBumped($id, $bumped) {
global $db;
$db->exec("UPDATE " . TINYIB_DBPOSTS . " SET bumped = '" . $db->escapeString($bumped) . "' WHERE id = " . $id);
}
function approvePostByID($id, $moderated) {
global $db;
$db->exec("UPDATE " . TINYIB_DBPOSTS . " SET moderated = " . $moderated . " WHERE id = " . $id);

View File

@ -82,6 +82,9 @@ if (!defined('TINYIB_REQMOD')) {
if (!defined('TINYIB_BANMESSAGE')) {
define('TINYIB_BANMESSAGE', true);
}
if (!defined('TINYIB_UPDATEBUMPED')) {
define('TINYIB_UPDATEBUMPED', true);
}
if (!defined('TINYIB_SPOILERTEXT')) {
define('TINYIB_SPOILERTEXT', false);
}

View File

@ -212,13 +212,20 @@ function deletePostImages($post) {
function deletePost($id) {
$id = intval($id);
$is_op = false;
$posts = postsInThreadByID($id, false);
$parent = 0;
$op = array();
$posts = postsInThreadByID($id, false);
foreach ($posts as $post) {
if ($post['parent'] == TINYIB_NEWTHREAD) {
if ($post['id'] == $id) {
$is_op = true;
}
$op = $post;
continue;
} else if ($post['id'] == $id) {
$parent = $post['parent'];
}
deletePostImages($post);
@ -231,7 +238,27 @@ function deletePost($id) {
deletePostByID($op['id']);
}
@unlink('res/' . $id . '.html');
if ($is_op) {
@unlink('res/' . $id . '.html');
return;
}
$current_bumped = 0;
$new_bumped = 0;
$posts = postsInThreadByID($parent, false);
foreach ($posts as $post) {
if ($post['parent'] == TINYIB_NEWTHREAD) {
$current_bumped = $post['bumped'];
} else if ($post['id'] == $id || strtolower($post['email']) == 'sage') {
continue;
}
$new_bumped = $post['timestamp'];
}
if ($new_bumped >= $current_bumped) {
return;
}
updatePostBumped($parent, $new_bumped);
rebuildIndexes();
}
function checkCAPTCHA($mode) {

View File

@ -33,6 +33,7 @@ define('TINYIB_REPORT', false); // Allow users to report posts
define('TINYIB_AUTOHIDE', 0); // Amount of reports which will cause a post to be hidden until it is approved [0 to disable]
define('TINYIB_REQMOD', ''); // Require moderation before displaying posts: files / all ['' to disable]
define('TINYIB_BANMESSAGE', true); // Allow staff to append a custom message to posts when banning users
define('TINYIB_UPDATEBUMPED', true); // Update thread position when a reply is deleted
define('TINYIB_SPOILERTEXT', false); // Allow users to hide text until it is hovered over using the tags <s>text here</s> or <spoiler>text here</spoiler>
define('TINYIB_SPOILERIMAGE', false); // Allow users to blur thumbnails via a "Spoiler" checkbox
define('TINYIB_AUTOREFRESH', 30); // Delay (in seconds) between attempts to refresh a thread automatically [0 to disable]