diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 78f560ec..e40dc241 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -61,10 +61,24 @@ function mod_confirm($request) { } function mod_dashboard() { + global $config; + $args = array(); $args['boards'] = listBoards(); + if(hasPermission($config['mod']['noticeboard'])) { + if(!$config['cache']['enabled'] || !$args['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)); + $args['noticeboard'] = $query->fetchAll(PDO::FETCH_ASSOC); + + if($config['cache']['enabled']) + cache::set('noticeboard_preview', $args['noticeboard']); + } + } + mod_page('Dashboard', 'mod/dashboard.html', $args); } diff --git a/templates/mod/dashboard.html b/templates/mod/dashboard.html index e9290e12..173c0e94 100644 --- a/templates/mod/dashboard.html +++ b/templates/mod/dashboard.html @@ -1,5 +1,5 @@
{% if mod|hasPermission(config.mod.noticeboard) %} {% endif %} {% if mod|hasPermission(config.mod.themes) %} {% endif %} {% if config.debug %} {% endif %}