|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
*
|
|
|
ef5584 |
* @package mcp
|
|
|
ef5584 |
* @version $Id: mcp_warn.php 9002 2008-10-11 17:01:43Z toonarmy $
|
|
|
ef5584 |
* @copyright (c) 2005 phpBB Group
|
|
|
ef5584 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
|
ef5584 |
*
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* @ignore
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
if (!defined('IN_PHPBB'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
exit;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* mcp_warn
|
|
|
ef5584 |
* Handling warning the users
|
|
|
ef5584 |
* @package mcp
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
class mcp_warn
|
|
|
ef5584 |
{
|
|
|
ef5584 |
var $p_master;
|
|
|
ef5584 |
var $u_action;
|
|
|
ef5584 |
|
|
|
ef5584 |
function mcp_warn(&$p_master)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$this->p_master = &$p_master;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
function main($id, $mode)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
global $auth, $db, $user, $template;
|
|
|
ef5584 |
global $config, $phpbb_root_path, $phpEx;
|
|
|
ef5584 |
|
|
|
ef5584 |
$action = request_var('action', array('' => ''));
|
|
|
ef5584 |
|
|
|
ef5584 |
if (is_array($action))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
list($action, ) = each($action);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$this->page_title = 'MCP_WARN';
|
|
|
ef5584 |
|
|
|
ef5584 |
add_form_key('mcp_warn');
|
|
|
ef5584 |
|
|
|
ef5584 |
switch ($mode)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
case 'front':
|
|
|
ef5584 |
$this->mcp_warn_front_view();
|
|
|
ef5584 |
$this->tpl_name = 'mcp_warn_front';
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'list':
|
|
|
ef5584 |
$this->mcp_warn_list_view($action);
|
|
|
ef5584 |
$this->tpl_name = 'mcp_warn_list';
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'warn_post':
|
|
|
ef5584 |
$this->mcp_warn_post_view($action);
|
|
|
ef5584 |
$this->tpl_name = 'mcp_warn_post';
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
|
|
|
ef5584 |
case 'warn_user':
|
|
|
ef5584 |
$this->mcp_warn_user_view($action);
|
|
|
ef5584 |
$this->tpl_name = 'mcp_warn_user';
|
|
|
ef5584 |
break;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* Generates the summary on the main page of the warning module
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
function mcp_warn_front_view()
|
|
|
ef5584 |
{
|
|
|
ef5584 |
global $phpEx, $phpbb_root_path, $config;
|
|
|
ef5584 |
global $template, $db, $user, $auth;
|
|
|
ef5584 |
|
|
|
ef5584 |
$template->assign_vars(array(
|
|
|
ef5584 |
'U_FIND_USERNAME' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=mcp&field=username&select_single=true'),
|
|
|
ef5584 |
'U_POST_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user'),
|
|
|
ef5584 |
));
|
|
|
ef5584 |
|
|
|
ef5584 |
// Obtain a list of the 5 naughtiest users....
|
|
|
ef5584 |
// These are the 5 users with the highest warning count
|
|
|
ef5584 |
$highest = array();
|
|
|
ef5584 |
$count = 0;
|
|
|
ef5584 |
|
|
|
ef5584 |
view_warned_users($highest, $count, 5);
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($highest as $row)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$template->assign_block_vars('highest', array(
|
|
|
ef5584 |
'U_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $row['user_id']),
|
|
|
ef5584 |
|
|
|
ef5584 |
'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
|
|
|
ef5584 |
'USERNAME' => $row['username'],
|
|
|
ef5584 |
'USERNAME_COLOUR' => ($row['user_colour']) ? '#' . $row['user_colour'] : '',
|
|
|
ef5584 |
'U_USER' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $row['user_id']),
|
|
|
ef5584 |
|
|
|
ef5584 |
'WARNING_TIME' => $user->format_date($row['user_last_warning']),
|
|
|
ef5584 |
'WARNINGS' => $row['user_warnings'],
|
|
|
ef5584 |
));
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// And now the 5 most recent users to get in trouble
|
|
|
ef5584 |
$sql = 'SELECT u.user_id, u.username, u.username_clean, u.user_colour, u.user_warnings, w.warning_time
|
|
|
ef5584 |
FROM ' . USERS_TABLE . ' u, ' . WARNINGS_TABLE . ' w
|
|
|
ef5584 |
WHERE u.user_id = w.user_id
|
|
|
ef5584 |
ORDER BY w.warning_time DESC';
|
|
|
ef5584 |
$result = $db->sql_query_limit($sql, 5);
|
|
|
ef5584 |
|
|
|
ef5584 |
while ($row = $db->sql_fetchrow($result))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$template->assign_block_vars('latest', array(
|
|
|
ef5584 |
'U_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $row['user_id']),
|
|
|
ef5584 |
|
|
|
ef5584 |
'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
|
|
|
ef5584 |
'USERNAME' => $row['username'],
|
|
|
ef5584 |
'USERNAME_COLOUR' => ($row['user_colour']) ? '#' . $row['user_colour'] : '',
|
|
|
ef5584 |
'U_USER' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $row['user_id']),
|
|
|
ef5584 |
|
|
|
ef5584 |
'WARNING_TIME' => $user->format_date($row['warning_time']),
|
|
|
ef5584 |
'WARNINGS' => $row['user_warnings'],
|
|
|
ef5584 |
));
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* Lists all users with warnings
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
function mcp_warn_list_view($action)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
global $phpEx, $phpbb_root_path, $config;
|
|
|
ef5584 |
global $template, $db, $user, $auth;
|
|
|
ef5584 |
|
|
|
ef5584 |
$user->add_lang('memberlist');
|
|
|
ef5584 |
|
|
|
ef5584 |
$start = request_var('start', 0);
|
|
|
ef5584 |
$st = request_var('st', 0);
|
|
|
ef5584 |
$sk = request_var('sk', 'b');
|
|
|
ef5584 |
$sd = request_var('sd', 'd');
|
|
|
ef5584 |
|
|
|
ef5584 |
$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'], 365 => $user->lang['1_YEAR']);
|
|
|
ef5584 |
$sort_by_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_DATE'], 'c' => $user->lang['SORT_WARNINGS']);
|
|
|
ef5584 |
$sort_by_sql = array('a' => 'username_clean', 'b' => 'user_last_warning', 'c' => 'user_warnings');
|
|
|
ef5584 |
|
|
|
ef5584 |
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
|
|
|
ef5584 |
gen_sort_selects($limit_days, $sort_by_text, $st, $sk, $sd, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
|
|
|
ef5584 |
|
|
|
ef5584 |
// Define where and sort sql for use in displaying logs
|
|
|
ef5584 |
$sql_where = ($st) ? (time() - ($st * 86400)) : 0;
|
|
|
ef5584 |
$sql_sort = $sort_by_sql[$sk] . ' ' . (($sd == 'd') ? 'DESC' : 'ASC');
|
|
|
ef5584 |
|
|
|
ef5584 |
$users = array();
|
|
|
ef5584 |
$user_count = 0;
|
|
|
ef5584 |
|
|
|
ef5584 |
view_warned_users($users, $user_count, $config['topics_per_page'], $start, $sql_where, $sql_sort);
|
|
|
ef5584 |
|
|
|
ef5584 |
foreach ($users as $row)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$template->assign_block_vars('user', array(
|
|
|
ef5584 |
'U_NOTES' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $row['user_id']),
|
|
|
ef5584 |
|
|
|
ef5584 |
'USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
|
|
|
ef5584 |
'USERNAME' => $row['username'],
|
|
|
ef5584 |
'USERNAME_COLOUR' => ($row['user_colour']) ? '#' . $row['user_colour'] : '',
|
|
|
ef5584 |
'U_USER' => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $row['user_id']),
|
|
|
ef5584 |
|
|
|
ef5584 |
'WARNING_TIME' => $user->format_date($row['user_last_warning']),
|
|
|
ef5584 |
'WARNINGS' => $row['user_warnings'],
|
|
|
ef5584 |
));
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$template->assign_vars(array(
|
|
|
ef5584 |
'U_POST_ACTION' => $this->u_action,
|
|
|
ef5584 |
'S_CLEAR_ALLOWED' => ($auth->acl_get('a_clearlogs')) ? true : false,
|
|
|
ef5584 |
'S_SELECT_SORT_DIR' => $s_sort_dir,
|
|
|
ef5584 |
'S_SELECT_SORT_KEY' => $s_sort_key,
|
|
|
ef5584 |
'S_SELECT_SORT_DAYS' => $s_limit_days,
|
|
|
ef5584 |
|
|
|
ef5584 |
'PAGE_NUMBER' => on_page($user_count, $config['topics_per_page'], $start),
|
|
|
ef5584 |
'PAGINATION' => generate_pagination(append_sid("{$phpbb_root_path}mcp.$phpEx", "i=warn&mode=list&st=$st&sk=$sk&sd=$sd"), $user_count, $config['topics_per_page'], $start),
|
|
|
ef5584 |
'TOTAL_USERS' => ($user_count == 1) ? $user->lang['LIST_USER'] : sprintf($user->lang['LIST_USERS'], $user_count),
|
|
|
ef5584 |
));
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* Handles warning the user when the warning is for a specific post
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
function mcp_warn_post_view($action)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
global $phpEx, $phpbb_root_path, $config;
|
|
|
ef5584 |
global $template, $db, $user, $auth;
|
|
|
ef5584 |
|
|
|
ef5584 |
$post_id = request_var('p', 0);
|
|
|
ef5584 |
$forum_id = request_var('f', 0);
|
|
|
ef5584 |
$notify = (isset($_REQUEST['notify_user'])) ? true : false;
|
|
|
ef5584 |
$warning = utf8_normalize_nfc(request_var('warning', '', true));
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql = 'SELECT u.*, p.*
|
|
|
ef5584 |
FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u
|
|
|
ef5584 |
WHERE post_id = $post_id
|
|
|
ef5584 |
AND u.user_id = p.poster_id";
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
$user_row = $db->sql_fetchrow($result);
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!$user_row)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error('NO_POST');
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// There is no point issuing a warning to ignored users (ie anonymous and bots)
|
|
|
ef5584 |
if ($user_row['user_type'] == USER_IGNORE)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error('CANNOT_WARN_ANONYMOUS');
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Prevent someone from warning themselves
|
|
|
ef5584 |
if ($user_row['user_id'] == $user->data['user_id'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error('CANNOT_WARN_SELF');
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Check if there is already a warning for this post to prevent multiple
|
|
|
ef5584 |
// warnings for the same offence
|
|
|
ef5584 |
$sql = 'SELECT post_id
|
|
|
ef5584 |
FROM ' . WARNINGS_TABLE . "
|
|
|
ef5584 |
WHERE post_id = $post_id";
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
$row = $db->sql_fetchrow($result);
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($row)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error('ALREADY_WARNED');
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$user_id = $user_row['user_id'];
|
|
|
ef5584 |
|
|
|
ef5584 |
if (strpos($this->u_action, "&f=$forum_id&p=$post_id") === false)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$this->p_master->adjust_url("&f=$forum_id&p=$post_id");
|
|
|
ef5584 |
$this->u_action .= "&f=$forum_id&p=$post_id";
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Check if can send a notification
|
|
|
ef5584 |
if ($config['allow_privmsg'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$auth2 = new auth();
|
|
|
ef5584 |
$auth2->acl($user_row);
|
|
|
ef5584 |
$s_can_notify = ($auth2->acl_get('u_readpm')) ? true : false;
|
|
|
ef5584 |
unset($auth2);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$s_can_notify = false;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Prevent against clever people
|
|
|
ef5584 |
if ($notify && !$s_can_notify)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$notify = false;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($warning && $action == 'add_warning')
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (check_form_key('mcp_warn'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
add_warning($user_row, $warning, $notify, $post_id);
|
|
|
ef5584 |
$msg = $user->lang['USER_WARNING_ADDED'];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$msg = $user->lang['FORM_INVALID'];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$redirect = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=notes&mode=user_notes&u=$user_id");
|
|
|
ef5584 |
meta_refresh(2, $redirect);
|
|
|
ef5584 |
trigger_error($msg . '
' . sprintf($user->lang['RETURN_PAGE'], '', ''));
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// OK, they didn't submit a warning so lets build the page for them to do so
|
|
|
ef5584 |
|
|
|
ef5584 |
// We want to make the message available here as a reminder
|
|
|
ef5584 |
// Parse the message and subject
|
|
|
ef5584 |
$message = censor_text($user_row['post_text']);
|
|
|
ef5584 |
|
|
|
ef5584 |
// Second parse bbcode here
|
|
|
ef5584 |
if ($user_row['bbcode_bitfield'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
|
|
|
ef5584 |
|
|
|
ef5584 |
$bbcode = new bbcode($user_row['bbcode_bitfield']);
|
|
|
ef5584 |
$bbcode->bbcode_second_pass($message, $user_row['bbcode_uid'], $user_row['bbcode_bitfield']);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$message = bbcode_nl2br($message);
|
|
|
ef5584 |
$message = smiley_text($message);
|
|
|
ef5584 |
|
|
|
ef5584 |
// Generate the appropriate user information for the user we are looking at
|
|
|
ef5584 |
if (!function_exists('get_user_avatar'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$rank_title = $rank_img = '';
|
|
|
ef5584 |
$avatar_img = get_user_avatar($user_row['user_avatar'], $user_row['user_avatar_type'], $user_row['user_avatar_width'], $user_row['user_avatar_height']);
|
|
|
ef5584 |
|
|
|
ef5584 |
$template->assign_vars(array(
|
|
|
ef5584 |
'U_POST_ACTION' => $this->u_action,
|
|
|
ef5584 |
|
|
|
ef5584 |
'POST' => $message,
|
|
|
ef5584 |
'USERNAME' => $user_row['username'],
|
|
|
ef5584 |
'USER_COLOR' => (!empty($user_row['user_colour'])) ? $user_row['user_colour'] : '',
|
|
|
ef5584 |
'RANK_TITLE' => $rank_title,
|
|
|
ef5584 |
'JOINED' => $user->format_date($user_row['user_regdate']),
|
|
|
ef5584 |
'POSTS' => ($user_row['user_posts']) ? $user_row['user_posts'] : 0,
|
|
|
ef5584 |
'WARNINGS' => ($user_row['user_warnings']) ? $user_row['user_warnings'] : 0,
|
|
|
ef5584 |
|
|
|
ef5584 |
'AVATAR_IMG' => $avatar_img,
|
|
|
ef5584 |
'RANK_IMG' => $rank_img,
|
|
|
ef5584 |
|
|
|
ef5584 |
'L_WARNING_POST_DEFAULT' => sprintf($user->lang['WARNING_POST_DEFAULT'], generate_board_url() . "/viewtopic.$phpEx?f=$forum_id&p=$post_id#p$post_id"),
|
|
|
ef5584 |
|
|
|
ef5584 |
'S_CAN_NOTIFY' => $s_can_notify,
|
|
|
ef5584 |
));
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* Handles warning the user
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
function mcp_warn_user_view($action)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
global $phpEx, $phpbb_root_path, $config, $module;
|
|
|
ef5584 |
global $template, $db, $user, $auth;
|
|
|
ef5584 |
|
|
|
ef5584 |
$user_id = request_var('u', 0);
|
|
|
ef5584 |
$username = request_var('username', '', true);
|
|
|
ef5584 |
$notify = (isset($_REQUEST['notify_user'])) ? true : false;
|
|
|
ef5584 |
$warning = utf8_normalize_nfc(request_var('warning', '', true));
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql_where = ($user_id) ? "user_id = $user_id" : "username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql = 'SELECT *
|
|
|
ef5584 |
FROM ' . USERS_TABLE . '
|
|
|
ef5584 |
WHERE ' . $sql_where;
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
$user_row = $db->sql_fetchrow($result);
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
if (!$user_row)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error('NO_USER');
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Prevent someone from warning themselves
|
|
|
ef5584 |
if ($user_row['user_id'] == $user->data['user_id'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
trigger_error('CANNOT_WARN_SELF');
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$user_id = $user_row['user_id'];
|
|
|
ef5584 |
|
|
|
ef5584 |
if (strpos($this->u_action, "&u=$user_id") === false)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$this->p_master->adjust_url('&u=' . $user_id);
|
|
|
ef5584 |
$this->u_action .= "&u=$user_id";
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Check if can send a notification
|
|
|
ef5584 |
if ($config['allow_privmsg'])
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$auth2 = new auth();
|
|
|
ef5584 |
$auth2->acl($user_row);
|
|
|
ef5584 |
$s_can_notify = ($auth2->acl_get('u_readpm')) ? true : false;
|
|
|
ef5584 |
unset($auth2);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$s_can_notify = false;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Prevent against clever people
|
|
|
ef5584 |
if ($notify && !$s_can_notify)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$notify = false;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($warning && $action == 'add_warning')
|
|
|
ef5584 |
{
|
|
|
ef5584 |
if (check_form_key('mcp_warn'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
add_warning($user_row, $warning, $notify);
|
|
|
ef5584 |
$msg = $user->lang['USER_WARNING_ADDED'];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
else
|
|
|
ef5584 |
{
|
|
|
ef5584 |
$msg = $user->lang['FORM_INVALID'];
|
|
|
ef5584 |
}
|
|
|
ef5584 |
$redirect = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=notes&mode=user_notes&u=$user_id");
|
|
|
ef5584 |
meta_refresh(2, $redirect);
|
|
|
ef5584 |
trigger_error($msg . '
' . sprintf($user->lang['RETURN_PAGE'], '', ''));
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
// Generate the appropriate user information for the user we are looking at
|
|
|
ef5584 |
if (!function_exists('get_user_avatar'))
|
|
|
ef5584 |
{
|
|
|
ef5584 |
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
$rank_title = $rank_img = '';
|
|
|
ef5584 |
$avatar_img = get_user_avatar($user_row['user_avatar'], $user_row['user_avatar_type'], $user_row['user_avatar_width'], $user_row['user_avatar_height']);
|
|
|
ef5584 |
|
|
|
ef5584 |
// OK, they didn't submit a warning so lets build the page for them to do so
|
|
|
ef5584 |
$template->assign_vars(array(
|
|
|
ef5584 |
'U_POST_ACTION' => $this->u_action,
|
|
|
ef5584 |
|
|
|
ef5584 |
'USERNAME' => $user_row['username'],
|
|
|
ef5584 |
'USER_COLOR' => (!empty($user_row['user_colour'])) ? $user_row['user_colour'] : '',
|
|
|
ef5584 |
'RANK_TITLE' => $rank_title,
|
|
|
ef5584 |
'JOINED' => $user->format_date($user_row['user_regdate']),
|
|
|
ef5584 |
'POSTS' => ($user_row['user_posts']) ? $user_row['user_posts'] : 0,
|
|
|
ef5584 |
'WARNINGS' => ($user_row['user_warnings']) ? $user_row['user_warnings'] : 0,
|
|
|
ef5584 |
|
|
|
ef5584 |
'AVATAR_IMG' => $avatar_img,
|
|
|
ef5584 |
'RANK_IMG' => $rank_img,
|
|
|
ef5584 |
|
|
|
ef5584 |
'S_CAN_NOTIFY' => $s_can_notify,
|
|
|
ef5584 |
));
|
|
|
ef5584 |
|
|
|
ef5584 |
return $user_id;
|
|
|
ef5584 |
}
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
/**
|
|
|
ef5584 |
* Insert the warning into the database
|
|
|
ef5584 |
*/
|
|
|
ef5584 |
function add_warning($user_row, $warning, $send_pm = true, $post_id = 0)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
global $phpEx, $phpbb_root_path, $config;
|
|
|
ef5584 |
global $template, $db, $user, $auth;
|
|
|
ef5584 |
|
|
|
ef5584 |
if ($send_pm)
|
|
|
ef5584 |
{
|
|
|
ef5584 |
include_once($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx);
|
|
|
ef5584 |
include_once($phpbb_root_path . 'includes/message_parser.' . $phpEx);
|
|
|
ef5584 |
|
|
|
ef5584 |
$user_row['user_lang'] = (file_exists($phpbb_root_path . 'language/' . $user_row['user_lang'] . "/mcp.$phpEx")) ? $user_row['user_lang'] : $config['default_lang'];
|
|
|
ef5584 |
include($phpbb_root_path . 'language/' . basename($user_row['user_lang']) . "/mcp.$phpEx");
|
|
|
ef5584 |
|
|
|
ef5584 |
$message_parser = new parse_message();
|
|
|
ef5584 |
|
|
|
ef5584 |
$message_parser->message = sprintf($lang['WARNING_PM_BODY'], $warning);
|
|
|
ef5584 |
$message_parser->parse(true, true, true, false, false, true, true);
|
|
|
ef5584 |
|
|
|
ef5584 |
$pm_data = array(
|
|
|
ef5584 |
'from_user_id' => $user->data['user_id'],
|
|
|
ef5584 |
'from_user_ip' => $user->ip,
|
|
|
ef5584 |
'from_username' => $user->data['username'],
|
|
|
ef5584 |
'enable_sig' => false,
|
|
|
ef5584 |
'enable_bbcode' => true,
|
|
|
ef5584 |
'enable_smilies' => true,
|
|
|
ef5584 |
'enable_urls' => false,
|
|
|
ef5584 |
'icon_id' => 0,
|
|
|
ef5584 |
'bbcode_bitfield' => $message_parser->bbcode_bitfield,
|
|
|
ef5584 |
'bbcode_uid' => $message_parser->bbcode_uid,
|
|
|
ef5584 |
'message' => $message_parser->message,
|
|
|
ef5584 |
'address_list' => array('u' => array($user_row['user_id'] => 'to')),
|
|
|
ef5584 |
);
|
|
|
ef5584 |
|
|
|
ef5584 |
submit_pm('post', $lang['WARNING_PM_SUBJECT'], $pm_data, false);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
add_log('admin', 'LOG_USER_WARNING', $user_row['username']);
|
|
|
ef5584 |
$log_id = add_log('user', $user_row['user_id'], 'LOG_USER_WARNING_BODY', $warning);
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql_ary = array(
|
|
|
ef5584 |
'user_id' => $user_row['user_id'],
|
|
|
ef5584 |
'post_id' => $post_id,
|
|
|
ef5584 |
'log_id' => $log_id,
|
|
|
ef5584 |
'warning_time' => time(),
|
|
|
ef5584 |
);
|
|
|
ef5584 |
|
|
|
ef5584 |
$db->sql_query('INSERT INTO ' . WARNINGS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
|
|
|
ef5584 |
|
|
|
ef5584 |
$sql = 'UPDATE ' . USERS_TABLE . '
|
|
|
ef5584 |
SET user_warnings = user_warnings + 1,
|
|
|
ef5584 |
user_last_warning = ' . time() . '
|
|
|
ef5584 |
WHERE user_id = ' . $user_row['user_id'];
|
|
|
ef5584 |
$db->sql_query($sql);
|
|
|
ef5584 |
|
|
|
ef5584 |
// We add this to the mod log too for moderators to see that a specific user got warned.
|
|
|
ef5584 |
$sql = 'SELECT forum_id, topic_id
|
|
|
ef5584 |
FROM ' . POSTS_TABLE . '
|
|
|
ef5584 |
WHERE post_id = ' . $post_id;
|
|
|
ef5584 |
$result = $db->sql_query($sql);
|
|
|
ef5584 |
$row = $db->sql_fetchrow($result);
|
|
|
ef5584 |
$db->sql_freeresult($result);
|
|
|
ef5584 |
|
|
|
ef5584 |
add_log('mod', $row['forum_id'], $row['topic_id'], 'LOG_USER_WARNING', $user_row['username']);
|
|
|
ef5584 |
}
|
|
|
ef5584 |
|
|
|
ef5584 |
?>
|