From 07fc56b80b36fcf41e8959844d1d8329a8852a99 Mon Sep 17 00:00:00 2001 From: Michael Save Date: Fri, 20 Apr 2012 21:54:30 +1000 Subject: [PATCH] Noticeboard on dashboard --- inc/mod/pages.php | 14 ++++++++ templates/mod/dashboard.html | 67 ++++++++++++++++++++++++++---------- 2 files changed, 62 insertions(+), 19 deletions(-) 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 @@
- Boards + {% trans 'Boards' %}
{% if mod|hasPermission(config.mod.noticeboard) %}
- Noticeboard - - {# TODO #} + {% trans 'Noticeboard' %} +
{% endif %}
- Administration + {% trans 'Administration' %}
{% if mod|hasPermission(config.mod.themes) %}
- Themes + {% trans 'Themes' %} {# TODO #}
{% endif %}
- Search + {% trans 'Search' %} {# TODO #}
{% if config.debug %}
- Debug + {% trans 'Debug' %}
{% endif %}