diff options
| author | Michael Save <savetheinternet@tinyboard.org> | 2012-08-27 22:13:47 +1000 |
|---|---|---|
| committer | Michael Save <savetheinternet@tinyboard.org> | 2012-08-27 22:13:47 +1000 |
| commit | b105a17b4f47931f9d5b7f41d181246e328280ba (patch) | |
| tree | 727d93884d6503cc5f4bd491f92151a8f3014c53 | |
| parent | 913010cff5d09311ca6c8bc7a139d5deee82ba38 (diff) | |
user logs
| -rw-r--r-- | inc/mod/pages.php | 26 | ||||
| -rw-r--r-- | mod.php | 2 | ||||
| -rw-r--r-- | templates/mod/log.html | 7 | ||||
| -rw-r--r-- | templates/mod/user.html | 3 |
4 files changed, 36 insertions, 2 deletions
diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 88ff3dd5..b167cb69 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -413,6 +413,32 @@ function mod_log($page_no = 1) { mod_page(_('Moderation log'), 'mod/log.html', array('logs' => $logs, 'count' => $count)); } +function mod_user_log($username, $page_no = 1) { + global $config; + + if ($page_no < 1) + error($config['error']['404']); + + if (!hasPermission($config['mod']['modlog'])) + error($config['error']['noaccess']); + + $query = prepare("SELECT `username`, `mod`, `ip`, `board`, `time`, `text` FROM `modlogs` LEFT JOIN `mods` ON `mod` = `mods`.`id` WHERE `username` = :username ORDER BY `time` DESC LIMIT :offset, :limit"); + $query->bindValue(':username', $username); + $query->bindValue(':limit', $config['mod']['modlog_page'], PDO::PARAM_INT); + $query->bindValue(':offset', ($page_no - 1) * $config['mod']['modlog_page'], PDO::PARAM_INT); + $query->execute() or error(db_error($query)); + $logs = $query->fetchAll(PDO::FETCH_ASSOC); + + if (empty($logs) && $page_no > 1) + error($config['error']['404']); + + $query = prepare("SELECT COUNT(*) FROM `modlogs`"); + $query->execute() or error(db_error($query)); + $count = $query->fetchColumn(0); + + mod_page(_('Moderation log'), 'mod/log.html', array('logs' => $logs, 'count' => $count, 'username' => $username)); +} + function mod_view_board($boardName, $page_no = 1) { global $config, $mod; @@ -39,6 +39,8 @@ $pages = array( '/noticeboard/delete/(\d+)' => 'noticeboard_delete',// delete from noticeboard '/log' => 'log', // modlog '/log/(\d+)' => 'log', // modlog + '/log:([^/]+)' => 'user_log', // modlog + '/log:([^/]+)/(\d+)' => 'user_log', // modlog '/news' => 'news', // view news '/news/(\d+)' => 'news', // view news '/news/delete/(\d+)' => 'news_delete', // delete from news diff --git a/templates/mod/log.html b/templates/mod/log.html index dca1b2d0..43541892 100644 --- a/templates/mod/log.html +++ b/templates/mod/log.html @@ -10,7 +10,10 @@ <tr> <td class="minimal"> {% if log.username %} - <a href="?/new_PM/{{ log.username|e }}">{{ log.username|e }}</a> + {{ log.username|e }} + <small> + <a href="?/new_PM/{{ log.username|e }}">[PM]</a>{% if not username %} <a href="?/log:{{ log.username|e }}">[…]</a>{% endif %} + </small> {% elseif log.mod == -1 %} <em>system</em> {% else %} @@ -40,7 +43,7 @@ {% if count > logs|count %} <p class="unimportant" style="text-align:center;word-wrap:break-word"> {% for i in range(0, (count - 1) / config.mod.modlog_page) %} - <a href="?/log/{{ i + 1 }}">[{{ i + 1 }}]</a> + <a href="?/log{% if username %}:{{ username }}{% endif %}/{{ i + 1 }}">[{{ i + 1 }}]</a> {% endfor %} </p> {% endif %} diff --git a/templates/mod/user.html b/templates/mod/user.html index 3c4b89cf..1bb297af 100644 --- a/templates/mod/user.html +++ b/templates/mod/user.html @@ -121,5 +121,8 @@ </tr> {% endfor %} </table> + <p style="text-align:center" class="unimportant"> + <a href="?/log:{{ user.username|e }}">{% trans 'View more logs for this user.' %}</a> + </p> {% endif %} |
