<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="modx.prosilver.en.xsl"?>
<!--NOTICE: Please open this file in your web browser. If presented with a security warning, you may safely tell it to allow the blocked content.-->
<!--For security purposes, please check: http://www.phpbb.com/mods/ for the latest version of this MOD.\nAlthough MODs are checked before being allowed in the MODs Database there is no guarantee that there are no security problems within the MOD.\nNo support will be given for MODs not found within the MODs Database which can be found at http://www.phpbb.com/mods/-->
<mod xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.phpbb.com/mods/xml/modx-1.2.5.xsd">
	<header>
		<meta name="generator" content="MODX file generated with PP MODX Creator 1.0.1 by tumba25 (offline version)"/>
		<license><![CDATA[http://opensource.org/licenses/gpl-license.php GNU General Public License v2]]></license>
		<title lang="en"><![CDATA[Change User's Post Count]]></title>
		<description lang="en"><![CDATA[The MOD allows an administrator to change a user's post count.]]></description>
		<author-notes lang="en"><![CDATA[This MOD adds a field to the user management section of the admin panel which enables you to change a user's postcount to any value.

			When this mod was updated to phpBB3, the ability to change the behaviour of the "total posts" statistics was removed.  Sorry.
			
			This MOD was originally authored by Tom Levens for phpBB 2.0.
			It was converted to phpBB 3.0 by prothought.]]></author-notes>
		<author-group>
			<author>
				<realname><![CDATA[Tom Levens]]></realname>
				<username><![CDATA[tomlevens]]></username>
				<email><![CDATA[tom@tomlevens.co.uk]]></email>
			</author>
			<author>
				<username><![CDATA[prothought]]></username>
				<homepage><![CDATA[http://www.phoenixforums.net]]></homepage>
				<email><![CDATA[mrprothought@gmail.com]]></email>
			</author>
		</author-group>
		<mod-version>2.0.3</mod-version>
		<installation>
			<level>easy</level>
			<time>300</time>
			<target-version>3.0.7-PL1</target-version>
		</installation>
		<history>
			<entry>
				<date>2004-01-26</date>
				<rev-version>1.0.0.</rev-version>
				<changelog lang="en">
					<change><![CDATA[Initial Release]]></change>
				</changelog>
			</entry>
			<entry>
				<date>2004-01-26</date>
				<rev-version>1.0.1.</rev-version>
				<changelog lang="en">
					<change><![CDATA[I had put the name of the wrong MOD in the comments... oops!]]></change>
				</changelog>
			</entry>
			<entry>
				<date>2006-11-23</date>
				<rev-version>1.0.2.</rev-version>
				<changelog lang="en">
					<change><![CDATA[Added an optional step to change the behaviour of the total posts statistic - as requested by prophetUK]]></change>
				</changelog>
			</entry>
			<entry>
				<date>2007-02-06</date>
				<rev-version>1.0.3.</rev-version>
				<changelog lang="en">
					<change><![CDATA[Added a function to recalculate the user's real postcount (i.e. the actual number of posts that user has made) - as requested by adk_tj]]></change>
				</changelog>
			</entry>
			<entry>
				<date>2007-09-13</date>
				<rev-version>2.0.0.</rev-version>
				<changelog lang="en">
					<change><![CDATA[Ported from phpBB 2.0 to phpBB 3.0 by prothought.]]></change>
				</changelog>
			</entry>
			<entry>
				<date>2007-09-19</date>
				<rev-version>2.0.1.</rev-version>
				<changelog lang="en">
					<change><![CDATA[Added the missing license.txt file required for submittal.]]></change>
				</changelog>
			</entry>
			<entry>
				<date>2007-10-18</date>
				<rev-version>2.0.2.</rev-version>
				<changelog lang="en">
					<change><![CDATA[Updated to support RC7.]]></change>
				</changelog>
			</entry>
			<entry>
				<date>2007-12-04</date>
				<rev-version>2.0.3.</rev-version>
				<changelog lang="en">
					<change><![CDATA[Updated to support RC8.]]></change>
				</changelog>
			</entry>
		</history>
	</header>
	<action-group>
		<open src="adm/style/acp_users_overview.html">
			<edit>
				<find><![CDATA[	<dt><label>{L_POSTS}:</label></dt>
	<dd><strong>{USER_POSTS}</strong><!-- IF POSTS_IN_QUEUE and U_MCP_QUEUE --> (<a href="{U_MCP_QUEUE}">{L_POSTS_IN_QUEUE}</a>)<!-- ELSEIF POSTS_IN_QUEUE --> ({L_POSTS_IN_QUEUE})<!-- ENDIF --></dd>

]]></find>
				<action type="replace-with"><![CDATA[	<script type="text/javascript">
	<!--
		function reset_post_count(posts)
		{
			var user_overview = document.getElementById('user_overview');
			user_overview.user_posts.value = posts;
		}
	//-->
	</script>
	<dt><label>{L_POSTS}:</label><br /><span><a href="javascript:reset_post_count({POSTS_COUNTED});">{L_POSTS_RECOUNT}</a></span></dt>
	<dd><input class="text medium" type="text" id="user_posts" name="user_posts" value="{USER_POSTS}" /><!-- IF POSTS_IN_QUEUE and U_MCP_QUEUE --> (<a href="{U_MCP_QUEUE}">{L_POSTS_IN_QUEUE}</a>)<!-- ELSEIF POSTS_IN_QUEUE --> ({L_POSTS_IN_QUEUE})<!-- ENDIF --></dd>
]]></action>
			</edit>
		</open>
		<open src="includes/acp/acp_users.php">
			<edit>
				<find><![CDATA[						'username'			=> utf8_normalize_nfc(request_var('user', $user_row['username'], true)),]]></find>
				<action type="after-add"><![CDATA[						'user_posts'		=> request_var('user_posts', $user_row['user_posts'], true),]]></action>
			</edit>
			<edit>
				<find><![CDATA[					$update_email = ($data['email'] != $user_row['user_email']) ? $data['email'] : false;]]></find>
				<action type="after-add"><![CDATA[					$update_postcount = ($user_row['user_posts'] != $data['user_posts']) ? intval($data['user_posts']) : false;]]></action>
			</edit>
			<edit>
				<find><![CDATA[						if ($update_email !== false)]]></find>
				<action type="before-add"><![CDATA[						if ($update_postcount !== false)
						{
							$sql_ary += array(
								'user_posts'		=> $update_postcount,
							);

							add_log('user', $user_id, 'LOG_USER_UPDATE_POSTCOUNT', $user_row['username'], $user_row['user_posts'], $update_postcount);
						}

]]></action>
			</edit>
			<edit>
				<find><![CDATA[				$template->assign_vars(array(
					'L_NAME_CHARS_EXPLAIN'		=> sprintf($user->lang[$config['allow_name_chars'] . '_EXPLAIN'], $config['min_name_chars'], $config['max_name_chars']),]]></find>
				<action type="before-add"><![CDATA[				// Get the user's total post count in case a reset is requested
				$sql = 'SELECT COUNT(post_id) as total_posts
					FROM ' . POSTS_TABLE . '
					WHERE poster_id = ' . $user_row['user_id'];
				$results = $db->sql_query($sql);
				$posts_counted = (int) $db->sql_fetchfield('total_posts');
				$db->sql_freeresult($result);

]]></action>
			</edit>
			<edit>
				<find><![CDATA[					'L_CHANGE_PASSWORD_EXPLAIN'	=> sprintf($user->lang[$config['pass_complex'] . '_EXPLAIN'], $config['min_pass_chars'], $config['max_pass_chars']),]]></find>
				<action type="after-add"><![CDATA[					'POSTS_COUNTED'				=> $posts_counted,]]></action>
			</edit>
		</open>
		<open src="language/en/common.php">
			<edit>
				<find><![CDATA[	'POSTS'					=> 'Posts',]]></find>
				<action type="after-add"><![CDATA[	'POSTS_RECOUNT'			=> 'Recount Posts',]]></action>
			</edit>
		</open>
		<open src="language/en/acp/common.php">
			<edit>
				<find><![CDATA['LOG_USER_UPDATE_NAME'	=> '<strong>Changed username</strong><br />» from “%1$s” to “%2$s”',]]></find>
				<action type="after-add"><![CDATA[	'LOG_USER_UPDATE_POSTCOUNT'	=> '<strong>Changed post count</strong><br />» from “%1$s” to “%2$s”',]]></action>
			</edit>
		</open>
		<diy-instructions lang="en"><![CDATA[Purge the cache 
(ACP -> GENERAL -> Resynchronise or reset statistics -> Purge the cache)]]></diy-instructions>
	</action-group>
</mod>
