diff --git a/mod.php b/mod.php
index 71053d23..a2dc5a42 100644
--- a/mod.php
+++ b/mod.php
@@ -87,7 +87,6 @@
if(hasPermission($config['mod']['noticeboard'])) {
if(!$config['cache']['enabled'] || !($fieldset['Noticeboard'] = cache::get('noticeboard_preview'))) {
-
$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));
@@ -115,27 +114,26 @@
if(!empty($_body)) {
$fieldset['Noticeboard'] .= '
';
}
-
- $fieldset['Noticeboard'] .= '' . _('View all entries') . '';
-
- $query = prepare("SELECT COUNT(*) AS `count` FROM `pms` WHERE `to` = :id AND `unread` = 1");
- $query->bindValue(':id', $mod['id']);
- $query->execute() or error(db_error($query));
- $count = $query->fetch();
- $count = $count['count'];
-
- $fieldset['Noticeboard'] .= '' . _('PM Inbox') .
- ($count > 0
- ?
- ' (' . $count . ' unread)'
- : '') .
- '';
-
- $fieldset['Noticeboard'] .= '' . _('News') . '';
-
if($config['cache']['enabled'])
cache::set('noticeboard_preview', $fieldset['Noticeboard']);
}
+
+ $fieldset['Noticeboard'] .= '' . _('View all entries') . '';
+
+ $query = prepare("SELECT COUNT(*) AS `count` FROM `pms` WHERE `to` = :id AND `unread` = 1");
+ $query->bindValue(':id', $mod['id']);
+ $query->execute() or error(db_error($query));
+ $count = $query->fetch();
+ $count = $count['count'];
+
+ $fieldset['Noticeboard'] .= '' . _('PM Inbox') .
+ ($count > 0
+ ?
+ ' (' . $count . ' unread)'
+ : '') .
+ '';
+
+ $fieldset['Noticeboard'] .= '' . _('News') . '';
}
@@ -709,6 +707,12 @@
'mod'=>true
)
);
+ } elseif(preg_match('/^\/inbox\/readall$/', $query, $match)) {
+ $query = prepare("UPDATE `pms` SET `unread` = 0 WHERE `to` = :id");
+ $query->bindValue(':id', $mod['id'], PDO::PARAM_INT);
+ $query->execute() or error(db_error($query));
+
+ header('Location: ?/inbox', true, $config['redirect_http']);
} elseif(preg_match('/^\/inbox$/', $query, $match)) {
$query = prepare("SELECT `unread`,`pms`.`id`, `time`, `sender`, `to`, `message`, `username` FROM `pms` LEFT JOIN `mods` ON `mods`.`id` = `sender` WHERE `to` = :mod ORDER BY `unread` DESC, `time` DESC");
$query->bindValue(':mod', $mod['id'], PDO::PARAM_INT);
@@ -732,6 +736,10 @@
$unread_pms++;
}
$body .= '';
+
+ if($unread_pms) {
+ $body = '(Mark all as read)
' . $body;
+ }
}