Blame Extras/phpBB/3.0.4/includes/mcp/mcp_warn.php

4c79b5
4c79b5
/**
4c79b5
*
4c79b5
* @package mcp
4c79b5
* @version $Id: mcp_warn.php 9002 2008-10-11 17:01:43Z toonarmy $
4c79b5
* @copyright (c) 2005 phpBB Group
4c79b5
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
4c79b5
*
4c79b5
*/
4c79b5
4c79b5
/**
4c79b5
* @ignore
4c79b5
*/
4c79b5
if (!defined('IN_PHPBB'))
4c79b5
{
4c79b5
	exit;
4c79b5
}
4c79b5
4c79b5
/**
4c79b5
* mcp_warn
4c79b5
* Handling warning the users
4c79b5
* @package mcp
4c79b5
*/
4c79b5
class mcp_warn
4c79b5
{
4c79b5
	var $p_master;
4c79b5
	var $u_action;
4c79b5
4c79b5
	function mcp_warn(&$p_master)
4c79b5
	{
4c79b5
		$this->p_master = &$p_master;
4c79b5
	}
4c79b5
4c79b5
	function main($id, $mode)
4c79b5
	{
4c79b5
		global $auth, $db, $user, $template;
4c79b5
		global $config, $phpbb_root_path, $phpEx;
4c79b5
4c79b5
		$action = request_var('action', array('' => ''));
4c79b5
4c79b5
		if (is_array($action))
4c79b5
		{
4c79b5
			list($action, ) = each($action);
4c79b5
		}
4c79b5
4c79b5
		$this->page_title = 'MCP_WARN';
4c79b5
4c79b5
		add_form_key('mcp_warn');
4c79b5
4c79b5
		switch ($mode)
4c79b5
		{
4c79b5
			case 'front':
4c79b5
				$this->mcp_warn_front_view();
4c79b5
				$this->tpl_name = 'mcp_warn_front';
4c79b5
			break;
4c79b5
4c79b5
			case 'list':
4c79b5
				$this->mcp_warn_list_view($action);
4c79b5
				$this->tpl_name = 'mcp_warn_list';
4c79b5
			break;
4c79b5
4c79b5
			case 'warn_post':
4c79b5
				$this->mcp_warn_post_view($action);
4c79b5
				$this->tpl_name = 'mcp_warn_post';
4c79b5
			break;
4c79b5
4c79b5
			case 'warn_user':
4c79b5
				$this->mcp_warn_user_view($action);
4c79b5
				$this->tpl_name = 'mcp_warn_user';
4c79b5
			break;
4c79b5
		}
4c79b5
	}
4c79b5
4c79b5
	/**
4c79b5
	* Generates the summary on the main page of the warning module
4c79b5
	*/
4c79b5
	function mcp_warn_front_view()
4c79b5
	{
4c79b5
		global $phpEx, $phpbb_root_path, $config;
4c79b5
		global $template, $db, $user, $auth;
4c79b5
4c79b5
		$template->assign_vars(array(
4c79b5
			'U_FIND_USERNAME'	=> append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&form=mcp&field=username&select_single=true'),
4c79b5
			'U_POST_ACTION'		=> append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=warn&mode=warn_user'),
4c79b5
		));
4c79b5
4c79b5
		// Obtain a list of the 5 naughtiest users....
4c79b5
		// These are the 5 users with the highest warning count
4c79b5
		$highest = array();
4c79b5
		$count = 0;
4c79b5
4c79b5
		view_warned_users($highest, $count, 5);
4c79b5
4c79b5
		foreach ($highest as $row)
4c79b5
		{
4c79b5
			$template->assign_block_vars('highest', array(
4c79b5
				'U_NOTES'		=> append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $row['user_id']),
4c79b5
4c79b5
				'USERNAME_FULL'		=> get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
4c79b5
				'USERNAME'			=> $row['username'],
4c79b5
				'USERNAME_COLOUR'	=> ($row['user_colour']) ? '#' . $row['user_colour'] : '',
4c79b5
				'U_USER'			=> append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $row['user_id']),
4c79b5
4c79b5
				'WARNING_TIME'	=> $user->format_date($row['user_last_warning']),
4c79b5
				'WARNINGS'		=> $row['user_warnings'],
4c79b5
			));
4c79b5
		}
