Add TINYIB_MAXREPLIES - Maximum replies before a thread stops getting bumped

This commit is contained in:
Trevor Slocum 2013-04-15 19:50:52 -07:00
parent 1401e66164
commit 88d4b441c2
6 changed files with 22 additions and 2 deletions

View File

@ -160,7 +160,9 @@ if (isset($_POST['message']) || isset($_POST['file'])) {
rebuildThread($post['parent']);
if (strtolower($post['email']) != 'sage') {
bumpThreadByID($post['parent']);
if (TINYIB_MAXREPLIES == 0 || numRepliesToThreadByID($id) > TINYIB_MAXREPLIES) {
bumpThreadByID($post['parent']);
}
}
} else {
rebuildThread($post['id']);

View File

@ -141,6 +141,11 @@ function allThreads() {
return convertPostsToSQLStyle($rows);
}
function numRepliesToThreadByID($id) {
$rows = $GLOBALS['db']->selectWhere(POSTS_FILE, new SimpleWhereClause(POST_PARENT, '=', $id, INTEGER_COMPARISON));
return count($rows);
}
function postsInThreadByID($id) {
$compClause = new OrWhereClause();
$compClause->add(new SimpleWhereClause(POST_ID, '=', $id, INTEGER_COMPARISON));

View File

@ -82,7 +82,7 @@ function bumpThreadByID($id) {
mysql_query("UPDATE `" . TINYIB_DBPOSTS . "` SET `bumped` = " . time() . " WHERE `id` = " . $id . " LIMIT 1");
}
function countThreads() {
function countThreads() {
return mysql_result(mysql_query("SELECT COUNT(*) FROM `" . TINYIB_DBPOSTS . "` WHERE `parent` = 0"), 0, 0);
}
@ -97,6 +97,10 @@ function allThreads() {
return $threads;
}
function numRepliesToThreadByID($id) {
return mysql_result(mysql_query("SELECT COUNT(*) FROM `" . TINYIB_DBPOSTS . "` WHERE `parent` = " . $id), 0, 0);
}
function postsInThreadByID($id) {
$posts = array();
$result = mysql_query("SELECT * FROM `" . TINYIB_DBPOSTS . "` WHERE `id` = " . $id . " OR `parent` = " . $id . " ORDER BY `id` ASC");

View File

@ -84,6 +84,10 @@ function allThreads() {
return $threads;
}
function numRepliesToThreadByID($id) {
return sqlite_fetch_single(sqlite_query($GLOBALS["db"], "SELECT COUNT(*) FROM " . TINYIB_DBPOSTS . " WHERE parent = " . $id));
}
function postsInThreadByID($id) {
$posts = array();
$result = sqlite_fetch_all(sqlite_query($GLOBALS["db"], "SELECT * FROM " . TINYIB_DBPOSTS . " WHERE id = " . $id . " OR parent = " . $id . " ORDER BY id ASC"), SQLITE_ASSOC);

View File

@ -4,4 +4,8 @@ if (!defined('TINYIB_BOARD')) { die(''); }
define('TINYIB_NEWTHREAD', '0');
define('TINYIB_INDEXPAGE', false);
define('TINYIB_RESPAGE', true);
// The following are provided for backward compatibility and should not be relied upon
// Copy new settings from settings.default.php to settings.php
if (!defined('TINYIB_MAXREPLIES')) { define('TINYIB_MAXREPLIES', 0); }
?>

View File

@ -5,6 +5,7 @@ define('TINYIB_THREADSPERPAGE', 10); // Amount of threads shown per index page
define('TINYIB_MAXTHREADS', 100); // Oldest threads are discarded over this limit [0 to disable]
define('TINYIB_TRUNCATE', 15); // Messages are truncated to this many lines on board index pages [0 to disable]
define('TINYIB_PREVIEWREPLIES', 3); // Amount of replies previewed on index pages
define('TINYIB_MAXREPLIES', 0); // Maximum replies before a thread stops bumping [0 to disable]
define('TINYIB_MAXKB', 2048); // Maximum file size in kilobytes [0 to disable]
define('TINYIB_MAXKBDESC', "2 MB"); // Human-readable representation of the maximum file size
define('TINYIB_MAXW', 250); // Maximum image width