aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB')
-rw-r--r--phpBB/includes/functions_admin.php30
-rwxr-xr-xphpBB/includes/mcp/mcp_warn.php24
2 files changed, 43 insertions, 11 deletions
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php
index 967f76d40e..3991d228e7 100644
--- a/phpBB/includes/functions_admin.php
+++ b/phpBB/includes/functions_admin.php
@@ -2007,6 +2007,36 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id
return;
}
+/**
+* Lists warned users
+*/
+function view_warned_users(&$users, &$user_count, $limit = 0, $offset = 0, $sort_by = 'user_warnings DESC')
+{
+ global $db;
+
+ $sql = 'SELECT user_id, username, user_warnings
+ FROM ' . USERS_TABLE . "
+ WHERE user_warnings > 0
+ ORDER BY $sort_by";
+ $result = $db->sql_query_limit($sql, $limit, $offset);
+
+ $users = $db->sql_fetchrowset($result);
+ $db->sql_freeresult($result);
+
+ $sql = 'SELECT count(user_id) AS user_count
+ FROM ' . USERS_TABLE . '
+ WHERE user_warnings > 0';
+
+ $result = $db->sql_query($sql);
+
+ $row = $db->sql_fetchrow($result);
+ $db->sql_freeresult($result);
+
+ $user_count = $row['user_count'];
+
+ return;
+}
+
if (class_exists('auth'))
{
/**
diff --git a/phpBB/includes/mcp/mcp_warn.php b/phpBB/includes/mcp/mcp_warn.php
index 1104936e57..b12d2af258 100755
--- a/phpBB/includes/mcp/mcp_warn.php
+++ b/phpBB/includes/mcp/mcp_warn.php
@@ -100,33 +100,31 @@ function mcp_warn_front_view($id, $mode)
// Obtain a list of the 5 naughtiest users....
// These are the 5 users with the highest warning count
- $sql = 'SELECT user_id, username, user_warnings
- FROM ' . USERS_TABLE . '
- WHERE user_warnings > 0
- ORDER BY user_warnings DESC LIMIT 5';
- $result = $db->sql_query($sql);
+ $highest = array();
+ $count = 0;
- while ($row = $db->sql_fetchrow($result))
+ view_warned_users($highest, $count, 5);
+
+ foreach ($highest as $row)
{
$template->assign_block_vars('highest', array(
'U_NOTES' => 'mcp.' . $phpEx . $SID . '&i=notes&mode=user_notes&u=' . $row['user_id'],
'U_USER' => 'memberlist.' . $phpEx . $SID . '&mode=viewprofile&u=' . $row['user_id'],
'USERNAME' => $row['username'],
- 'WARNING_TIME' => $user->format_date($row['user_warning_time']), // TODO: Need to obtain the time of the last warning. Probably store this in the USERS_TABLE rather than join the WARNINGS_TABLE for efficiency
+ 'WARNING_TIME' => $user->format_date($row['user_last_warning']),
'WARNINGS' => $row['user_warnings'],
)
);
}
- $db->sql_freeresult($result);
// And now the 5 most recent users to get in trouble
$sql = 'SELECT u.user_id, u.username, u.user_warnings, w.warning_time
FROM ' . USERS_TABLE . ' u, ' . WARNINGS_TABLE . ' w
WHERE u.user_id = w.user_id
- ORDER BY w.warning_time DESC LIMIT 5';
- $result = $db->sql_query($sql);
+ ORDER BY w.warning_time DESC';
+ $result = $db->sql_query_limit($sql, 5);
while ($row = $db->sql_fetchrow($result))
{
@@ -362,6 +360,10 @@ function add_warning($userrow, $warning, $send_pm = true, $post_id = 0)
$db->sql_query('INSERT INTO ' . WARNINGS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
- $db->sql_query('UPDATE ' . USERS_TABLE . ' SET user_warnings = user_warnings + 1 WHERE user_id = ' . $userrow['user_id']);
+ $sql = 'UPDATE ' . USERS_TABLE . '
+ SET user_warnings = user_warnings + 1,
+ user_last_warning = ' . time() . '
+ WHERE user_id = ' . $userrow['user_id'];
+ $db->sql_query($sql);
}
?> \ No newline at end of file