Browse Source

combine noticeboard queries

pull/40/head
Savetheinternet 13 years ago
parent
commit
7360381b41
  1. 26
      mod.php

26
mod.php

@ -85,21 +85,14 @@
$fieldset['Boards'] .= ulBoards(); $fieldset['Boards'] .= ulBoards();
if(hasPermission($config['mod']['noticeboard'])) { if(hasPermission($config['mod']['noticeboard'])) {
$query = prepare("SELECT * FROM `noticeboard` ORDER BY `id` DESC LIMIT :limit"); $query = prepare("SELECT `noticeboard`.*, `username` FROM `noticeboard` LEFT JOIN `mods` ON `mods`.`id` = `mod` ORDER BY `id` DESC LIMIT :limit");
$query->bindValue(':limit', $config['mod']['noticeboard_dashboard'], PDO::PARAM_INT); $query->bindValue(':limit', $config['mod']['noticeboard_dashboard'], PDO::PARAM_INT);
$query->execute() or error(db_error($query)); $query->execute() or error(db_error($query));
$fieldset['Noticeboard'] .= '<li>'; $fieldset['Noticeboard'] .= '<li>';
$_body = ''; $_body = '';
while($notice = $query->fetch()) { while($notice = $query->fetch()) {
$m_query = prepare("SELECT `username` FROM `mods` WHERE `id` = :id");
$m_query->bindValue(':id', $notice['mod'], PDO::PARAM_INT);
$m_query->execute() or error(db_error($m_query));
if(!$_mod = $m_query->fetch()) {
$_mod = Array('username' => '<em>???</em>');
}
$_body .= '<li><a href="?/noticeboard#' . $_body .= '<li><a href="?/noticeboard#' .
$notice['id'] . $notice['id'] .
'">' . '">' .
@ -109,7 +102,9 @@
'<em>no subject</em>' '<em>no subject</em>'
) . ) .
'</a><span class="unimportant"> &mdash; by ' . '</a><span class="unimportant"> &mdash; by ' .
utf8tohtml($_mod['username']) . (isset($notice['username']) ?
utf8tohtml($notice['username'])
: '<em>???</em>') .
' at ' . ' at ' .
date($config['post_date'], $notice['time']) . date($config['post_date'], $notice['time']) .
'</span></li>'; '</span></li>';
@ -574,15 +569,10 @@
'</form></fieldset>'; '</form></fieldset>';
} }
$query = prepare("SELECT * FROM `noticeboard` ORDER BY `id` DESC LIMIT :limit"); $query = prepare("SELECT `noticeboard`.*, `username` FROM `noticeboard` LEFT JOIN `mods` ON `mods`.`id` = `mod` ORDER BY `id` DESC LIMIT :limit");
$query->bindValue(':limit', $config['mod']['noticeboard_display'], PDO::PARAM_INT); $query->bindValue(':limit', $config['mod']['noticeboard_display'], PDO::PARAM_INT);
$query->execute() or error(db_error($query)); $query->execute() or error(db_error($query));
while($notice = $query->fetch()) { while($notice = $query->fetch()) {
$m_query = prepare("SELECT `username` FROM `mods` WHERE `id` = :id");
$m_query->bindValue(':id', $notice['mod'], PDO::PARAM_INT);
$m_query->execute() or error(db_error($m_query));
$_mod = $m_query->fetch();
$body .= '<div class="ban">' . $body .= '<div class="ban">' .
(hasPermission($config['mod']['noticeboard_delete']) ? (hasPermission($config['mod']['noticeboard_delete']) ?
'<span style="float:right;padding:2px"><a class="unimportant" href="?/noticeboard/delete/' . $notice['id'] . '">[delete]</a></span>' '<span style="float:right;padding:2px"><a class="unimportant" href="?/noticeboard/delete/' . $notice['id'] . '">[delete]</a></span>'
@ -594,8 +584,8 @@
'<em>no subject</em>' '<em>no subject</em>'
) . ) .
'<span class="unimportant"> &mdash; by ' . '<span class="unimportant"> &mdash; by ' .
($_mod ? (isset($notice['username']) ?
utf8tohtml($_mod['username']) utf8tohtml($notice['username'])
: :
'<em>???</em>' '<em>???</em>'
) . ) .

Loading…
Cancel
Save