4c79b5
4c79b5
		// And now the 5 most recent users to get in trouble
4c79b5
		$sql = 'SELECT u.user_id, u.username, u.username_clean, u.user_colour, u.user_warnings, w.warning_time
4c79b5
			FROM ' . USERS_TABLE . ' u, ' . WARNINGS_TABLE . ' w
4c79b5
			WHERE u.user_id = w.user_id
4c79b5
			ORDER BY w.warning_time DESC';
4c79b5
		$result = $db->sql_query_limit($sql, 5);
4c79b5
4c79b5
		while ($row = $db->sql_fetchrow($result))
4c79b5
		{
4c79b5
			$template->assign_block_vars('latest', array(
4c79b5
				'U_NOTES'		=> append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $row['user_id']),
4c79b5
4c79b5
				'USERNAME_FULL'		=> get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
4c79b5
				'USERNAME'			=> $row['username'],
4c79b5
				'USERNAME_COLOUR'	=> ($row['user_colour']) ? '#' . $row['user_colour'] : '',
4c79b5
				'U_USER'			=> append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $row['user_id']),
4c79b5
4c79b5
				'WARNING_TIME'	=> $user->format_date($row['warning_time']),
4c79b5
				'WARNINGS'		=> $row['user_warnings'],
4c79b5
			));
4c79b5
		}
4c79b5
		$db->sql_freeresult($result);
4c79b5
	}
4c79b5
4c79b5
	/**
4c79b5
	* Lists all users with warnings
4c79b5
	*/
4c79b5
	function mcp_warn_list_view($action)
4c79b5
	{
4c79b5
		global $phpEx, $phpbb_root_path, $config;
4c79b5
		global $template, $db, $user, $auth;
4c79b5
4c79b5
		$user->add_lang('memberlist');
4c79b5
4c79b5
		$start	= request_var('start', 0);
4c79b5
		$st		= request_var('st', 0);
4c79b5
		$sk		= request_var('sk', 'b');
4c79b5
		$sd		= request_var('sd', 'd');
4c79b5
4c79b5
		$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']);
4c79b5
		$sort_by_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_DATE'], 'c' => $user->lang['SORT_WARNINGS']);
4c79b5
		$sort_by_sql = array('a' => 'username_clean', 'b' => 'user_last_warning', 'c' => 'user_warnings');
4c79b5
4c79b5
		$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
4c79b5
		gen_sort_selects($limit_days, $sort_by_text, $st, $sk, $sd, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
4c79b5
4c79b5
		// Define where and sort sql for use in displaying logs
4c79b5
		$sql_where = ($st) ? (time() - ($st * 86400)) : 0;
4c79b5
		$sql_sort = $sort_by_sql[$sk] . ' ' . (($sd == 'd') ? 'DESC' : 'ASC');
4c79b5
4c79b5
		$users = array();
4c79b5
		$user_count = 0;
4c79b5
4c79b5
		view_warned_users($users, $user_count, $config['topics_per_page'], $start, $sql_where, $sql_sort);
4c79b5
4c79b5
		foreach ($users as $row)
4c79b5
		{
4c79b5
			$template->assign_block_vars('user', array(
4c79b5
				'U_NOTES'		=> append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&mode=user_notes&u=' . $row['user_id']),
4c79b5
4c79b5
				'USERNAME_FULL'		=> get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
4c79b5
				'USERNAME'			=> $row['username'],
4c79b5
				'USERNAME_COLOUR'	=> ($row['user_colour']) ? '#' . $row['user_colour'] : '',
4c79b5
				'U_USER'			=> append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $row['user_id']),
4c79b5
4c79b5
				'WARNING_TIME'	=> $user->format_date($row['user_last_warning']),
4c79b5
				'WARNINGS'		=> $row['user_warnings'],
4c79b5
			));
4c79b5
		}
4c79b5
4c79b5
		$template->assign_vars(array(
4c79b5
			'U_POST_ACTION'			=> $this->u_action,
4c79b5
			'S_CLEAR_ALLOWED'		=> ($auth->acl_get('a_clearlogs')) ? true : false,
4c79b5
			'S_SELECT_SORT_DIR'		=> $s_sort_dir,
4c79b5
			'S_SELECT_SORT_KEY'		=> $s_sort_key,
4c79b5
			'S_SELECT_SORT_DAYS'	=> $s_limit_days,
4c79b5
4c79b5
			'PAGE_NUMBER'		=> on_page($user_count, $config['topics_per_page'], $start),
4c79b5
			'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),
4c79b5
			'TOTAL_USERS'		=> ($user_count == 1) ? $user->lang['LIST_USER'] : sprintf($user->lang['LIST_USERS'], $user_count),
4c79b5
		));
4c79b5
	}
