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; diff --git a/mod.php b/mod.php index 408c5c39..8f3a5001 100644 --- a/mod.php +++ b/mod.php @@ -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 @@ {% if log.username %} - {{ log.username|e }} + {{ log.username|e }} + + [PM]{% if not username %} […]{% endif %} + {% elseif log.mod == -1 %} system {% else %} @@ -40,7 +43,7 @@ {% if count > logs|count %}

{% for i in range(0, (count - 1) / config.mod.modlog_page) %} - [{{ i + 1 }}] + [{{ i + 1 }}] {% endfor %}

{% 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 @@ {% endfor %} +

+ {% trans 'View more logs for this user.' %} +

{% endif %}