From a7dcdb07602f9d1e72cfbcd2c0c02c3dacd06320 Mon Sep 17 00:00:00 2001 From: Graham Eames Date: Wed, 14 Dec 2005 20:54:54 +0000 Subject: [PATCH] Adding the ability to get a list of all users with outstanding warnings git-svn-id: file:///svn/phpbb/trunk@5333 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/functions_admin.php | 14 +++-- phpBB/includes/mcp/mcp_warn.php | 63 +++++++++++++++++++ phpBB/language/en/mcp.php | 2 + .../subSilver/template/mcp_warn_front.html | 2 +- .../subSilver/template/mcp_warn_list.html | 44 +++++++++++++ 5 files changed, 118 insertions(+), 7 deletions(-) create mode 100755 phpBB/styles/subSilver/template/mcp_warn_list.html diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 3991d228e7..91bc2fa85f 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2010,14 +2010,15 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id /** * Lists warned users */ -function view_warned_users(&$users, &$user_count, $limit = 0, $offset = 0, $sort_by = 'user_warnings DESC') +function view_warned_users(&$users, &$user_count, $limit = 0, $offset = 0, $limit_days = 0, $sort_by = 'user_warnings DESC') { global $db; - $sql = 'SELECT user_id, username, user_warnings - FROM ' . USERS_TABLE . " + $sql = 'SELECT user_id, username, user_warnings, user_last_warning + FROM ' . USERS_TABLE . ' WHERE user_warnings > 0 - ORDER BY $sort_by"; + ' . (($limit_days) ? "AND user_last_warning >= $limit_days" : '') . " + ORDER BY $sort_by"; $result = $db->sql_query_limit($sql, $limit, $offset); $users = $db->sql_fetchrowset($result); @@ -2025,14 +2026,15 @@ function view_warned_users(&$users, &$user_count, $limit = 0, $offset = 0, $sort $sql = 'SELECT count(user_id) AS user_count FROM ' . USERS_TABLE . ' - WHERE user_warnings > 0'; + WHERE user_warnings > 0 + ' . (($limit_days) ? "AND user_last_warning >= $limit_days" : ''); $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - $user_count = $row['user_count']; + $user_count = $row['user_count']; return; } diff --git a/phpBB/includes/mcp/mcp_warn.php b/phpBB/includes/mcp/mcp_warn.php index b12d2af258..c37b186946 100755 --- a/phpBB/includes/mcp/mcp_warn.php +++ b/phpBB/includes/mcp/mcp_warn.php @@ -41,6 +41,10 @@ class mcp_warn mcp_warn_front_view($id, $mode); $this->tpl_name = 'mcp_warn_front'; break; + case 'list': + mcp_warn_list_view($id, $mode, $action); + $this->tpl_name = 'mcp_warn_list'; + break; case 'warn_post': mcp_warn_post_view($id, $mode, $action); $this->tpl_name = 'mcp_warn_post'; @@ -141,6 +145,65 @@ function mcp_warn_front_view($id, $mode) $db->sql_freeresult($result); } +/** +* Lists all users with warnings +*/ +function mcp_warn_list_view($id, $mode, $action) +{ + global $SID, $phpEx, $phpbb_root_path, $config; + global $template, $db, $user, $auth; + + $user->add_lang('memberlist'); + + $start = request_var('start', 0); + $st = request_var('st', 0); + $sk = request_var('sk', 'b'); + $sd = request_var('sd', 'd'); + + $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 364 => $user->lang['1_YEAR']); + $sort_by_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_DATE'], 'c' => $user->lang['SORT_WARNINGS']); + $sort_by_sql = array('a' => 'username', 'b' => 'user_last_warning', 'c' => 'user_warnings'); + + $s_limit_days = $s_sort_key = $s_sort_dir = ''; + gen_sort_selects($limit_days, $sort_by_text, $st, $sk, $sd, $s_limit_days, $s_sort_key, $s_sort_dir); + + // Define where and sort sql for use in displaying logs + $sql_where = ($st) ? (time() - ($st * 86400)) : 0; + $sql_sort = $sort_by_sql[$sk] . ' ' . (($sd == 'd') ? 'DESC' : 'ASC'); + + $users = array(); + $user_count = 0; + + view_warned_users($users, $user_count, $config['topics_per_page'], $start, $sql_where, $sql_sort); + + foreach ($users as $row) + { + $template->assign_block_vars('user', 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_last_warning']), + 'WARNINGS' => $row['user_warnings'], + ) + ); + } + + $template->assign_vars(array( + 'U_POST_ACTION' => "mcp.$phpEx$SID&i=$id&mode=$mode", + 'S_CLEAR_ALLOWED' => ($auth->acl_get('a_clearlogs')) ? true : false, + 'S_SELECT_SORT_DIR' => $s_sort_dir, + 'S_SELECT_SORT_KEY' => $s_sort_key, + 'S_SELECT_SORT_DAYS' => $s_limit_days, + + 'PAGE_NUMBER' => on_page($user_count, $config['topic_per_page'], $start), + 'PAGINATION' => generate_pagination("mcp.$phpEx$SID&i=$id&mode=$mode&st=$st&sk=$sk&sd=$sd", $user_count, $config['topics_per_page'], $start), + 'TOTAL_USERS' => ($user_count == 1) ? $user->lang['LIST_USER'] : sprintf($user->lang['LIST_USERS'], $user_count), + ) + ); + +} + /** * Handles warning the user when the warning is for a specific post */ diff --git a/phpBB/language/en/mcp.php b/phpBB/language/en/mcp.php index 8abdb0b915..579e22af5d 100644 --- a/phpBB/language/en/mcp.php +++ b/phpBB/language/en/mcp.php @@ -272,6 +272,8 @@ $lang = array_merge($lang, array( 'VIEW_DETAILS' => 'View Details', + 'WARNED_USERS' => 'Warned Users', + 'YOU_SELECTED_TOPIC' => 'You selected topic number %d: %s', 'report_reasons' => array( diff --git a/phpBB/styles/subSilver/template/mcp_warn_front.html b/phpBB/styles/subSilver/template/mcp_warn_front.html index 358ffb02a4..e250f3109d 100755 --- a/phpBB/styles/subSilver/template/mcp_warn_front.html +++ b/phpBB/styles/subSilver/template/mcp_warn_front.html @@ -32,7 +32,7 @@ {highest.USERNAME} {highest.WARNINGS} - + {highest.WARNING_TIME} {L_VIEW_NOTES} diff --git a/phpBB/styles/subSilver/template/mcp_warn_list.html b/phpBB/styles/subSilver/template/mcp_warn_list.html new file mode 100755 index 0000000000..5b23f9705e --- /dev/null +++ b/phpBB/styles/subSilver/template/mcp_warn_list.html @@ -0,0 +1,44 @@ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
{L_WARNED_USERS}
 {L_USERNAME}  {L_WARNINGS}  {L_LATEST_TIME}  
{user.USERNAME}{user.WARNINGS}{user.WARNING_TIME}{L_VIEW_NOTES}
{L_WARNINGS_ZERO_TOTAL}
{L_DISPLAY_POSTS}: {S_SELECT_SORT_DAYS} {L_SORT_BY} {S_SELECT_SORT_KEY} {S_SELECT_SORT_DIR} 
+ + + + + + +
{PAGE_NUMBER} [ {TOTAL_USERS} ]{L_GOTO_PAGE} {L_PREVIOUS}  {PAGINATION}  {L_NEXT}
+ +
+ +

+ + \ No newline at end of file