From 586c0ae93942a180a904733d68e5374d629fc3da Mon Sep 17 00:00:00 2001 From: Trevor Slocum Date: Tue, 8 Jun 2021 12:47:52 -0700 Subject: [PATCH] Fix pending posts display in management panel Resolves #219. --- inc/database/flatfile.php | 2 +- inc/database/mysql.php | 2 +- inc/database/mysqli.php | 2 +- inc/database/pdo.php | 2 +- inc/database/sqlite.php | 2 +- inc/database/sqlite3.php | 2 +- inc/html.php | 16 ++++++++++------ 7 files changed, 16 insertions(+), 12 deletions(-) diff --git a/inc/database/flatfile.php b/inc/database/flatfile.php index bb3865b..b50c364 100644 --- a/inc/database/flatfile.php +++ b/inc/database/flatfile.php @@ -398,7 +398,7 @@ function postsByHex($hex) { } function latestPosts($moderated = true) { - $rows = $GLOBALS['db']->selectWhere(POSTS_FILE, NULL, 10, new OrderBy(POST_TIMESTAMP, DESCENDING, INTEGER_COMPARISON)); + $rows = $GLOBALS['db']->selectWhere(POSTS_FILE, new SimpleWhereClause(POST_MODERATED, $moderated ? '>' : '=', 0, INTEGER_COMPARISON), 10, new OrderBy(POST_TIMESTAMP, DESCENDING, INTEGER_COMPARISON)); return convertPostsToSQLStyle($rows); } diff --git a/inc/database/mysql.php b/inc/database/mysql.php index 2cbdd7e..8984b35 100644 --- a/inc/database/mysql.php +++ b/inc/database/mysql.php @@ -243,7 +243,7 @@ function postsByHex($hex) { function latestPosts($moderated = true) { $posts = array(); - $result = mysql_query("SELECT * FROM `" . TINYIB_DBPOSTS . "` WHERE `moderated` = " . ($moderated ? '1' : '0') . " ORDER BY `timestamp` DESC LIMIT 10"); + $result = mysql_query("SELECT * FROM `" . TINYIB_DBPOSTS . "` WHERE `moderated` " . ($moderated ? '>' : '=') . " 0 ORDER BY `timestamp` DESC LIMIT 10"); if ($result) { while ($post = mysql_fetch_assoc($result)) { $posts[] = $post; diff --git a/inc/database/mysqli.php b/inc/database/mysqli.php index c65f8b8..d12d726 100644 --- a/inc/database/mysqli.php +++ b/inc/database/mysqli.php @@ -279,7 +279,7 @@ function postsByHex($hex) { function latestPosts($moderated = true) { global $link; $posts = array(); - $result = mysqli_query($link, "SELECT * FROM `" . TINYIB_DBPOSTS . "` WHERE `moderated` = " . ($moderated ? '1' : '0') . " ORDER BY `timestamp` DESC LIMIT 10"); + $result = mysqli_query($link, "SELECT * FROM `" . TINYIB_DBPOSTS . "` WHERE `moderated` " . ($moderated ? '>' : '=') . " 0 ORDER BY `timestamp` DESC LIMIT 10"); if ($result) { while ($post = mysqli_fetch_assoc($result)) { $posts[] = $post; diff --git a/inc/database/pdo.php b/inc/database/pdo.php index 1ce7d04..b77bc32 100644 --- a/inc/database/pdo.php +++ b/inc/database/pdo.php @@ -226,7 +226,7 @@ function postsByHex($hex) { function latestPosts($moderated = true) { $posts = array(); - $results = pdoQuery("SELECT * FROM " . TINYIB_DBPOSTS . " WHERE moderated = ? ORDER BY timestamp DESC LIMIT 10", array($moderated ? '1' : '0')); + $results = pdoQuery("SELECT * FROM " . TINYIB_DBPOSTS . " WHERE moderated " . ($moderated ? '>' : '=') . " 0 ORDER BY timestamp DESC LIMIT 10"); while ($row = $results->fetch(PDO::FETCH_ASSOC)) { $posts[] = $row; } diff --git a/inc/database/sqlite.php b/inc/database/sqlite.php index de272d7..862c8c0 100644 --- a/inc/database/sqlite.php +++ b/inc/database/sqlite.php @@ -215,7 +215,7 @@ function postsByHex($hex) { function latestPosts($moderated = true) { $posts = array(); - $result = sqlite_fetch_all(sqlite_query($GLOBALS["db"], "SELECT * FROM " . TINYIB_DBPOSTS . " ORDER BY timestamp DESC LIMIT 10"), SQLITE_ASSOC); + $result = sqlite_fetch_all(sqlite_query($GLOBALS["db"], "SELECT * FROM " . TINYIB_DBPOSTS . " WHERE `moderated` " . ($moderated ? '>' : '=') . " 0 ORDER BY timestamp DESC LIMIT 10"), SQLITE_ASSOC); foreach ($result as $post) { $posts[] = $post; } diff --git a/inc/database/sqlite3.php b/inc/database/sqlite3.php index 44070cd..a407c8b 100644 --- a/inc/database/sqlite3.php +++ b/inc/database/sqlite3.php @@ -249,7 +249,7 @@ function postsByHex($hex) { function latestPosts($moderated = true) { global $db; $posts = array(); - $result = $db->query("SELECT * FROM " . TINYIB_DBPOSTS . " ORDER BY timestamp DESC LIMIT 10"); + $result = $db->query("SELECT * FROM " . TINYIB_DBPOSTS . " WHERE `moderated` " . ($moderated ? '>' : '=') . " 0 ORDER BY timestamp DESC LIMIT 10"); while ($post = $result->fetchArray()) { $posts[] = $post; } diff --git a/inc/html.php b/inc/html.php index d98393c..aec32f6 100644 --- a/inc/html.php +++ b/inc/html.php @@ -148,8 +148,8 @@ function buildPostForm($parent, $staff_post = false) { $maxlen_message = TINYIB_MAXMESSAGE; } if ($staff_post) { - $txt_options = __('Options'); $txt_raw_html = __('Raw HTML'); + $txt_enable = __('Enable'); $txt_raw_html_info_1 = __('Text entered in the Message field will be posted as is with no formatting applied.'); $txt_raw_html_info_2 = __('Line-breaks must be specified with "<br>".'); @@ -161,12 +161,14 @@ function buildPostForm($parent, $staff_post = false) { $input_extra = << - $txt_options + $txt_raw_html -
-   $txt_raw_html_info_1
-   $txt_raw_html_info_2 + @@ -879,7 +881,9 @@ function adminBar() { $output .= '' . __('Staff Post') . '] ['; if ($isadmin) { $output .= '' . __('Rebuild All') . '] ['; - $output .= '' . __('Reports') . '] ['; + if (TINYIB_REPORT) { + $output .= '' . __('Reports') . '] ['; + } } if ($isadmin && installedViaGit()) { $output .= '' . __('Update') . '] [';