diff --git a/mod.php b/mod.php
index ce554192..4ec672c7 100644
--- a/mod.php
+++ b/mod.php
@@ -85,21 +85,14 @@
$fieldset['Boards'] .= ulBoards();
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->execute() or error(db_error($query));
$fieldset['Noticeboard'] .= '
';
$_body = '';
- 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' => '???');
- }
-
+ while($notice = $query->fetch()) {
$_body .= '' .
@@ -109,7 +102,9 @@
'no subject'
) .
' — by ' .
- utf8tohtml($_mod['username']) .
+ (isset($notice['username']) ?
+ utf8tohtml($notice['username'])
+ : '???') .
' at ' .
date($config['post_date'], $notice['time']) .
'';
@@ -574,15 +569,10 @@
'';
}
- $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->execute() or error(db_error($query));
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 .= '' .
(hasPermission($config['mod']['noticeboard_delete']) ?
'
[delete]'
@@ -594,8 +584,8 @@
'
no subject'
) .
'
— by ' .
- ($_mod ?
- utf8tohtml($_mod['username'])
+ (isset($notice['username']) ?
+ utf8tohtml($notice['username'])
:
'???'
) .