Browse Source

Noticeboard on dashboard

pull/40/head
Savetheinternet 13 years ago
parent
commit
6f62e038d4
  1. 2
      inc/config.php
  2. 39
      mod.php

2
inc/config.php

@ -254,6 +254,8 @@
$config['mod']['search_results'] = 75; $config['mod']['search_results'] = 75;
// Maximum number of notices to display on the moderator noticeboard // Maximum number of notices to display on the moderator noticeboard
$config['mod']['noticeboard_display'] = 50; $config['mod']['noticeboard_display'] = 50;
// Number of entries to summarize and display on the dashboard
$config['mod']['noticeboard_dashboard'] = 5;
// Probably best not to change these: // Probably best not to change these:
if(!defined('JANITOR')) { if(!defined('JANITOR')) {

39
mod.php

@ -88,7 +88,40 @@
$fieldset['Boards'] .= ulBoards(); $fieldset['Boards'] .= ulBoards();
if($mod['type'] >= $config['mod']['noticeboard']) { if($mod['type'] >= $config['mod']['noticeboard']) {
$fieldset['Noticeboard'] .= '<li><a href="?/noticeboard">View previous entries</a></li>'; $query = prepare("SELECT * FROM `noticeboard` 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'] .= '<li>';
$_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' => '<em>???</em>');
}
$_body .= '<li><a href="?/noticeboard#' .
$notice['id'] .
'">' .
($notice['subject'] ?
$notice['subject']
:
'<em>no subject</em>'
) .
'</a><span class="unimportant"> — by ' .
$_mod['username'] .
' at ' .
date($config['post_date'], $notice['time']) .
'</span></li>';
}
if(!empty($_body)) {
$fieldset['Noticeboard'] .= '<ul>' . $_body . '</ul></li><li>';
}
$fieldset['Noticeboard'] .= '<a href="?/noticeboard">View all entires</a></li>';
} }
if($mod['type'] >= $config['mod']['reports']) { if($mod['type'] >= $config['mod']['reports']) {
@ -197,7 +230,7 @@
$body = ''; $body = '';
if($mod['type'] >= $config['mod']['noticeboard_post']) { if($mod['type'] >= $config['mod']['noticeboard_post']) {
if(isset($_POST['subject']) && isset($_POST['body'])) { if(isset($_POST['subject']) && isset($_POST['body']) && !empty($_POST['body'])) {
$query = prepare("INSERT INTO `noticeboard` VALUES (NULL, :mod, :time, :subject, :body)"); $query = prepare("INSERT INTO `noticeboard` VALUES (NULL, :mod, :time, :subject, :body)");
$query->bindValue(':mod', $mod['id'], PDO::PARAM_INT); $query->bindValue(':mod', $mod['id'], PDO::PARAM_INT);
$query->bindvalue(':time', time(), PDO::PARAM_INT); $query->bindvalue(':time', time(), PDO::PARAM_INT);
@ -239,7 +272,7 @@
($mod['type'] >= $config['mod']['noticeboard_delete'] ? ($mod['type'] >= $config['mod']['noticeboard_delete'] ?
'<span style="float:right;padding:2px"><a class="unimportant" href="?/noticeboard/delete/' . $notice['id'] . '">[delete]</a>' '<span style="float:right;padding:2px"><a class="unimportant" href="?/noticeboard/delete/' . $notice['id'] . '">[delete]</a>'
: '') . : '') .
'</span><h2>' . '</span><h2 id="' . $notice['id'] . '">' .
($notice['subject'] ? ($notice['subject'] ?
$notice['subject'] $notice['subject']
: :

Loading…
Cancel
Save