Fix pending posts display in management panel

Resolves #219.
This commit is contained in:
Trevor Slocum 2021-06-08 12:47:52 -07:00
parent 6bcc978bc9
commit 586c0ae939
7 changed files with 16 additions and 12 deletions

View File

@ -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);
}

View File

@ -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;

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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 = <<<EOF
<tr>
<td class="postblock">
$txt_options
$txt_raw_html
</td>
<td>
<label><input type="checkbox" name="raw" value="1" accesskey="r">&nbsp;$txt_raw_html</label><br>
&nbsp; <small>$txt_raw_html_info_1</small><br>
&nbsp; <small>$txt_raw_html_info_2</small>
<label>
<input type="checkbox" name="raw" value="1" accesskey="r">&nbsp;$txt_enable<br>
&nbsp; <small>$txt_raw_html_info_1</small><br>
&nbsp; <small>$txt_raw_html_info_2</small>
</label>
</td>
</tr>
<tr>
@ -879,7 +881,9 @@ function adminBar() {
$output .= '<a href="?manage&staffpost">' . __('Staff Post') . '</a>] [';
if ($isadmin) {
$output .= '<a href="?manage&rebuildall">' . __('Rebuild All') . '</a>] [';
$output .= '<a href="?manage&reports">' . __('Reports') . '</a>] [';
if (TINYIB_REPORT) {
$output .= '<a href="?manage&reports">' . __('Reports') . '</a>] [';
}
}
if ($isadmin && installedViaGit()) {
$output .= '<a href="?manage&update">' . __('Update') . '</a>] [';