diff options
| author | Michael Save <savetheinternet@tinyboard.org> | 2012-04-20 21:54:30 +1000 |
|---|---|---|
| committer | Michael Save <savetheinternet@tinyboard.org> | 2012-04-20 21:54:30 +1000 |
| commit | 07fc56b80b36fcf41e8959844d1d8329a8852a99 (patch) | |
| tree | 3b0e39d3242d5e95c00f03ef12844a8959ab5d49 | |
| parent | de84ca6f755347b2c3fcf87165704a2d9e899d77 (diff) | |
Noticeboard on dashboard
| -rw-r--r-- | inc/mod/pages.php | 14 | ||||
| -rw-r--r-- | 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 @@ <fieldset> - <legend>Boards</legend> + <legend>{% trans 'Boards' %}</legend> <ul> {% for board in boards %} @@ -12,79 +12,108 @@ {% endif %} {% if mod|hasPermission(config.mod.manageboards) %} - <a href="?/manage/{{ board.uri }}"><small>[manage]</small></a> + <a href="?/manage/{{ board.uri }}"><small>[{% trans 'manage' %}]</small></a> {% endif %} </li> {% endfor %} {% if mod|hasPermission(config.mod.newboard) %} - <li style="margin-top:15px"><a href="?/new_board"><strong>Create new board</strong></a></li> + <li style="margin-top:15px"><a href="?/new_board"><strong>{% trans 'Create new board' %}</strong></a></li> {% endif %} </ul> </fieldset> {% if mod|hasPermission(config.mod.noticeboard) %} <fieldset> - <legend>Noticeboard</legend> - - {# TODO #} + <legend>{% trans 'Noticeboard' %}</legend> + <ul> + {% if noticeboard %} + <li> + {% trans 'Latest posts:' %} + <ul> + {% for post in noticeboard %} + <li> + <a href="?/noticeboard#{{ post.id }}"> + {% if post.subject %} + {{ post.subject|e }} + {% else %} + <em>{% trans 'no subject' %}</em> + {% endif %} + </a> + <small class="unimportant"> + — by + {% if post.username %} + {{ post.username }} + {% else %} + <em>deleted?</em> + {% endif %} + at + {{ notice.time|date(config.post_date) }} + </small> + </li> + {% endfor %} + </ul> + </li> + {% endif %} + <li><a href="?/noticeboard">{% trans 'View all entries' %}</a></li> + </ul> </fieldset> {% endif %} <fieldset> - <legend>Administration</legend> + <legend>{% trans 'Administration' %}</legend> <ul> {% if mod|hasPermission(config.mod.reports) %} - <li><a href="?/reports">Report queue</a></li> + <li><a href="?/reports">{% trans 'Report queue' %}</a></li> {% endif %} {% if mod|hasPermission(config.mod.view_banlist) %} - <li><a href="?/bans">Ban list</a></li> + <li><a href="?/bans">{% trans 'Ban list' %}</a></li> {% endif %} {% if mod|hasPermission(config.mod.manageusers) %} - <li><a href="?/users">Manage users</a></li> + <li><a href="?/users">{% trans 'Manage users' %}</a></li> {% elseif mod|hasPermission(config.mod.change_password) %} - <li><a href="?/users/{{ mod.id }}">Change password</a></li> + <li><a href="?/users/{{ mod.id }}">{% trans 'Change password' %}</a></li> {% endif %} {% if mod|hasPermission(config.mod.modlog) %} - <li><a href="?/log">Moderation log</a></li> + <li><a href="?/log">{% trans 'Moderation log' %}</a></li> {% endif %} {% if mod|hasPermission(config.mod.rebuild) %} - <li><a href="?/rebuild">Rebuild</a></li> + <li><a href="?/rebuild">{% trans 'Rebuild' %}</a></li> {% if config.cache.enabled %} - <li><a href="?/flushcache">Clear cache</a></li> + <li><a href="?/flushcache">{% trans 'Clear cache' %}</a></li> {% endif %} {% endif %} {% if mod|hasPermission(config.mod.show_config) %} - <li><a href="?/config">Configuration</a></li> + <li><a href="?/config">{% trans 'Configuration' %}</a></li> {% endif %} </ul> </fieldset> {% if mod|hasPermission(config.mod.themes) %} <fieldset> - <legend>Themes</legend> + <legend>{% trans 'Themes' %}</legend> {# TODO #} </fieldset> {% endif %} <fieldset> - <legend>Search</legend> + <legend>{% trans 'Search' %}</legend> {# TODO #} </fieldset> {% if config.debug %} <fieldset> - <legend>Debug</legend> + <legend>{% trans 'Debug' %}</legend> <ul> - <li><a href="?/debug/antispam">Anti-spam</a></li> + <li><a href="?/debug/antispam">{% trans 'Anti-spam' %}</a></li> </ul> </fieldset> {% endif %} |
