user logs

This commit is contained in:
Michael Save 2012-08-27 22:13:47 +10:00
parent 913010cff5
commit b105a17b4f
4 changed files with 36 additions and 2 deletions

View File

@ -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;

View File

@ -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

View File

@ -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 }}">[&hellip;]</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 %}

View File

@ -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 %}