diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2009-07-14 20:35:53 +0000 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2009-07-14 20:35:53 +0000 |
commit | e3866c939d78b925844cd61d6ad567988f24e42d (patch) | |
tree | 5dc7ead67990b8770adac05a2d9464064e33e617 /phpBB/includes | |
parent | 0b2979c6bab97297f839937606635fd4cc6b1eae (diff) | |
download | forums-e3866c939d78b925844cd61d6ad567988f24e42d.tar forums-e3866c939d78b925844cd61d6ad567988f24e42d.tar.gz forums-e3866c939d78b925844cd61d6ad567988f24e42d.tar.bz2 forums-e3866c939d78b925844cd61d6ad567988f24e42d.tar.xz forums-e3866c939d78b925844cd61d6ad567988f24e42d.zip |
Feature Bug #43375 - Ability to delete warnings and keep warnings permanently
Authorised by: AcydBurn
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9758 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes')
-rw-r--r-- | phpBB/includes/acp/acp_users.php | 142 | ||||
-rw-r--r-- | phpBB/includes/acp/info/acp_users.php | 1 | ||||
-rw-r--r-- | phpBB/includes/functions.php | 2 |
3 files changed, 144 insertions, 1 deletions
diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 1cd7a405d5..d8fef3f547 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1065,6 +1065,148 @@ class acp_users break; + case 'warnings': + $user->add_lang('mcp'); + + // Set up general vars + $start = request_var('start', 0); + $deletemark = (isset($_POST['delmarked'])) ? true : false; + $deleteall = (isset($_POST['delall'])) ? true : false; + $confirm = (isset($_POST['confirm'])) ? true : false; + $marked = request_var('mark', array(0)); + $message = utf8_normalize_nfc(request_var('message', '', true)); + + // Sort keys + $sort_days = request_var('st', 0); + $sort_key = request_var('sk', 't'); + $sort_dir = request_var('sd', 'd'); + + // Delete entries if requested and able + if ($deletemark || $deleteall || $confirm) + { + if (confirm_box(true)) + { + $where_sql = ''; + $deletemark = request_var('delmarked', 0); + $deleteall = request_var('delall', 0); + if ($deletemark && $marked) + { + $sql_in = array(); + foreach ($marked as $mark) + { + $sql_in[] = $mark; + } + $where_sql = ' AND ' . $db->sql_in_set('warning_id', $sql_in); + unset($sql_in); + } + + if ($where_sql || $deleteall) + { + $sql = 'DELETE FROM ' . WARNINGS_TABLE . " + WHERE user_id = $user_id + $where_sql"; + $db->sql_query($sql); + + if ($deleteall) + { + $deleted_warnings = '0'; + } + else + { + $deleted_warnings = ' user_warnings - ' . $db->sql_affectedrows(); + } + + $sql = 'UPDATE ' . USERS_TABLE . " + SET user_warnings = $deleted_warnings + WHERE user_id = $user_id"; + $db->sql_query($sql); + + add_log('admin', 'LOG_WARNING_DELETED', $user_row['username']); + } + } + else + { + $s_hidden_fields = array( + 'i' => $id, + 'mode' => $mode, + 'u' => $user_id, + 'mark' => $marked, + ); + if (isset($_POST['delmarked'])) + { + $s_hidden_fields['delmarked'] = 1; + } + if (isset($_POST['delall'])) + { + $s_hidden_fields['delall'] = 1; + } + if (isset($_POST['delall']) || (isset($_POST['delmarked']) && sizeof($marked))) + { + confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($s_hidden_fields)); + } + } + } + + $sql = 'SELECT w.warning_id, w.warning_time, w.post_id, l.log_operation, l.log_data, l.user_id AS mod_user_id, m.username AS mod_username, m.user_colour AS mod_user_colour + FROM ' . WARNINGS_TABLE . ' w + LEFT JOIN ' . LOG_TABLE . ' l + ON (w.log_id = l.log_id) + LEFT JOIN ' . USERS_TABLE . ' m + ON (l.user_id = m.user_id) + WHERE w.user_id = ' . $user_id . ' + ORDER BY w.warning_time DESC'; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + if (!$row['log_operation']) + { + // We do not have a log-entry anymore, so there is no data available + $row['action'] = $user->lang['USER_WARNING_LOG_DELETED']; + } + else + { + $row['action'] = (isset($user->lang[$row['log_operation']])) ? $user->lang[$row['log_operation']] : '{' . ucfirst(str_replace('_', ' ', $row['log_operation'])) . '}'; + if (!empty($row['log_data'])) + { + $log_data_ary = @unserialize($row['log_data']); + $log_data_ary = ($log_data_ary === false) ? array() : $log_data_ary; + + if (isset($user->lang[$row['log_operation']])) + { + // Check if there are more occurrences of % than arguments, if there are we fill out the arguments array + // It doesn't matter if we add more arguments than placeholders + if ((substr_count($row['action'], '%') - sizeof($log_data_ary)) > 0) + { + $log_data_ary = array_merge($log_data_ary, array_fill(0, substr_count($row['action'], '%') - sizeof($log_data_ary), '')); + } + $row['action'] = vsprintf($row['action'], $log_data_ary); + $row['action'] = bbcode_nl2br(censor_text($row['action'])); + } + else if (!empty($log_data_ary)) + { + $row['action'] .= '<br />' . implode('', $log_data_ary); + } + } + } + + + $template->assign_block_vars('warn', array( + 'ID' => $row['warning_id'], + 'USERNAME' => ($row['log_operation']) ? get_username_string('full', $row['mod_user_id'], $row['mod_username'], $row['mod_user_colour']) : '-', + 'ACTION' => make_clickable($row['action']), + 'DATE' => $user->format_date($row['warning_time']), + )); + } + $db->sql_freeresult($result); + + $template->assign_vars(array( + 'S_WARNINGS' => true, + 'S_CLEARLOGS' => $auth->acl_get('a_clearlogs'), + )); + + break; + case 'profile': include($phpbb_root_path . 'includes/functions_user.' . $phpEx); diff --git a/phpBB/includes/acp/info/acp_users.php b/phpBB/includes/acp/info/acp_users.php index 0cd5f7ae97..10081ac870 100644 --- a/phpBB/includes/acp/info/acp_users.php +++ b/phpBB/includes/acp/info/acp_users.php @@ -22,6 +22,7 @@ class acp_users_info 'modes' => array( 'overview' => array('title' => 'ACP_MANAGE_USERS', 'auth' => 'acl_a_user', 'cat' => array('ACP_CAT_USERS')), 'feedback' => array('title' => 'ACP_USER_FEEDBACK', 'auth' => 'acl_a_user', 'display' => false, 'cat' => array('ACP_CAT_USERS')), + 'warnings' => array('title' => 'ACP_USER_WARNINGS', 'auth' => 'acl_a_user', 'display' => false, 'cat' => array('ACP_CAT_USERS')), 'profile' => array('title' => 'ACP_USER_PROFILE', 'auth' => 'acl_a_user', 'display' => false, 'cat' => array('ACP_CAT_USERS')), 'prefs' => array('title' => 'ACP_USER_PREFS', 'auth' => 'acl_a_user', 'display' => false, 'cat' => array('ACP_CAT_USERS')), 'avatar' => array('title' => 'ACP_USER_AVATAR', 'auth' => 'acl_a_user', 'display' => false, 'cat' => array('ACP_CAT_USERS')), diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 74f7e31bee..eaaa8aaf6a 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4025,7 +4025,7 @@ function page_footer($run_cron = true) // Tidy the cache $cron_type = 'tidy_cache'; } - else if (time() - $config['warnings_gc'] > $config['warnings_last_gc']) + else if ($config['warnings_last_gc'] && (time() - $config['warnings_gc'] > $config['warnings_last_gc'])) { $cron_type = 'tidy_warnings'; } |