1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-27 17:00:52 +01:00

Noticeboard on dashboard

This commit is contained in:
Savetheinternet 2011-03-30 21:57:51 +11:00
parent e978bfd2b0
commit 6f62e038d4
2 changed files with 38 additions and 3 deletions

View File

@ -254,6 +254,8 @@
$config['mod']['search_results'] = 75;
// Maximum number of notices to display on the moderator noticeboard
$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:
if(!defined('JANITOR')) {

39
mod.php
View File

@ -88,7 +88,40 @@
$fieldset['Boards'] .= ulBoards();
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']) {
@ -197,7 +230,7 @@
$body = '';
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->bindValue(':mod', $mod['id'], PDO::PARAM_INT);
$query->bindvalue(':time', time(), PDO::PARAM_INT);
@ -239,7 +272,7 @@
($mod['type'] >= $config['mod']['noticeboard_delete'] ?
'<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']
: