#
# For updating from RC1 (0.0.1) version to RC2 (0.0.2):
#
## Files To Edit (7):
##		posting.php
##		modcp.php
##		includes/functions_post.php
##		includes/usercp_viewprofile.php
##		admin/admin_users.php
##		templates/subSilver/admin/user_edit_body.tpl
##		language/lang_english/lang_admin.php

# 
# STEP 1: Uploading all files
# 
copy upload/*.php to *.php
copy upload/includes/*.php to includes/
copy upload/admin/*.php to admin/
copy upload/images/*.* to images/
copy upload/language/lang_english/*.php to language/lang_english/
copy upload/templates/subSilver/*.* to templates/subSilver/
copy upload/templates/subSilver/admin/*.* to templates/subSilver/admin/

# 
# STEP 2: Updating the database
# 
Run:
	reputation_mod_update_v001_to_002.php
Then delete it!

#
# STEP 3: Modifying existing phpBB2 Files
#

# 
#-----[ OPEN ]------------------------------------------ 
# 
posting.php
# 
#-----[ FIND ]------------------------------------------ 
#
include($phpbb_root_path . 'reputation_common.'.$phpEx);
# 
#-----[ AFTER, ADD ]------------------------------------------ 
# 
include($phpbb_root_path . 'includes/functions_reputation.'.$phpEx);
# 
#-----[ FIND ]------------------------------------------ 
#
			update_post_stats($mode, $post_data, $forum_id, $topic_id, $post_id, $user_id);
# 
#-----[ AFTER, ADD ]------------------------------------------ 
#
			update_reputations($mode, $user_id);
# 
#-----[ OPEN ]------------------------------------------ 
# 
modcp.php
# 
#-----[ FIND ]------------------------------------------ 
#
include($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
# 
#-----[ AFTER, ADD ]------------------------------------------ 
#
include($phpbb_root_path . 'reputation_common.'.$phpEx);
# 
#-----[ FIND ]------------------------------------------ 
#
			$count_sql = array();
			while ( $row = $db->sql_fetchrow($result) )
			{
				$count_sql[] = "UPDATE " . USERS_TABLE . " 
					SET user_posts = user_posts - " . $row['posts'] . " 
					WHERE user_id = " . $row['poster_id'];
			} 
# 
#-----[ REPLACE WITH ]------------------------------------------ 
#
			$count_sql = array();
			while ( $row = $db->sql_fetchrow($result) )
			{
				$rep = ($rep_config['posts_to_earn'] != 0) ? (1/$rep_config['posts_to_earn']) : 0;
				$count_sql[] = "UPDATE " . USERS_TABLE . " 
					SET user_posts = user_posts - " . $row['posts'] . ", user_reputation = user_reputation - " . $rep . "
					WHERE user_id = " . $row['poster_id'];
			}
# 
#-----[ OPEN ]------------------------------------------ 
# 
includes/usercp_viewprofile.php
# 
#-----[ FIND ]------------------------------------------ 
#
	// START ADD Reputation Mod v.0.0.1
# 
#-----[ REPLACE WITH ]------------------------------------------ 
#
	// START ADD Reputation Mod v.0.0.2
# 
#-----[ FIND ]------------------------------------------ 
#
	// END ADD Reputation Mod v.0.0.1
 
#-----[ REPLACE WITH ]------------------------------------------ 
#
	// END ADD Reputation Mod v.0.0.2
# 
#-----[ FIND ]------------------------------------------ 
#
	// START ADD Reputation Mod v.0.0.1
# 
#-----[ REPLACE WITH ]------------------------------------------ 
#
	// START ADD Reputation Mod v.0.0.2
# 
#-----[ FIND ]------------------------------------------ 
#
	// END ADD Reputation Mod v.0.0.1
 
#-----[ REPLACE WITH ]------------------------------------------ 
#
	// END ADD Reputation Mod v.0.0.2
# 
#-----[ OPEN ]------------------------------------------ 
#
includes/functions_post.php

# 
#-----[ FIND ]------------------------------------------ 
#
function update_post_stats(&$mode, &$post_data, &$forum_id, &$topic_id, &$post_id, &$user_id)
{
	global $db, $rep_config, $userdata;

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# 
function update_post_stats(&$mode, &$post_data, &$forum_id, &$topic_id, &$post_id, &$user_id)
{
	global $db;

# 
#-----[ FIND ]------------------------------------------ 
#
	// START ADD Reputation Mod v.0.0.1
	if ($rep_config['posts_to_earn'] != 0)
	{
		$sign_rep = ($mode == 'delete') ? '- ' . (1/$rep_config['posts_to_earn']) : '+ ' . (1/$rep_config['posts_to_earn']);
	} else
	{
		$sign_rep = ' + 0';
	}
	if ($userdata['user_id'] == ANONYMOUS)
	{
		$last_time = time();
	} else
	{
		$last_time = $userdata['user_rep_last_time'];
		$dif = time() - $last_time;
		$dif = round($dif/86400,0);
		if ($dif > 1)
		{
			if ($rep_config['days_to_earn'] != 0)
			{
				$sign_rep .= ' + ' . $dif / $rep_config['days_to_earn'];
			} else
			{
				$sign_rep .= ' + 0';
			}
			$last_time = time();
		}
	}
	// END ADD Reputation Mod v.0.0.1

# 
#-----[ REPLACE WITH ]------------------------------------------ 
# replace with nothing, just remove

# 
#-----[ FIND ]------------------------------------------ 
#
		$sql = "UPDATE " . USERS_TABLE . "
			SET user_posts = user_posts $sign, user_reputation = user_reputation $sign_rep, user_rep_last_time = $last_time

# 
#-----[ REPLACE WITH ]------------------------------------------ 
#
		$sql = "UPDATE " . USERS_TABLE . "
			SET user_posts = user_posts $sign
# 
#-----[ OPEN ]------------------------------------------ 
#
admin/admin_users.php
# 
#-----[ FIND ]------------------------------------------ 
# 
		$icq = ( !empty($HTTP_POST_VARS['icq']) ) ? trim(strip_tags( $HTTP_POST_VARS['icq'] ) ) : '';
# 
#-----[ BEFORE, ADD ]------------------------------------------ 
# 
		$reputation = ( !empty($HTTP_POST_VARS['reputation']) ) ? trim(strip_tags( $HTTP_POST_VARS['reputation'] ) ) : '';
# 
#-----[ FIND ]------------------------------------------ 
# 
			$icq = stripslashes($icq);
# 
#-----[ BEFORE, ADD ]------------------------------------------ 
# 
			$reputation = intval(stripslashes($reputation));
# 
#-----[ FIND ]------------------------------------------ 
# 
			$sql = "UPDATE " . USERS_TABLE . "
				SET " . $username_sql . $passwd_sql . "user_email = '" . str_replace("\'", "''", $email) . "'
# 
#-----[ INLINE, ADD AFTER]------------------------------------------ 
# 
, user_reputation = '" . str_replace("\'", "''", $reputation) . "'
# 
#-----[ FIND ]------------------------------------------ 
# 
			$icq = stripslashes($icq);
# 
#-----[ BEFORE, ADD ]------------------------------------------ 
# 
			$reputation = intval($reputation);
# 
#-----[ FIND ]------------------------------------------ 
#
		$icq = $this_userdata['user_icq'];
# 
#-----[ BEFORE, ADD ]------------------------------------------ 
# 
		$reputation = $this_userdata['user_reputation'];
# 
#-----[ FIND ]------------------------------------------ 
#
			$s_hidden_fields .= '<input type="hidden" name="icq" value="' . str_replace("\"", "&quot;", $icq) . '" />';
# 
#-----[ BEFORE, ADD ]------------------------------------------ 
# 
			$s_hidden_fields .= '<input type="hidden" name="reputation" value="' . str_replace("\"", "&quot;", $reputation) . '" />';
# 
#-----[ FIND ]------------------------------------------ 
#
			'ICQ' => $icq,
# 
#-----[ BEFORE, ADD ]------------------------------------------ 
# 
			'REPUTATION' => $reputation,
# 
#-----[ FIND ]------------------------------------------ 
#
			'L_ICQ_NUMBER' => $lang['ICQ'],
# 
#-----[ BEFORE, ADD ]------------------------------------------ 
# 
			'L_REPUTATION' => $lang['Reputation'],
# 
#-----[ OPEN ]------------------------------------------ 
# 
templates/subSilver/admin/user_edit_body.tpl
# 
#-----[ FIND ]------------------------------------------ 
#
	<tr> 
	  <td class="row1"><span class="gen">{L_ICQ_NUMBER}</span></td>
# 
#-----[ BEFORE, ADD ]------------------------------------------ 
#
	<tr> 
	  <td class="row1"><span class="gen">{L_REPUTATION}</span></td>
	  <td class="row2"> 
		<input class="post" type="text" name="reputation" size="10" maxlength="15" value="{REPUTATION}" />
	  </td>
	</tr>
# 
#-----[ OPEN ]------------------------------------------ 
# 
language/lang_english/lang_admin.php

# 
#-----[ FIND ]------------------------------------------ 
#
// Reputation mod v.0.0.1
$lang['Reputation_Config_Title'] = 'Reputation System Configuration';
$lang['Reputation_Config_Explain'] = 'Here you can set the options for Users Reputation System.';
$lang['Rep_config_updated'] = 'Reputation System config updated';
$lang['Click_return_rep_config'] = '%sReturn to Reputation System config%s';
$lang['Disable_rep'] = 'Disable Reputation System';
$lang['Graphic_version'] = 'Graphic version';
$lang['Posts_to_earn'] = 'Amount of posts to earn 1 reputation point';
$lang['Days_to_earn'] = 'Amount of days on forum to earn 1 reputation point';
$lang['Flood_control_time'] = 'Minimum amount of minutes between reputation givings by the same user';
$lang['Medal1_to_earn'] = 'Amount of reputation points to earn the 1st size medal';
$lang['Medal2_to_earn'] = 'Amount of reputation points to earn the 2nd size medal';
$lang['Medal3_to_earn'] = 'Amount of reputation points to earn the 3rd size medal';
$lang['Medal4_to_earn'] = 'Amount of reputation points to earn the 4th size medal';
$lang['Given_rep_to_earn'] = 'Amount of given reputation to earn 1 reputation point';
# 
#-----[ REPLACE WITH ]------------------------------------------ 
#
// Reputation mod v.0.0.2
$lang['Reputation'] = 'Reputation';
$lang['Reputation_Config_Title'] = 'Reputation System Configuration';
$lang['Reputation_Config_Explain'] = 'Here you can set the options for Users Reputation System.';
$lang['Rep_config_updated'] = 'Reputation System config updated';
$lang['Click_return_rep_config'] = '%sReturn to Reputation System config%s';
$lang['Disable_rep'] = 'Disable Reputation System';
$lang['Graphic_version'] = 'Graphic version';
$lang['Show_stats_to_mods'] = 'Show the stats of given points only to administrators/moderators';
$lang['PM_notify'] = 'Notify users through PM when they receive new reputation points';
$lang['Posts_to_earn'] = 'Amount of posts to earn 1 reputation point (0 - to disable)';
$lang['Days_to_earn'] = 'Amount of days on forum to earn 1 reputation point (0 - to disable)';
$lang['Flood_control_time'] = 'Minimum amount of minutes between reputation givings by the same user (no use for admins and mods)';
$lang['Medal1_to_earn'] = 'Amount of reputation points to earn the 1st size medal';
$lang['Medal2_to_earn'] = 'Amount of reputation points to earn the 2nd size medal';
$lang['Medal3_to_earn'] = 'Amount of reputation points to earn the 3rd size medal';
$lang['Medal4_to_earn'] = 'Amount of reputation points to earn the 4th size medal';
$lang['Given_rep_to_earn'] = 'Amount of given reputation to earn 1 reputation point (0 - to disable)';
$lang['Repsum_limit'] = 'Limit of giving reputation points to a user (0 - no limits)';
$lang['Default_amount'] = 'Turn the simple version on and set the default amount of every giving to this number (0 - to disable)';
 