4c79b5
4c79b5
	/**
4c79b5
	* Handles warning the user when the warning is for a specific post
4c79b5
	*/
4c79b5
	function mcp_warn_post_view($action)
4c79b5
	{
4c79b5
		global $phpEx, $phpbb_root_path, $config;
4c79b5
		global $template, $db, $user, $auth;
4c79b5
4c79b5
		$post_id = request_var('p', 0);
4c79b5
		$forum_id = request_var('f', 0);
4c79b5
		$notify = (isset($_REQUEST['notify_user'])) ? true : false;
4c79b5
		$warning = utf8_normalize_nfc(request_var('warning', '', true));
4c79b5
4c79b5
		$sql = 'SELECT u.*, p.*
4c79b5
			FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . " u
4c79b5
			WHERE post_id = $post_id
4c79b5
				AND u.user_id = p.poster_id";
4c79b5
		$result = $db->sql_query($sql);
4c79b5
		$user_row = $db->sql_fetchrow($result);
4c79b5
		$db->sql_freeresult($result);
4c79b5
4c79b5
		if (!$user_row)
4c79b5
		{
4c79b5
			trigger_error('NO_POST');
4c79b5
		}
4c79b5
4c79b5
		// There is no point issuing a warning to ignored users (ie anonymous and bots)
4c79b5
		if ($user_row['user_type'] == USER_IGNORE)
4c79b5
		{
4c79b5
			trigger_error('CANNOT_WARN_ANONYMOUS');
4c79b5
		}
4c79b5
4c79b5
		// Prevent someone from warning themselves
4c79b5
		if ($user_row['user_id'] == $user->data['user_id'])
4c79b5
		{
4c79b5
			trigger_error('CANNOT_WARN_SELF');
4c79b5
		}
4c79b5
4c79b5
		// Check if there is already a warning for this post to prevent multiple
4c79b5
		// warnings for the same offence
4c79b5
		$sql = 'SELECT post_id
4c79b5
			FROM ' . WARNINGS_TABLE . "
4c79b5
			WHERE post_id = $post_id";
4c79b5
		$result = $db->sql_query($sql);
4c79b5
		$row = $db->sql_fetchrow($result);
4c79b5
		$db->sql_freeresult($result);
4c79b5
4c79b5
		if ($row)
4c79b5
		{
4c79b5
			trigger_error('ALREADY_WARNED');
4c79b5
		}
4c79b5
4c79b5
		$user_id = $user_row['user_id'];
4c79b5
4c79b5
		if (strpos($this->u_action, "&f=$forum_id&p=$post_id") === false)
4c79b5
		{
4c79b5
			$this->p_master->adjust_url("&f=$forum_id&p=$post_id");
4c79b5
			$this->u_action .= "&f=$forum_id&p=$post_id";
4c79b5
		}
4c79b5
4c79b5
		// Check if can send a notification
4c79b5
		if ($config['allow_privmsg'])
4c79b5
		{
4c79b5
			$auth2 = new auth();
4c79b5
			$auth2->acl($user_row);
4c79b5
			$s_can_notify = ($auth2->acl_get('u_readpm')) ? true : false;
4c79b5
			unset($auth2);
4c79b5
		}
4c79b5
		else
4c79b5
		{
4c79b5
			$s_can_notify = false;
4c79b5
		}
4c79b5
4c79b5
		// Prevent against clever people
4c79b5
		if ($notify && !$s_can_notify)
4c79b5
		{
4c79b5
			$notify = false;
4c79b5
		}
4c79b5
4c79b5
		if ($warning && $action == 'add_warning')
4c79b5
		{
4c79b5
			if (check_form_key('mcp_warn'))
4c79b5
			{
4c79b5
				add_warning($user_row, $warning, $notify, $post_id);
4c79b5
				$msg = $user->lang['USER_WARNING_ADDED'];
4c79b5
			}
4c79b5
			else
4c79b5
			{
4c79b5
				$msg = $user->lang['FORM_INVALID'];
4c79b5
			}
4c79b5
			$redirect = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=notes&mode=user_notes&u=$user_id");
4c79b5
			meta_refresh(2, $redirect);
4c79b5
			trigger_error($msg . '

' . sprintf($user->lang['RETURN_PAGE'], '', ''));
4c79b5
		}
4c79b5
4c79b5
		// OK, they didn't submit a warning so lets build the page for them to do so
4c79b5
4c79b5
		// We want to make the message available here as a reminder
4c79b5
		// Parse the message and subject
4c79b5
		$message = censor_text($user_row['post_text']);
4c79b5
4c79b5
		// Second parse bbcode here
4c79b5
		if ($user_row['bbcode_bitfield'])
4c79b5
		{
4c79b5
			include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
4c79b5
4c79b5
			$bbcode = new bbcode($user_row['bbcode_bitfield']);
4c79b5
			$bbcode->bbcode_second_pass($message, $user_row['bbcode_uid'], $user_row['bbcode_bitfield']);
4c79b5
		}
4c79b5
4c79b5
		$message = bbcode_nl2br($message);
4c79b5
		$message = smiley_text($message);
4c79b5
4c79b5
		// Generate the appropriate user information for the user we are looking at
4c79b5
		if (!function_exists('get_user_avatar'))
4c79b5
		{
4c79b5
			include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
4c79b5
		}
4c79b5
4c79b5
		$rank_title = $rank_img = '';
4c79b5
		$avatar_img = get_user_avatar($user_row['user_avatar'], $user_row['user_avatar_type'], $user_row['user_avatar_width'], $user_row['user_avatar_height']);
4c79b5
4c79b5
		$template->assign_vars(array(
4c79b5
			'U_POST_ACTION'		=> $this->u_action,
4c79b5
4c79b5
			'POST'				=> $message,
4c79b5
			'USERNAME'			=> $user_row['username'],
4c79b5
			'USER_COLOR'		=> (!empty($user_row['user_colour'])) ? $user_row['user_colour'] : '',
4c79b5
			'RANK_TITLE'		=> $rank_title,
4c79b5
			'JOINED'			=> $user->format_date($user_row['user_regdate']),
4c79b5
			'POSTS'				=> ($user_row['user_posts']) ? $user_row['user_posts'] : 0,
4c79b5
			'WARNINGS'			=> ($user_row['user_warnings']) ? $user_row['user_warnings'] : 0,
4c79b5
4c79b5
			'AVATAR_IMG'		=> $avatar_img,
4c79b5
			'RANK_IMG'			=> $rank_img,
4c79b5
4c79b5
			'L_WARNING_POST_DEFAULT'	=> sprintf($user->lang['WARNING_POST_DEFAULT'], generate_board_url() . "/viewtopic.$phpEx?f=$forum_id&p=$post_id#p$post_id"),
4c79b5
4c79b5
			'S_CAN_NOTIFY'		=> $s_can_notify,
4c79b5
		));
4c79b5
	}
4c79b5
4c79b5
	/**
4c79b5
	* Handles warning the user
4c79b5
	*/
4c79b5
	function mcp_warn_user_view($action)
4c79b5
	{
4c79b5
		global $phpEx, $phpbb_root_path, $config, $module;
4c79b5
		global $template, $db, $user, $auth;
4c79b5
4c79b5
		$user_id = request_var('u', 0);
4c79b5
		$username = request_var('username', '', true);
4c79b5
		$notify = (isset($_REQUEST['notify_user'])) ? true : false;
4c79b5
		$warning = utf8_normalize_nfc(request_var('warning', '', true));
4c79b5
4c79b5
		$sql_where = ($user_id) ? "user_id = $user_id" : "username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
4c79b5
4c79b5
		$sql = 'SELECT *
4c79b5
			FROM ' . USERS_TABLE . '
4c79b5
			WHERE ' . $sql_where;
4c79b5
		$result = $db->sql_query($sql);
4c79b5
		$user_row = $db->sql_fetchrow($result);
4c79b5
		$db->sql_freeresult($result);
4c79b5
4c79b5
		if (!$user_row)
4c79b5
		{
4c79b5
			trigger_error('NO_USER');
4c79b5
		}
4c79b5
4c79b5
		// Prevent someone from warning themselves
4c79b5
		if ($user_row['user_id'] == $user->data['user_id'])
4c79b5
		{
4c79b5
			trigger_error('CANNOT_WARN_SELF');
4c79b5
		}
4c79b5
4c79b5
		$user_id = $user_row['user_id'];
4c79b5
4c79b5
		if (strpos($this->u_action, "&u=$user_id") === false)
4c79b5
		{
4c79b5
			$this->p_master->adjust_url('&u=' . $user_id);
4c79b5
			$this->u_action .= "&u=$user_id";
4c79b5
		}
4c79b5
4c79b5
		// Check if can send a notification
4c79b5
		if ($config['allow_privmsg'])
4c79b5
		{
4c79b5
			$auth2 = new auth();
4c79b5
			$auth2->acl($user_row);
4c79b5
			$s_can_notify = ($auth2->acl_get('u_readpm')) ? true : false;
4c79b5
			unset($auth2);
4c79b5
		}
4c79b5
		else
4c79b5
		{
4c79b5
			$s_can_notify = false;
4c79b5
		}
4c79b5
4c79b5
		// Prevent against clever people
4c79b5
		if ($notify && !$s_can_notify)
4c79b5
		{
4c79b5
			$notify = false;
4c79b5
		}
4c79b5
4c79b5
		if ($warning && $action == 'add_warning')
4c79b5
		{
4c79b5
			if (check_form_key('mcp_warn'))
4c79b5
			{
4c79b5
				add_warning($user_row, $warning, $notify);
4c79b5
				$msg = $user->lang['USER_WARNING_ADDED'];
4c79b5
			}
4c79b5
			else
4c79b5
			{
4c79b5
				$msg = $user->lang['FORM_INVALID'];
4c79b5
			}
4c79b5
			$redirect = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=notes&mode=user_notes&u=$user_id");
4c79b5
			meta_refresh(2, $redirect);
4c79b5
			trigger_error($msg . '

' . sprintf($user->lang['RETURN_PAGE'], '', ''));
4c79b5
		}
4c79b5
4c79b5
		// Generate the appropriate user information for the user we are looking at
4c79b5
		if (!function_exists('get_user_avatar'))
4c79b5
		{
4c79b5
			include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
4c79b5
		}
4c79b5
4c79b5
		$rank_title = $rank_img = '';
4c79b5
		$avatar_img = get_user_avatar($user_row['user_avatar'], $user_row['user_avatar_type'], $user_row['user_avatar_width'], $user_row['user_avatar_height']);
4c79b5
4c79b5
		// OK, they didn't submit a warning so lets build the page for them to do so
4c79b5
		$template->assign_vars(array(
4c79b5
			'U_POST_ACTION'		=> $this->u_action,
4c79b5
4c79b5
			'USERNAME'			=> $user_row['username'],
4c79b5
			'USER_COLOR'		=> (!empty($user_row['user_colour'])) ? $user_row['user_colour'] : '',
4c79b5
			'RANK_TITLE'		=> $rank_title,
4c79b5
			'JOINED'			=> $user->format_date($user_row['user_regdate']),
4c79b5
			'POSTS'				=> ($user_row['user_posts']) ? $user_row['user_posts'] : 0,
4c79b5
			'WARNINGS'			=> ($user_row['user_warnings']) ? $user_row['user_warnings'] : 0,
4c79b5
4c79b5
			'AVATAR_IMG'		=> $avatar_img,
4c79b5
			'RANK_IMG'			=> $rank_img,
4c79b5
4c79b5
			'S_CAN_NOTIFY'		=> $s_can_notify,
4c79b5
		));
4c79b5
4c79b5
		return $user_id;
4c79b5
	}
4c79b5
}
4c79b5
4c79b5
/**
4c79b5
* Insert the warning into the database
4c79b5
*/
4c79b5
function add_warning($user_row, $warning, $send_pm = true, $post_id = 0)
4c79b5
{
4c79b5
	global $phpEx, $phpbb_root_path, $config;
4c79b5
	global $template, $db, $user, $auth;
4c79b5
4c79b5
	if ($send_pm)
4c79b5
	{
4c79b5
		include_once($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx);
4c79b5
		include_once($phpbb_root_path . 'includes/message_parser.' . $phpEx);
4c79b5
4c79b5
		$user_row['user_lang'] = (file_exists($phpbb_root_path . 'language/' . $user_row['user_lang'] . "/mcp.$phpEx")) ? $user_row['user_lang'] : $config['default_lang'];
4c79b5
		include($phpbb_root_path . 'language/' . basename($user_row['user_lang']) . "/mcp.$phpEx");
4c79b5
4c79b5
		$message_parser = new parse_message();
4c79b5
4c79b5
		$message_parser->message = sprintf($lang['WARNING_PM_BODY'], $warning);
4c79b5
		$message_parser->parse(true, true, true, false, false, true, true);
4c79b5
4c79b5
		$pm_data = array(
4c79b5
			'from_user_id'			=> $user->data['user_id'],
4c79b5
			'from_user_ip'			=> $user->ip,
4c79b5
			'from_username'			=> $user->data['username'],
4c79b5
			'enable_sig'			=> false,
4c79b5
			'enable_bbcode'			=> true,
4c79b5
			'enable_smilies'		=> true,
4c79b5
			'enable_urls'			=> false,
4c79b5
			'icon_id'				=> 0,
4c79b5
			'bbcode_bitfield'		=> $message_parser->bbcode_bitfield,
4c79b5
			'bbcode_uid'			=> $message_parser->bbcode_uid,
4c79b5
			'message'				=> $message_parser->message,
4c79b5
			'address_list'			=> array('u' => array($user_row['user_id'] => 'to')),
4c79b5
		);
4c79b5
4c79b5
		submit_pm('post', $lang['WARNING_PM_SUBJECT'], $pm_data, false);
4c79b5
	}
4c79b5
4c79b5
	add_log('admin', 'LOG_USER_WARNING', $user_row['username']);
4c79b5
	$log_id = add_log('user', $user_row['user_id'], 'LOG_USER_WARNING_BODY', $warning);
4c79b5
4c79b5
	$sql_ary = array(
4c79b5
		'user_id'		=> $user_row['user_id'],
4c79b5
		'post_id'		=> $post_id,
4c79b5
		'log_id'		=> $log_id,
4c79b5
		'warning_time'	=> time(),
4c79b5
	);
4c79b5
4c79b5
	$db->sql_query('INSERT INTO ' . WARNINGS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
4c79b5
4c79b5
	$sql = 'UPDATE ' . USERS_TABLE . '
4c79b5
		SET user_warnings = user_warnings + 1,
4c79b5
			user_last_warning = ' . time() . '
4c79b5
		WHERE user_id = ' . $user_row['user_id'];
4c79b5
	$db->sql_query($sql);
4c79b5
4c79b5
	// We add this to the mod log too for moderators to see that a specific user got warned.
4c79b5
	$sql = 'SELECT forum_id, topic_id
4c79b5
		FROM ' . POSTS_TABLE . '
4c79b5
		WHERE post_id = ' . $post_id;
4c79b5
	$result = $db->sql_query($sql);
4c79b5
	$row = $db->sql_fetchrow($result);
4c79b5
	$db->sql_freeresult($result);
4c79b5
4c79b5
	add_log('mod', $row['forum_id'], $row['topic_id'], 'LOG_USER_WARNING', $user_row['username']);
4c79b5
}
4c79b5
4c79b5
?>