Fix approval when clearing reports

This commit is contained in:
Trevor Slocum 2021-04-15 21:30:31 -07:00
parent 5cd4049ebe
commit 79adb305a3
7 changed files with 18 additions and 18 deletions

View File

@ -39,11 +39,11 @@ while (ob_get_level() > 0) {
} }
function fancyDie($message, $go_back=1) { function fancyDie($message, $go_back=1) {
$back = 'Click here to go back'; $go_back_text = 'Click here to go back';
if (function_exists('__')) { if (function_exists('__')) {
$back = __('Click here to go back'); $go_back_text = __('Click here to go back');
} }
die('<body text="#800000" bgcolor="#FFFFEE" align="center"><br><div style="display: inline-block; background-color: #F0E0D6;font-size: 1.25em;font-family: Tahoma, Geneva, sans-serif;padding: 7px;border: 1px solid #D9BFB7;border-left: none;border-top: none;">' . $message . '</div><br><br>- <a href="javascript:history.go(-' . $back . ')">' . $back . '</a> -</body>'); die('<body text="#800000" bgcolor="#FFFFEE" align="center"><br><div style="display: inline-block; background-color: #F0E0D6;font-size: 1.25em;font-family: Tahoma, Geneva, sans-serif;padding: 7px;border: 1px solid #D9BFB7;border-left: none;border-top: none;">' . $message . '</div><br><br>- <a href="javascript:history.go(-' . $go_back . ')">' . $go_back_text . '</a> -</body>');
} }
if (!file_exists('settings.php')) { if (!file_exists('settings.php')) {
@ -573,7 +573,7 @@ if (!isset($_GET['delete']) && !isset($_GET['manage']) && (isset($_POST['name'])
fancyDie(__('Sorry, an invalid post identifier was sent. Please go back, refresh the page, and try again.')); fancyDie(__('Sorry, an invalid post identifier was sent. Please go back, refresh the page, and try again.'));
} }
if ($post['moderated'] == 1) { if ($post['moderated'] == 2) {
fancyDie(__('Moderators have determined that post does not break any rules.')); fancyDie(__('Moderators have determined that post does not break any rules.'));
} }
@ -974,7 +974,7 @@ EOF;
if ($_GET['approve'] > 0) { if ($_GET['approve'] > 0) {
$post = postByID($_GET['approve']); $post = postByID($_GET['approve']);
if ($post) { if ($post) {
approvePostByID($post['id']); approvePostByID($post['id'], 1);
$thread_id = $post['parent'] == TINYIB_NEWTHREAD ? $post['id'] : $post['parent']; $thread_id = $post['parent'] == TINYIB_NEWTHREAD ? $post['id'] : $post['parent'];
if (strtolower($post['email']) != 'sage' && (TINYIB_MAXREPLIES == 0 || numRepliesToThreadByID($thread_id) <= TINYIB_MAXREPLIES)) { if (strtolower($post['email']) != 'sage' && (TINYIB_MAXREPLIES == 0 || numRepliesToThreadByID($thread_id) <= TINYIB_MAXREPLIES)) {
@ -1034,7 +1034,7 @@ EOF;
if ($_GET['clearreports'] > 0) { if ($_GET['clearreports'] > 0) {
$post = postByID($_GET['clearreports']); $post = postByID($_GET['clearreports']);
if ($post) { if ($post) {
approvePostByID($post['id']); approvePostByID($post['id'], 2);
deleteReportsByPost($post['id']); deleteReportsByPost($post['id']);
manageLogAction(__('Approved') . ' ' . postLink('&gt;&gt;' . $post['id'])); manageLogAction(__('Approved') . ' ' . postLink('&gt;&gt;' . $post['id']));

View File

@ -259,11 +259,11 @@ function insertPost($newpost) {
return $GLOBALS['db']->insertWithAutoId(POSTS_FILE, POST_ID, $post); return $GLOBALS['db']->insertWithAutoId(POSTS_FILE, POST_ID, $post);
} }
function approvePostByID($id) { function approvePostByID($id, $moderated) {
$rows = $GLOBALS['db']->selectWhere(POSTS_FILE, new SimpleWhereClause(POST_ID, '=', $id, INTEGER_COMPARISON), 1); $rows = $GLOBALS['db']->selectWhere(POSTS_FILE, new SimpleWhereClause(POST_ID, '=', $id, INTEGER_COMPARISON), 1);
if (count($rows) > 0) { if (count($rows) > 0) {
foreach ($rows as $post) { foreach ($rows as $post) {
$post[POST_MODERATED] = 1; $post[POST_MODERATED] = $moderated;
$GLOBALS['db']->updateRowById(POSTS_FILE, POST_ID, $post); $GLOBALS['db']->updateRowById(POSTS_FILE, POST_ID, $post);
} }
} }

View File

@ -173,8 +173,8 @@ function insertPost($post) {
return mysql_insert_id(); return mysql_insert_id();
} }
function approvePostByID($id) { function approvePostByID($id, $moderated) {
mysql_query("UPDATE `" . TINYIB_DBPOSTS . "` SET `moderated` = 1 WHERE `id` = " . $id . " LIMIT 1"); mysql_query("UPDATE `" . TINYIB_DBPOSTS . "` SET `moderated` = $moderated WHERE `id` = " . $id . " LIMIT 1");
} }
function bumpThreadByID($id) { function bumpThreadByID($id) {

View File

@ -199,9 +199,9 @@ function insertPost($post) {
return mysqli_insert_id($link); return mysqli_insert_id($link);
} }
function approvePostByID($id) { function approvePostByID($id, $moderated) {
global $link; global $link;
mysqli_query($link, "UPDATE `" . TINYIB_DBPOSTS . "` SET `moderated` = 1 WHERE `id` = " . $id . " LIMIT 1"); mysqli_query($link, "UPDATE `" . TINYIB_DBPOSTS . "` SET `moderated` = " . $moderated . " WHERE `id` = " . $id . " LIMIT 1");
} }
function bumpThreadByID($id) { function bumpThreadByID($id) {

View File

@ -159,8 +159,8 @@ function insertPost($post) {
return $dbh->lastInsertId(); return $dbh->lastInsertId();
} }
function approvePostByID($id) { function approvePostByID($id, $moderated) {
pdoQuery("UPDATE " . TINYIB_DBPOSTS . " SET moderated = 1 WHERE id = ?", array($id)); pdoQuery("UPDATE " . TINYIB_DBPOSTS . " SET moderated = ? WHERE id = ?", array($id, $moderated));
} }
function bumpThreadByID($id) { function bumpThreadByID($id) {

View File

@ -151,8 +151,8 @@ function insertPost($post) {
return sqlite_last_insert_rowid($GLOBALS["db"]); return sqlite_last_insert_rowid($GLOBALS["db"]);
} }
function approvePostByID($id) { function approvePostByID($id, $moderated) {
sqlite_query($GLOBALS["db"], "UPDATE " . TINYIB_DBPOSTS . " SET moderated = 1 WHERE id = " . $id); sqlite_query($GLOBALS["db"], "UPDATE " . TINYIB_DBPOSTS . " SET moderated = " . $moderated . " WHERE id = " . $id);
} }
function bumpThreadByID($id) { function bumpThreadByID($id) {

View File

@ -175,9 +175,9 @@ function insertPost($post) {
return $db->lastInsertRowID(); return $db->lastInsertRowID();
} }
function approvePostByID($id) { function approvePostByID($id, $moderated) {
global $db; global $db;
$db->exec("UPDATE " . TINYIB_DBPOSTS . " SET moderated = 1 WHERE id = " . $id); $db->exec("UPDATE " . TINYIB_DBPOSTS . " SET moderated = " . $moderated . " WHERE id = " . $id);
} }
function bumpThreadByID($id) { function bumpThreadByID($id) {