####################################################################################################
## MOD Title: Democracy MOD - Update from 0.1.4 to 0.2.0
## MOD Author: Carbofos < carbofos@mail.ru > (N/A) N/A
## MOD Author: ETZel < etzel@mail.ru > (N/A) N/A
## MOD Description: Adds some social mechanisms to the phpBB (namely: warnings + reputation + reports)
## MOD Version: 0.2.0
##
## Installation Level: Intermediate
## Installation Time: 30 Minutes
## Files To Edit (14):
##    index.php
##    profile.php
##    viewtopic.php
##    includes/constants.php
##    includes/functions_post.php
##    includes/functions_admin.php
##    includes/functions.php
##    includes/page_header.php
##    includes/usercp_viewprofile.php
##    language/lang_english/lang_admin.php
##    language/lang_english/lang_main.php
##    templates/subSilver/index_body.tpl
##    templates/subSilver/profile_view_body.tpl
##    templates/subSilver/viewtopic_body.tpl
##
## Included Files (12):
##    post_report.php
##    reputation.php
##    admin/admin_democracy.php
##    includes/functions_reputation.php
##    includes/usercp_reputation.php
##    language/lang_english/email/reputation_ban.tpl
##    language/lang_english/email/reputation_warning.tpl
##    templates/subSilver/modcp_reports_body.tpl
##    templates/subSilver/profile_modify_reputation.tpl
##    templates/subSilver/profile_view_reputation.tpl
##    templates/subSilver/profile_warning.tpl
##    templates/subSilver/admin/reputation_body.tpl
##
## License: http://opensource.org/licenses/gpl-license.php GNU Public License v2
####################################################################################################
##
## For security purposes, please check: http://www.phpbb.com/mods/
## for the latest version of this MOD. Although MODs are checked
## before being allowed in the MODs Database there is no guarantee
## that there are no security problems within the MOD. No support
## will be given for MODs not found within the MODs Database which
## can be found at http://www.phpbb.com/mods/
##
####################################################################################################
##
## MOD History:
##
##   2006-07-15 - Version 0.2.0
##      - New permissions system, much more flexible
##      - An option to show the least respected users list on index in addition to the most respected.
##      - Post warnigns are now displayed in-line
##      - Rich set of restrictions on who can change reputation and when
##      - An important "positive reputation only" mode
##      - New bugs due to heavy refactoring
##
####################################################################################################
##
## Author Notes:
##    Do not miss the "DIY INSTRUCTIONS" block at the end of this file.
##
####################################################################################################
##
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##
####################################################################################################
#
#-----------------------[ COPY ]-------------------------
#
copy root/post_report.php                                   to post_report.php
copy root/reputation.php                                    to reputation.php
copy root/admin/admin_democracy.php                         to admin/admin_democracy.php
copy root/includes/functions_reputation.php                 to includes/functions_reputation.php
copy root/includes/usercp_reputation.php                    to includes/usercp_reputation.php
copy root/templates/subSilver/modcp_reports_body.tpl        to templates/subSilver/modcp_reports_body.tpl
copy root/templates/subSilver/profile_modify_reputation.tpl to templates/subSilver/profile_modify_reputation.tpl
copy root/templates/subSilver/profile_view_reputation.tpl   to templates/subSilver/profile_view_reputation.tpl
copy root/templates/subSilver/profile_warning.tpl           to templates/subSilver/profile_warning.tpl
copy root/templates/subSilver/admin/reputation_body.tpl     to templates/subSilver/admin/reputation_body.tpl
#
#-----------------------[ SQL ]-------------------------
#
ALTER TABLE `phpbb_reputation` ALTER `post_id` SET DEFAULT '-1';
ALTER TABLE `phpbb_reputation` ALTER `forum_id` SET DEFAULT '-1';
ALTER TABLE `phpbb_reputation` DROP INDEX `forum_id`;
ALTER TABLE `phpbb_reputation` ADD INDEX `expire` (`expire`);

ALTER TABLE `phpbb_post_reports` ALTER `post_id` SET DEFAULT '-1';
ALTER TABLE `phpbb_post_reports` ALTER `review_id` SET DEFAULT '-1';
ALTER TABLE `phpbb_post_reports` ALTER `forum_id` SET DEFAULT '-1';

ALTER TABLE `phpbb_users` CHANGE `reputation` `user_reputation` smallint(8) NOT NULL default '0';
ALTER TABLE `phpbb_users` CHANGE `warnings` `user_warnings` tinyint(4) unsigned NOT NULL default '0';
ALTER TABLE `phpbb_users` ADD `user_reputation_plus` smallint(8) NOT NULL default '0';

DELETE FROM `phpbb_config` WHERE `config_name` LIKE 'reputation_%' OR `config_name` = 'warnings_enabled';

INSERT INTO `phpbb_config` (`config_name`, `config_value`) VALUES
  ('warnings_enabled', '1'),
  ('reputation_enabled', '1'),
  ('reports_enabled', '1'),
  ('reputation_least_respected', '0'),
  ('reputation_ban_warnings', '5'),
  ('reputation_delete_expired', '-1'),
  ('reputation_warning_expire', '3,30'),
  ('reputation_ban_expire', '3,30'),
  ('reputation_perms', '0,0,1,3,3,3,3,5,3,5,3,3,3'),
  ('reputation_none', '0,0'),
  ('reputation_mod_norep', '0'),
  ('reputation_reviews_per_page', '25'),
  ('reputation_reports_per_page', '25'),
  ('reputation_display', '1'),
  ('reputation_most_respected', '1'),
  ('reputation_days_req', '0'),
  ('reputation_posts_req', '0'),
  ('reputation_points_req', '-100000'),
  ('reputation_warnings_req', '100000'),
  ('reputation_rotation_limit', '0'),
  ('reputation_time_limit', '0'),
  ('reputation_check_rate', '60'),
  ('reputation_last_check_time', '1152884749'),
  ('reputation_empty_reviews', '0'),
  ('reputation_positive_only', '0'),
  ('reputation_check_reports', '1'),
  ('reputation_reports_color', ''),
  ('reputation_admin_norep', '0');

#
#-----[ OPEN ]------------------------------------------
#
index.php
#
#-----[ FIND ]------------------------------------------
#
//////////democracy///////////////////////////////
//
// Get user(s) with the most reputation points
//
if ( $board_config['reputation_enabled'] )
{
	$sql = 'SELECT MAX(reputation) AS maxrep FROM ' . USERS_TABLE;
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Couldn\'t retrieve the reputation stats', '', __LINE__, __FILE__, $sql);
	}
	$reputation_max = $db->sql_fetchrow($result);

	if ( $reputation_max['maxrep'] > 0 )
	{
		$sql = 'SELECT username, user_id, reputation FROM ' . USERS_TABLE . '
			WHERE user_id <> ' . ANONYMOUS . '
				AND reputation = ' . $reputation_max['maxrep'];

		if ( !($result = $db->sql_query($sql)) )
		{
			message_die(GENERAL_ERROR, 'Couldn\'t retrieve the reputation stats', '', __LINE__, __FILE__, $sql);
		}

		$respect_set = $db->sql_fetchrowset($result);

		if ( count($respect_set) > 1 )
		{
			$l_respected_user_s = $lang['reputation_most_respected_users'];
		}
		else
		{
			$l_respected_user_s = $lang['reputation_most_respected_user'];
		}
		for ( $i = 0; $i < count($respect_set); $i++ )
		{
			$respected_user_link = '<b><a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . '=' . $respect_set[$i]['user_id']) . '">' . $respect_set[$i]['username'] . '</a></b>';
			$s_respected_user_s .= ( $s_respected_user_s != '' ) ? ', ' . $respected_user_link : $respected_user_link;
		}
		$s_respected_user_s .= '<br />';
	}
}
//
// Check for post reports
//
if ( $board_config['reputation_check_reports'] == 1 && ( $userdata['user_level'] == ADMIN || $userdata['user_level'] == MOD || $userdata['user_level'] == GLOBAL_MOD || $userdata['user_level'] == MAIN_MOD ) )
{
	switch ( $userdata['user_level'] )
	{
		case ADMIN:
			// Select all reports
			$from = POST_REPORTS_TABLE . ' r';
			$where = '1';
			break;
		case MOD:
			// Select reports from only those forums user can moderate
			$from = POST_REPORTS_TABLE . ' r, ' . USER_GROUP_TABLE . ' g, ' . AUTH_ACCESS_TABLE . ' a';
			$where = 'a.auth_mod = 1
					AND a.forum_id = r.forum_id
					AND a.group_id = g.group_id
					AND g.user_id = ' . $userdata['user_id'];
			break;
	}

	//
	// Get reports count
	//
	$sql = 'SELECT COUNT(r.report_id) AS num_reports
		FROM ' . $from . '
		WHERE ' . $where;
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, "Could not obtain limited reports count information", '', __LINE__, __FILE__, $sql);
	}
	$total_post_reports = ( $row = $db->sql_fetchrow($result) ) ? intval($row['num_reports']) : 0;
}
///////////////////////////////////////////////

#
#-----[ REPLACE WITH ]------------------------------------------
#
//////////democracy///////////////////////////////
//
// Get user(s) with the most reputation points
//
$s_most_respected_users = $s_least_respected_users = $u_reported_posts = '';

if ($board_config['reputation_enabled'] && ($board_config['reputation_most_respected'] || $board_config['reputation_least_respected']))
{
	include_once($phpbb_root_path . 'includes/functions_reputation.' . $phpEx);

	function reputation_user_list($cond, &$user_list)
	{
		global $db, $phpEx, $theme;

		$user_list = ''; $user_count = 0;
		$result = db_query('SELECT username, user_id, user_level, user_reputation FROM {USERS_TABLE}
			WHERE user_id <> {ANONYMOUS} AND ' . $cond);

		while ($row = $db->sql_fetchrow($result))
		{
			switch ($row['user_level'])
			{
				case ADMIN:
					$style_color = ' style="color: #' . $theme['fontcolor3'] . '"';
					break;
				case MOD:
					$style_color = ' style="color: #' . $theme['fontcolor2'] . '"';
					break;
				default:
					$style_color = '';
			}
			// NOTE: this string will be cached, so session ids will be added later
			$user_list .= '<b><a href="profile.' . $phpEx . '?mode=viewprofile&amp;' . POST_USERS_URL . '=' . $row['user_id'] . "\"$style_color>" . $row['username'] . '</a></b>, ';
			++$user_count;
		}

		$user_list = substr($user_list, 0, -2);
		return $user_count;
	}

	if (!($rep_cache = cache_get(RESPECTED_CACHE)))
	{
		$rep_cache = array('num_most_respected' => 0, 'num_least_respected' => 0, 'most_respected' => '', 'least_respected' => '');

		if ($board_config['reputation_most_respected'])
		{
			$result = db_query('SELECT user_reputation FROM {USERS_TABLE} GROUP BY user_reputation ORDER BY user_reputation DESC LIMIT %d', $board_config['reputation_most_respected']);

			$reputation = 0;
			while (($row = $db->sql_fetchrow($result)) && $row['user_reputation'] > 0)
			{
				$reputation = $row['user_reputation'];
			}

			if ($reputation && ($rep_cache['num_most_respected'] = reputation_user_list('user_reputation >= ' . $reputation . ' ORDER BY user_reputation DESC', $rep_list)))
			{
				$rep_cache['most_respected'] = $rep_list;
			}
		}

		if ($board_config['reputation_least_respected'] && !$board_config['reputation_positive_only'])
		{
			$result = db_query('SELECT user_reputation FROM {USERS_TABLE} GROUP BY user_reputation ORDER BY user_reputation ASC LIMIT %d', $board_config['reputation_least_respected']);

			$reputation = 0;
			while (($row = $db->sql_fetchrow($result)) && $row['user_reputation'] < 0)
			{
				$reputation = $row['user_reputation'];
			}

			if ($reputation && ($rep_cache['num_least_respected'] = reputation_user_list('user_reputation <= ' . $reputation . ' ORDER BY user_reputation ASC', $rep_list)))
			{
				$rep_cache['least_respected'] = $rep_list;
			}
		}

		cache_set(RESPECTED_CACHE, $rep_cache);
	}

	if (!empty($SID))
	{
		// add session ids to urls (quick and dirty)
		$rep_cache['most_respected'] = str_replace('?', "?$SID&amp;", $rep_cache['most_respected']);
		$rep_cache['least_respected'] = str_replace('?', "?$SID&amp;", $rep_cache['least_respected']); // patch urls to preserve session

		// NOTE: code for custom append_sid
		// $rep_cache['respected'] = preg_replace('#(?<=href=")([^"]+)#se', 'append_sid(\'\1\')', $rep_cache['respected']);
	}

	if ($rep_cache['num_most_respected'])
	{
		$s_most_respected_users = '<br />' . (($rep_cache['num_most_respected'] == 1) ? $lang['reputation_most_respected_user'] : $lang['reputation_most_respected_users']) . $rep_cache['most_respected'];
	}

	if ($rep_cache['num_least_respected'])
	{
		$s_least_respected_users = '<br />' . (($rep_cache['num_least_respected'] == 1) ? $lang['reputation_least_respected_user'] : $lang['reputation_least_respected_users']) . $rep_cache['least_respected'];
	}
}

//
// Make a link to reported posts (for authorized ppl only)
//
if ($board_config['reports_enabled'] && ($userdata['user_level'] == ADMIN || $userdata['user_level'] == MOD))
{
	include_once($phpbb_root_path . 'includes/functions_reputation.' . $phpEx);

	if ($userdata['user_level'] != ADMIN)
	{
		$forums_auth = reputation_auth(AUTH_LIST_ALL, $userdata);
		$forums_sql = '';
		foreach ($forums_auth as $forum_id => $is_auth)
		{
			if ($is_auth['auth_mod'])
			{
				$forums_sql .= ($forums_sql ? ',' : '') . $forum_id;
			}
		}
		$forums_sql = "WHERE forum_id IN($forums_sql)";

		unset($forum_id);
	}
	else
	{
		$forums_sql = '';
	}

	//
	// Get reports count
	//
	$result = db_query('SELECT COUNT(report_id) AS num_reports FROM {POST_REPORTS_TABLE} ' . $forums_sql);
	$total_post_reports = ($row = $db->sql_fetchrow($result)) ? ('<b>' . $row['num_reports'] . '</b>') : '0';

	$link_color = '';
	$l_reported_posts = sprintf($lang['reputation_reported_posts'], $total_post_reports);
	if ($board_config['reputation_reports_color'] && $total_post_reports)
	{
		$link_color = ' style="color: #' . $board_config['reputation_reports_color'] . '"';
	}

	$u_reported_posts = '<a href="' . append_sid("post_report.$phpEx?mode=view") . '" class="gensmall"' . $link_color . '>' . $l_reported_posts . '</a><br />';
}
///////////////////////////////////////////////


#
#-----[ FIND ]------------------------------------------
#
///////democracy///////
	//
	// Make a link to reported posts (for authorized ppl only)
	//
	if ( $board_config['reputation_enable_reports'] == 1 && ( $userdata['user_level'] == ADMIN || $userdata['user_level'] == MOD || $userdata['user_level'] == GLOBAL_MOD || $userdata['user_level'] == MAIN_MOD ) )
	{
		$link_color = '';
		if ( isset($total_post_reports) )
		{
			$l_reported_posts = $lang['reputation_reported_posts'] . ': ' . ( $total_post_reports == 0 ? '0' : "<b>$total_post_reports</b>" );
			if ( $board_config['reputation_reports_color'] != '' && $total_post_reports > 0 )
			{
				$link_color = ' style="color:#' . $board_config['reputation_reports_color'] . '"';
			}
		}
		else
		{
			$l_reported_posts = $lang['reputation_view_reported_posts'];
		}
		$u_reported_posts = '<a href="' . append_sid("post_report.$phpEx?mode=view") . '" class="gensmall"' . $link_color . '>' . $l_reported_posts . '</a><br />';
	}
//////////////
#
#-----[ REPLACE WITH ]------------------------------------------
# Just remove the lines

#
#-----[ FIND ]------------------------------------------
#
		'RESPECTED_USERS' => $l_respected_user_s . $s_respected_user_s,

#
#-----[ REPLACE WITH ]------------------------------------------
#
		'MOST_RESPECTED_USERS' => $s_most_respected_users,
		'LEAST_RESPECTED_USERS' => $s_least_respected_users,

#
#-----[ OPEN ]------------------------------------------
#
profile.php
#
#-----[ FIND ]------------------------------------------
#
	else if ( $mode == 'reputation' )

#
#-----[ REPLACE WITH ]------------------------------------------
#
	else if ( $mode == 'reputation' || $mode == 'given' || $mode == 'warnings' || $mode == 'expired' )

#
#-----[ OPEN ]------------------------------------------
#
viewtopic.php
#
#-----[ FIND ]------------------------------------------
#
$sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from,

#
#-----[ IN-LINE FIND ]------------------------------------------
#
u.reputation, u.warnings

#
#-----[ IN-LINE REPLACE WITH ]------------------------------------------
#
u.user_reputation, u.user_reputation_plus, u.user_warnings

#
#-----[ FIND ]------------------------------------------
#
$postrow = array();
if ($row = $db->sql_fetchrow($result))
{

#
#-----[ AFTER, ADD ]------------------------------------------
#
	$post_ids = $row['post_id'];

#
#-----[ FIND ]------------------------------------------
#
	}
	while ($row = $db->sql_fetchrow($result));
	$db->sql_freeresult($result);

#
#-----[ BEFORE, ADD ]------------------------------------------
#
		$post_ids .= ',' . $row['post_id'];

#
#-----[ FIND ]------------------------------------------
#
////////////democracy/////////////
//
// Get ban data
//
$sql = 'SELECT ban_userid
	FROM ' . BANLIST_TABLE;
if ( !($result = $db->sql_query($sql)) )
{
	message_die(GENERAL_ERROR, "Couldn't obtain banlist information", "", __LINE__, __FILE__, $sql);
}
while ( $row = $db->sql_fetchrow($result) )
{
	$banned[$row['ban_userid']] = true;
}
/////////////////////////////////

#
#-----[ REPLACE WITH ]------------------------------------------
#
////////////democracy/////////////
if ($board_config['warnings_enabled'] || $board_config['reputation_enabled'])
{
	include($phpbb_root_path . 'includes/functions_reputation.' . $phpEx);

	$is_auth = reputation_auth($is_auth, $userdata);

	if ($board_config['warnings_enabled'])
	{
		$result = db_query('SELECT ban_userid FROM {BANLIST_TABLE}');
		while ($row = $db->sql_fetchrow($result))
		{
			$banned[$row['ban_userid']] = true;
		}

		$result = db_query('SELECT r.*, rt.*, u.username FROM {REPUTATION_TABLE} r, {REPUTATION_TEXT_TABLE} rt, {USERS_TABLE} u
			WHERE r.post_id IN (%s)
				AND r.modification IN ({REPUTATION_WARNING},{REPUTATION_BAN},{REPUTATION_WARNING_EXPIRED},{REPUTATION_BAN_EXPIRED})
				AND r.id = rt.id
				AND r.voter_id = u.user_id', $post_ids);
		while ($row = $db->sql_fetchrow($result))
		{
			$post_warnings[$row['post_id']] = $row;
		}
	}
}
/////////////////////////////////

#
#-----[ FIND ]------------------------------------------
#
	'L_GOTO_PAGE' => $lang['Goto_page'],

#
#-----[ AFTER, ADD ]------------------------------------------
#
	'L_REASON' => $lang['reputation_reason'],

#
#-----[ FIND ]------------------------------------------
#
///////////democracy////////////////
	$user_warnings = '';
	$user_reputation = '';
////////////////////////////////

#
#-----[ REPLACE WITH ]------------------------------------------
# Just remove the lines

#
#-----[ FIND ]------------------------------------------
#
	if ( $poster_id != ANONYMOUS )
	{

#
#-----[ BEFORE, ADD ]------------------------------------------
#
///////////democracy////////////////
	$user_warnings = $user_reputation = $reviews_img = $reviews = $ban_img = $ban = $warn_img = $warn = $ban_img = $ban = $reportpost_img = $reportpost = '';
////////////////////////////////


#
#-----[ FIND ]------------------------------------------
#
////////////////////////democracy//////
		if ( $board_config['reputation_enabled'] )
		{
			$thumb_up_img = '<img src="' . $images['thumb_up'] . '" alt="' . $lang['reputation_approve'] . '" title="' . $lang['reputation_approve'] . '" border="0" />';
			$thumb_dn_img = '<img src="' . $images['thumb_dn'] . '" alt="' . $lang['reputation_disapprove'] . '" title="' . $lang['reputation_disapprove'] . '" border="0" />';

			$user_reputation = '<a href="' . append_sid("profile.$phpEx?mode=reputation&amp;m=" . REPUTATION_VIEW . '&amp;' . POST_USERS_URL . '=' . $postrow[$i]['user_id'] . '&amp;view=rep') . '" title="' . $lang['reputation_view_details'] . '">' . $lang['Reputation'] . '</a>' . ': ' . $postrow[$i]['reputation'];
			if ( $postrow[$i]['user_id'] != $userdata['user_id'] && $userdata['user_id'] != ANONYMOUS )
			{
				$user_reputation .= '&nbsp;&nbsp;<a href="' . append_sid("profile.$phpEx?mode=reputation&amp;m=" . REPUTATION_INC . '&amp;' . POST_POST_URL . '=' . $postrow[$i]['post_id']) . '">' . $thumb_up_img . '</a>&nbsp;&nbsp;<a href="' . append_sid("profile.$phpEx?mode=reputation&amp;m=" . REPUTATION_DEC . '&amp;' . POST_POST_URL . '=' . $postrow[$i]['post_id']) . '">' . $thumb_dn_img . '</a><br />';
			}
		}
		if ( $board_config['warnings_enabled'] )
		{
			$warnings = $postrow[$i]['warnings'];
			if ( $banned[$postrow[$i]['user_id']] )
			{
				$user_ban = true;
				$warnings = $warnings - 1;
			}
			else
			{
				$user_ban = false;
			}

			if ( $postrow[$i]['warnings'] > 0 )
			{
				$temp_url = append_sid("profile.$phpEx?mode=reputation&amp;" . POST_USERS_URL . '=' . $postrow[$i]['user_id'] . '&amp;m=' . REPUTATION_VIEW . '&amp;view=warn');
				$user_warnings = '<a href="' . $temp_url . '" title="' . sprintf($lang['reputation_warnings_to'], $poster) . '">';

				for ($k = 0; $k < $warnings; $k++ )
				{
					$user_warnings .= '<img src="' . $images['user_warning'] . '" alt="' . $lang['reputation_warning'] . '" border="0" />';
				}
				if ( $user_ban )
				{
					$user_warnings .= '<img src="' . $images['user_ban'] . '" alt="' . $lang['reputation_ban'] . '" border="0" />';
				}
				$user_warnings .= '</a>';
			}
		}
		if ( ( $board_config['warnings_enabled'] || $board_config['reputation_enabled'] ) && $postrow[$i]['post_reviews'] > 0 )
		{
			$temp_url = append_sid("profile.$phpEx?mode=reputation&amp;m=" . REPUTATION_VIEW . '&' . POST_POST_URL . '=' . $postrow[$i]['post_id']);
			$post_reviews = sprintf($lang['reputation_view_reviews'], $postrow[$i]['post_reviews']);
			$reviews_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_reviews'] . '" alt="' . $post_reviews . '" title="' . $post_reviews . '" border="0" /></a>';
			$reviews = '<a href="' . $temp_url . '" title="' . $post_reviews . '">' . $lang['Reviews'] . '</a>';
		}
		else
		{
			$reviews_img = '';
			$reviews = '';
		}
////////////////////////////


#
#-----[ REPLACE WITH ]------------------------------------------
# Just remove the lines

#
#-----[ FIND ]------------------------------------------
#
/////////////democracy////////////////////
		if ( $board_config['warnings_enabled'] )
		{
			if ( $userdata['user_id'] != $postrow[$i]['user_id'] && $postrow[$i]['user_level'] != ADMIN && $postrow[$i]['user_level'] != MOD && $postrow[$i]['user_level'] != GLOBAL_MOD && $postrow[$i]['user_level'] != MAIN_MOD && $is_auth['auth_mod'] )
			{
				$temp_url = "profile.$phpEx?mode=reputation&amp;m=" . REPUTATION_WARNING . "&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&amp;sid=" . $userdata['session_id'];
				$warn_img = '<a href="' . $temp_url . '"><img src="' . $images['warn_user'] . '" alt="' . $lang['reputation_warn_user'] . '" title="' . $lang['reputation_warn_user'] . '" border="0" /></a>';
				$warn = '<a href="' . $temp_url . '">' . $lang['reputation_warn_user'] . '</a>';

				if ( $board_config['reputation_moderators_can_ban'] == 1 )
				{
					$temp_url = "profile.$phpEx?mode=reputation&amp;m=" . REPUTATION_BAN . "&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&amp;sid=" . $userdata['session_id'];
					$ban_img = '<a href="' . $temp_url . '"><img src="' . $images['ban_user'] . '" alt="' . $lang['reputation_ban_user'] . '" title="' . $lang['reputation_ban_user'] . '" border="0" /></a>';
					$ban = '<a href="' . $temp_url . '">' . $lang['reputation_ban_user'] . '</a>';
				}
				else
				{
					$ban_img = '';
					$ban = '';
				}
			}
			else
			{
				$warn_img = '';
				$warn = '';
				$ban_img = '';
				$ban = '';
			}
		}
/////////////////////////////////////////

#
#-----[ REPLACE WITH ]------------------------------------------
#
/////////////democracy////////////////////
		if ($board_config['reputation_enabled'])
		{
			$personal_auth = reputation_auth($is_auth, $userdata, $postrow[$i], true);

			$user_reputation = reputation_display($postrow[$i], $personal_auth, true);

			if ($postrow[$i]['post_reviews'])
			{
				$temp_url = append_sid("profile.$phpEx?mode=reputation&amp;" . POST_POST_URL . '=' . $postrow[$i]['post_id']);
				$post_reviews = sprintf($lang['reputation_view_reviews'], $postrow[$i]['post_reviews']);
				$reviews_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_reviews'] . '" alt="' . $post_reviews . '" title="' . $post_reviews . '" border="0" /></a>';
				$reviews = '<a href="' . $temp_url . '" title="' . $post_reviews . '">' . $lang['Reviews'] . '</a>';
			}
		}
		if ($board_config['warnings_enabled'])
		{
			$personal_auth = reputation_auth($is_auth, $userdata, $postrow[$i], true);

			$user_warnings = reputation_warnings($postrow[$i], !empty($banned[$poster_id]), $personal_auth);

			if (!isset($post_warnings[$postrow[$i]['post_id']]))
			{
				if ($personal_auth['auth_warn'])
				{
					$temp_url = "reputation.$phpEx?mode=warning&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&amp;sid=" . $userdata['session_id'];
					$warn_img = '<a href="' . $temp_url . '"><img src="' . $images['warn_user'] . '" alt="' . $lang['reputation_warn_user'] . '" title="' . $lang['reputation_warn_user'] . '" border="0" /></a>';
					$warn = '<a href="' . $temp_url . '">' . $lang['reputation_warn'] . '</a>';
				}

				if ($personal_auth['auth_ban'])
				{
					$temp_url = "reputation.$phpEx?mode=ban&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&amp;sid=" . $userdata['session_id'];
					$ban_img = '<a href="' . $temp_url . '"><img src="' . $images['ban_user'] . '" alt="' . $lang['reputation_ban_user'] . '" title="' . $lang['reputation_ban_user'] . '" border="0" /></a>';
					$ban = '<a href="' . $temp_url . '">' . $lang['reputation_ban'] . '</a>';
				}
			}
		}
/////////////////////////////////////////

#
#-----[ FIND ]------------------------------------------
#
		$reviews_img = '';    //////         //////
		$reviews = '';       //////democracy//////

#
#-----[ REPLACE WITH ]------------------------------------------
# Just remove the lines

#
#-----[ FIND ]------------------------------------------
#
/////////////democracy////////////////////
		if ( $board_config['reputation_enable_reports'] )
		{
			if( $userdata['user_id'] != ANONYMOUS )
			{
				$temp_url = "post_report.$phpEx?mode=report&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&amp;sid=" . $userdata['session_id'];
				$reportpost_img = '<a href="' . $temp_url . '"><img src="' . $images['report_post'] . '" alt="' . $lang['reputation_report_post'] . '" title="' . $lang['reputation_report_post'] . '" border="0" /></a>';
				$reportpost = '<a href="' . $temp_url . '">' . $lang['reputation_report_post'] . '</a>';
			}
		}
///////////////////////////////////////////

#
#-----[ REPLACE WITH ]------------------------------------------
#
/////////////democracy////////////////////
		if ($board_config['reports_enabled'])
		{
			if ($userdata['user_id'] != ANONYMOUS)
			{
				$temp_url = "post_report.$phpEx?mode=report&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&amp;sid=" . $userdata['session_id'];
				$reportpost_img = '<a href="' . $temp_url . '"><img src="' . $images['report_post'] . '" alt="' . $lang['reputation_report_post'] . '" title="' . $lang['reputation_report_post'] . '" border="0" /></a>';
				$reportpost = '<a href="' . $temp_url . '">' . $lang['reputation_report_post'] . '</a>';
			}
		}
///////////////////////////////////////////

#
#-----[ FIND ]------------------------------------------
#
		'POSTER_WARNINGS' => empty($user_warnings) ? '' : $user_warnings,

#
#-----[ REPLACE WITH ]------------------------------------------
#
		'POSTER_WARNINGS' => $user_warnings,

#
#-----[ FIND ]------------------------------------------
#
		'U_MINI_POST' => $mini_post_url,
		'U_POST_ID' => $postrow[$i]['post_id'])
	);

#
#-----[ AFTER, ADD ]------------------------------------------
#
	if (isset($post_warnings[$postrow[$i]['post_id']]))
	{
		$template->assign_block_vars('postrow.warning', reputation_warning_tpl($post_warnings[$postrow[$i]['post_id']]));
	}

#
#-----[ OPEN ]------------------------------------------
#
includes/constants.php
#
#-----[ FIND ]------------------------------------------
#
///////////////democracy/////////////////////
define('REPUTATION_TABLE', $table_prefix.'reputation');
define('REPUTATION_TEXT_TABLE', $table_prefix.'reputation_text');
define('POST_REPORTS_TABLE', $table_prefix.'post_reports');

// reputation modes definition
define('REPUTATION_VIEW', 0);
define('REPUTATION_INC', 1);
define('REPUTATION_DEC', 2);
define('REPUTATION_WARNING', 3);
define('REPUTATION_BAN', 4);
define('REPUTATION_EDIT', 5);
define('REPUTATION_DELETE', 6);
define('REPUTATION_WARNING_EXPIRED', 7);
define('REPUTATION_BAN_EXPIRED', 8);

define('POST_REVIEWS_URL', 'r');

define('REPUTATION_MODE_FULL', 4);
define('REPUTATION_MODE_REPUTATION', 3);
define('REPUTATION_MODE_WARNINGS', 2);
define('REPUTATION_MODE_NONE', 1);
////////////////////////////////////////////

#
#-----[ REPLACE WITH ]------------------------------------------
#
///////////////democracy/////////////////////
define('REPUTATION_TABLE', $table_prefix.'reputation');
define('REPUTATION_TEXT_TABLE', $table_prefix.'reputation_text');
define('POST_REPORTS_TABLE', $table_prefix.'post_reports');

// reputation modifications
define('REPUTATION_INC', 1);
define('REPUTATION_DEC', 2);
define('REPUTATION_WARNING', 3);
define('REPUTATION_BAN', 4);
define('REPUTATION_WARNING_EXPIRED', 7);
define('REPUTATION_BAN_EXPIRED', 8);

// display modes (more to come)
define('REPUTATION_SUM', 0);
define('REPUTATION_PLUSMINUS', 1);

define('POST_REVIEWS_URL', 'r');
define('RESPECTED_CACHE', 'respected.dat');
define('NO_ID', -1);
////////////////////////////////////////////

#
#-----[ OPEN ]------------------------------------------
#
includes/functions.php
#
#-----[ FIND ]------------------------------------------
#
	exit;
}

#
#-----[ AFTER, ADD ]------------------------------------------
#
/////////////democracy////////
/**
 * This is sprintf-like $db->sql_query() wrapper with automatic constants and variables substitution.
 * Idea and some code are borrowed from drupal.
 * Example:
 * $result = db_query('SELECT * FROM {POSTS_TABLE} WHERE id = %d OR name LIKE \'%s\'', 10, '\\StupidUserName/');
 *
 * @return resource Database query result
 */
function db_query($sql)
{
	global $db;

	$sql = preg_replace_callback('#{(\w+)}#', 'const_subst', $sql); // substitute constants

	if (func_num_args() > 1)
	{
		$args = func_get_args();
		$args = array_map('addslashes', $args);
		$args[0] = $sql;
		$sql = call_user_func_array('sprintf', $args);
	}

	if ($result = $db->sql_query($sql))
	{
		return $result;
	}
	else
	{
		message_die(GENERAL_ERROR, 'SQL query failed', '', __LINE__, __FILE__, $sql);
	}
}

/**
 * Used in db_query with preg_replace_callback to avoid dynamic code.
 * @access private
 */
function const_subst($match)
{
	return constant($match[1]);
}

/**
 * Begins or ends transaction
 * @param integer $command Specify BEGIN_TRANSACTION or END_TRANASCTION
 */
function db_transaction($command)
{
	global $db;

	$db->sql_query('SELECT 0', $command); // DBAL requires non-empty query to issue transaction command.
}
//////////////////////////////

#
#-----[ OPEN ]------------------------------------------
#
includes/functions_admin.php
#
#-----[ FIND ]------------------------------------------
#
			{
				message_die(GENERAL_ERROR, 'Could not update forum', '', __LINE__, __FILE__, $sql);
			}

#
#-----[ AFTER, ADD ]------------------------------------------
#
/////////democracy///////////////
			global $board_config;

			if ($board_config['reputation_enabled'] || $board_config['warnings_enabled'])
			{
				$result = db_query('SELECT r.id, r.forum_id AS review_forum_id, p.post_id, p.forum_id AS post_forum_id
					FROM {REPUTATION_TABLE} r LEFT JOIN {POSTS_TABLE} p ON r.post_id = p.post_id
					WHERE r.forum_id = %d
						AND (p.forum_id <> r.forum_id OR (r.post_id <> {NO_ID} AND p.post_id IS NULL))', $id);

				$no_post = ''; $wrong_forum = array();

				while ($row = $db->sql_fetchrow($result))
				{
					if (!$row['post_id'])
					{
						$no_post .= ($no_post ? ',' : '') . $row['id'];
					}
					elseif ($row['review_forum_id'] != $row['post_forum_id'])
					{
						if (isset($wrong_forum[$row['post_forum_id']]))
						{
							$wrong_forum[$row['post_forum_id']] .= ',' . $row['id'];
						}
						else
						{
							$wrong_forum[$row['post_forum_id']] = $row['id'];
						}
					}
				}

				if ($no_post)
				{
					db_query('UPDATE {REPUTATION_TABLE} SET post_id = {NO_ID} WHERE id IN(%s)', $no_post);
				}
				foreach ($wrong_forum as $forum_id => $review_ids)
				{
					db_query('UPDATE {REPUTATION_TABLE} SET forum_id = %d WHERE id IN(%s)', $forum_id, $review_ids);
				}
			}
/////////////////////////////

#
#-----[ OPEN ]------------------------------------------
#
includes/functions_post.php
#
#-----[ FIND ]------------------------------------------
#
	if ( $mode == 'editpost' && $post_data['poster_id'] != $userdata['user_id'] )

#
#-----[ REPLACE WITH ]------------------------------------------
#
	if ($mode == 'editpost' && $post_data['poster_id'] != $userdata['user_id'])

#
#-----[ FIND ]------------------------------------------
#
		$sql = 'UPDATE ' . POSTS_TABLE . '
			SET post_locked = ' . $post_data['post_locked'] . '
			WHERE post_id = ' . $post_id;
		if (!$db->sql_query($sql))
		{
			message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql);
		}

#
#-----[ REPLACE WITH ]------------------------------------------
#
		db_query('UPDATE {POSTS_TABLE} SET post_locked = %d WHERE post_id = %d', $post_data['post_locked'], $post_id);

#
#-----[ FIND ]------------------------------------------
#
		$sql = "UPDATE " . REPUTATION_TABLE . "
			SET post_id = -1
			WHERE post_id = $post_id";
		if (!$db->sql_query($sql))
		{
			message_die(GENERAL_ERROR, 'Error in deleting post references', '', __LINE__, __FILE__, $sql);
		}

#
#-----[ REPLACE WITH ]------------------------------------------
#
		db_query('UPDATE {REPUTATION_TABLE} SET post_id = {NO_ID} WHERE post_id = %d', $post_id);
		db_query('DELETE FROM {POST_REPORTS_TABLE} WHERE post_id = %d', $post_id);

#
#-----[ OPEN ]------------------------------------------
#
includes/page_header.php
#
#-----[ FIND ]------------------------------------------
#
//////////////////democracy///////////////////////////////////
//
// Check for expired warnings and bans
//
$current_time = time();

if ( $board_config['reputation_last_check_time'] + $board_config['reputation_check_rate'] < $current_time )
{
   $sql = 'SELECT id, user_id, modification FROM ' . REPUTATION_TABLE . '
           WHERE (modification = ' . REPUTATION_WARNING . ' OR modification = ' . REPUTATION_BAN . ")
            AND expire < $current_time";
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Couldn\'t select from rep table', '', __LINE__, __FILE__, $sql);
	}
    while ($row = $db->sql_fetchrow($result))
    {
		if ( $board_config['reputation_delete_expired'] == 1 )
		{
			$sql = 'DELETE FROM ' . REPUTATION_TABLE . '
					WHERE id = ' . $row['id'];
			if ( !$db->sql_query($sql) )
			{
				message_die(GENERAL_ERROR, 'Couldn\'t delete expired warnings', '', __LINE__, __FILE__, $sql);
			}
			$sql = 'DELETE FROM ' . REPUTATION_TEXT_TABLE . '
					WHERE id = ' . $row['id'];
			if ( !$db->sql_query($sql) )
			{
				message_die(GENERAL_ERROR, 'Couldn\'t delete expired warnings', '', __LINE__, __FILE__, $sql);
			}
		}
		else
		{
			if ( $row['modification'] == REPUTATION_WARNING )
			{
				$set = REPUTATION_WARNING_EXPIRED;
			}
			else
			{
				$set = REPUTATION_BAN_EXPIRED;
			}
			$sql = 'UPDATE ' . REPUTATION_TABLE . '
				SET modification = ' . $set . '
				WHERE id = ' . $row['id'];
			if ( !$db->sql_query($sql) )
			{
				message_die(GENERAL_ERROR, 'Couldn\'t cancel expired warnings', '', __LINE__, __FILE__, $sql);
			}
		}
		if ( $row['modification'] == REPUTATION_BAN )
		{
			$sql = 'DELETE FROM ' . BANLIST_TABLE . "
				WHERE ban_userid = '" . $row['user_id'] . "'";
			if ( !$db->sql_query($sql) )
			{
				message_die(GENERAL_ERROR, "Couldn't obtain banlist information", "", __LINE__, __FILE__, $sql);
			}
		}
		$sql = 'UPDATE ' . USERS_TABLE . '
			SET warnings = warnings - 1
			WHERE user_id = ' . $row['user_id'];
		if ( !$db->sql_query($sql) )
		{
			message_die(CRITICAL_ERROR, "Could not update user rep.", '', __LINE__, __FILE__, $sql);
		}
	}
	//
	// Save last check time
	//
	$sql = "UPDATE " . CONFIG_TABLE . " SET
		config_value = $current_time
		WHERE config_name = 'reputation_last_check_time'";
	if( !$db->sql_query($sql) )
	{
		message_die(GENERAL_ERROR, "Failed to update board settings", "", __LINE__, __FILE__, $sql);
	}
}
/////////////////////////////////

#
#-----[ REPLACE WITH ]------------------------------------------
#
//////////////////democracy///////////////////////////////////
//
// Check for expired warnings and bans
//
$current_time = time();

if ($board_config['reputation_last_check_time'] + $board_config['reputation_check_rate'] * 60 < $current_time)
{
	if ($board_config['reputation_delete_expired'] != -1)
	{
		$delete_time = $current_time - $board_config['reputation_delete_expired'] * 86400;
//		switch (SQL_LAYER)
//		{
//			case 'mysql4':
//				db_query('DELETE r, rt FROM {REPUTATION_TABLE} r, {REPUTATION_TEXT_TABLE} rt
//					WHERE r.id = rt.id
//						AND (r.modification = {REPUTATION_WARNING_EXPIRED} OR r.modification = {REPUTATION_BAN_EXPIRED})
//						AND r.expire < %d', $delete_time); // QUESTION: expire value storage
//				break;
//			default:
				$result = db_query('SELECT id
					FROM {REPUTATION_TABLE}
					WHERE (modification = {REPUTATION_WARNING_EXPIRED} OR modification = {REPUTATION_BAN_EXPIRED})
						AND expire < %d', $delete_time);

				$in_sql = '';
				while ($row = $db->sql_fetchrow($result))
				{
					$in_sql .= ($in_sql ? ',' : '') . $row['id'];
				}
				if ($in_sql)
				{
					db_query('DELETE FROM {REPUTATION_TABLE}
						WHERE id IN (' . $in_sql . ')');
					db_query('DELETE FROM {REPUTATION_TEXT_TABLE}
						WHERE id IN (' . $in_sql . ')');
				}
//				break;
//		}
	}
	else
	{
		$delete_time = -1;
	}

	$result = db_query('SELECT id, user_id, modification FROM {REPUTATION_TABLE}
			WHERE (modification = {REPUTATION_WARNING} OR modification = {REPUTATION_BAN})
				AND expire < %d', $current_time);

	while ($row = $db->sql_fetchrow($result))
	{
		if ($delete_time != -1 && $row['expire'] < $delete_time)
		{
			db_query('DELETE FROM {REPUTATION_TABLE} WHERE id = ' . $row['id']);
			db_query('DELETE FROM {REPUTATION_TEXT_TABLE} WHERE id = ' . $row['id']);
		}
		else
		{
			$set = ($row['modification'] == REPUTATION_WARNING) ? REPUTATION_WARNING_EXPIRED : REPUTATION_BAN_EXPIRED;
			db_query('UPDATE {REPUTATION_TABLE} SET modification = %d WHERE id = %d', $set, $row['id']);
		}
		if ($row['modification'] == REPUTATION_BAN)
		{
			db_query('DELETE FROM {BANLIST_TABLE} WHERE ban_userid = %d', $row['user_id']);
		}
		db_query('UPDATE {USERS_TABLE} SET user_warnings = user_warnings - 1 WHERE user_id = %d', $row['user_id']);
	}

	db_query('UPDATE {CONFIG_TABLE} SET config_value = %d WHERE config_name = \'reputation_last_check_time\'', $current_time);
}
/////////////////////////////////

#
#-----[ OPEN ]------------------------------------------
#
includes/usercp_viewprofile.php
#
#-----[ FIND ]------------------------------------------
#
/////democracy///////////////////
if ( $board_config['warnings_enabled'] )
{
	$template->assign_block_vars('warnings', array(
		'U_VIEW_WARNINGS' => append_sid("profile.$phpEx?mode=reputation&amp;m=" . REPUTATION_VIEW . '&amp;' . POST_USERS_URL . '=' . $profiledata['user_id'] . '&amp;view=warn'),
		'WARNINGS' => $profiledata['warnings'],
	));
}
if ( $board_config['reputation_enabled'] )
{
	$template->assign_block_vars('reputation', array(
		'U_VIEW_REPUTATION' => append_sid("profile.$phpEx?mode=reputation&amp;m=" . REPUTATION_VIEW . '&amp;' . POST_USERS_URL . '=' . $profiledata['user_id'] . '&amp;view=rep'),
		'REPUTATION' => $profiledata['reputation'],
	));
}

///////////////////////////////////

#
#-----[ REPLACE WITH ]------------------------------------------
#
/////democracy///////////////////
if ($board_config['warnings_enabled'] || $board_config['reputation_enabled'])
{
	include($phpbb_root_path . 'includes/functions_reputation.' . $phpEx);

	$is_auth = reputation_auth(NO_ID, $userdata, $profiledata);

	if ($board_config['warnings_enabled'] && !$is_auth['no_warn'])
	{
		$warn_img = $warn = $ban_img = $ban = '';

		if ($is_auth['auth_warn'])
		{
			$temp_url = "reputation.$phpEx?mode=warning&amp;" . POST_USERS_URL . "=" . $profiledata['user_id'] . "&amp;sid=" . $userdata['session_id'];
			$warn_img = '<a href="' . $temp_url . '"><img src="' . $images['warn_user'] . '" alt="' . $lang['reputation_warn_user'] . '" title="' . $lang['reputation_warn_user'] . '" border="0" /></a>';
			$warn = '<a href="' . $temp_url . '">' . $lang['reputation_warn'] . '</a>';
		}
		if ($is_auth['auth_ban'])
		{
			$temp_url = "reputation.$phpEx?mode=ban&amp;" . POST_USERS_URL . "=" . $profiledata['user_id'] . "&amp;sid=" . $userdata['session_id'];
			$ban_img = '<a href="' . $temp_url . '"><img src="' . $images['ban_user'] . '" alt="' . $lang['reputation_ban_user'] . '" title="' . $lang['reputation_ban_user'] . '" border="0" /></a>';
			$ban = '<a href="' . $temp_url . '">' . $lang['reputation_ban'] . '</a>';
		}

		$template->assign_block_vars('warnings', array(
			'L_WARNINGS' => $lang['Warnings'],
			'WARNINGS' => $profiledata['user_warnings'],

			'RED' => $ban,
			'RED_IMG' => $ban_img,
			'YELLOW' => $warn,
			'YELLOW_IMG' => $warn_img,
		));

		if ($is_auth['auth_view_warns'] && $profiledata['user_warnings'])
		{
			$template->assign_block_vars('warnings.details', array(
				'U_SEARCH' => append_sid("profile.$phpEx?mode=warnings&amp;" . POST_USERS_URL . '=' . $profiledata['user_id']),
				'L_SEARCH' => sprintf($lang['reputation_search_warnings'], $profiledata['username']),
			));
		}
	}
	if ($board_config['reputation_enabled'] && !$is_auth['no_rep'])
	{
		$template->assign_block_vars('reputation', array(
			'L_REPUTATION' => $lang['Reputation'],
			'U_VIEW_REPUTATION' => append_sid("profile.$phpEx?mode=reputation&amp;" . POST_USERS_URL . '=' . $profiledata['user_id']),
			'REPUTATION' => reputation_display($profiledata, $is_auth, false),
		));

		if ($is_auth['auth_view_rep'] && ($profiledata['user_reputation'] || $profiledata['user_reputation_plus']))
		{
			$template->assign_block_vars('reputation.details', array(
				'U_SEARCH' => append_sid("profile.$phpEx?mode=reputation&amp;" . POST_USERS_URL . '=' . $profiledata['user_id']),
				'L_SEARCH' => sprintf($lang['reputation_search_reputation'], $profiledata['username']),
			));
		}
	}
}
///////////////////////////////////

#
#-----[ FIND ]------------------------------------------
#
	'L_WARNINGS' => $lang['Warnings'],
	'L_REPUTATION' => $lang['Reputation'],
	'L_VIEW_DETAILS' => $lang['reputation_view_details'],

#
#-----[ REPLACE WITH ]------------------------------------------
# Just remove the lines

#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_admin.php
#
#-----[ FIND ]------------------------------------------
#
$lang['reputation_board_mode'] =
$lang['reputation_board_mode_exp'] =
$lang['reputation_mode_1'] =
$lang['reputation_mode_2'] =
$lang['reputation_mode_3'] =
$lang['reputation_mode_4'] =
$lang['reputation_select_mode'] =
$lang['reputation_mode_1_exp'] =
$lang['reputation_mode_2_exp'] =
$lang['reputation_mode_3_exp'] =
$lang['reputation_mode_4_exp'] =
$lang['reputation_gen_options'] =
$lang['reputation_reputation_options'] =
$lang['reputation_warnings_options'] =
$lang['reputation_app_to'] =
$lang['reputation_anonymous_view'] =
$lang['reputation_anonymous_view_exp'] =
$lang['reputation_enable_reports'] =
$lang['reputation_enable_reports_exp'] =
$lang['reputation_check_reports'] =
$lang['reputation_check_reports_exp'] =
$lang['reputation_reports_color'] =
$lang['reputation_reports_color_exp'] =
$lang['reputation_reports_per_page'] =
$lang['reputation_reviews_per_page'] =
$lang['reputation_reviews_per_page_exp'] =
$lang['reputation_users_can_edit'] =
$lang['reputation_users_can_delete'] =
$lang['reputation_moders_can_ban'] =
$lang['reputation_moders_can_ban_exp'] =
$lang['reputation_expire_enabled'] =
$lang['reputation_expire_default'] =
$lang['reputation_expire_min'] =
$lang['reputation_expire_max'] =
$lang['reputation_ban_expire_enabled'] =
$lang['reputation_ban_expire_default'] =
$lang['reputation_ban_expire_min'] =
$lang['reputation_ban_expire_max'] =
$lang['reputation_check_rate'] =
$lang['reputation_check_rate_exp'] =
$lang['reputation_check_rate_hint'] =
$lang['reputation_expired_warnings'] =
$lang['reputation_delete'] =
$lang['reputation_mark_expired'] =
$lang['reputation_auto_ban'] =
$lang['reputation_auto_ban_exp'] =
$lang['reputation_num_warnings'] =
$lang['reputation_check_confirm'] =
$lang['Click_return_reputation_index'] =

#
#-----[ REPLACE WITH ]------------------------------------------
#
$lang = array(
	'reputation_democracy' => 'Democracy',
	'reputation_democracy_exp' => 'Democracy combines the features of warnings system, ban manager, karma (reputation) and post reports.',
	'reputation_enable' => 'Enable reputation',
	'reputation_enable_warnings' => 'Enable warnings and bans',
	'reports_enabled' => 'Enable Report Post button',
	'reputation_positive_only' => 'Positive reviews only',
	'reputation_positive_only_exp' => 'Make only positive reviews possible. Hide (not delete!) negative reviews and do not count them when summing reputation points.',
	'reputation_empty_reviews' => 'Allow reviews without comments (make comment field optional)',
	'reputation_reputation_options' => 'Reputation options',
	'reputation_warnings_options' => 'Warnings options',
	'reputation_reports_options' => 'Post report options',
	'Click_return_reputation_index' => 'Click %sHere%s to return to Democracy configuration',

	'reputation_access_rights' => 'Access rights',
	'reputation_add_rep' => 'Change reputation',
	'reputation_add_rep_nonpost' => 'Change reputation without referring to a specific post',
	'reputation_edit_rep' => 'Edit reputation reviews',
	'reputation_delete_rep' => 'Delete reputation reviews',
	'reputation_no_limits' => 'Requirements do not apply',
	'reputation_warn' => 'Give warnings',
	'reputation_warn_nonpost' => 'Give warnings without referring to a specific post',
	'reputation_ban' => 'Ban users',
	'reputation_ban_nonpost' => 'Ban users without referring to a specific post',
	'reputation_edit_warns' => 'Edit warnings and bans',
	'reputation_delete_warns' => 'Delete warnings and bans',
	'reputation_not_applicable' => 'Don\'t have reputation at all',
	'reputation_anonymous_view_rep' => 'Anonymous users can read reviews pages.',
	'reputation_anonymous_view_warns' => 'Anonymous users can read warnings and bans pages.',
	'reputation_perms_notes' => '* = only his/her own<br />** = only in the forums where he/she is moderator.',
	'reputation_warn_perms_notes' => '* = only in the forums where he/she is moderator.',

	'reputation_days_req' => 'At least %s days of registration.',
	'reputation_posts_req' => 'At least %s posts.',
	'reputation_warnings_req' => 'At most %s unexpired warnings.',
	'reputation_points_req' => 'At least %s reputation points.',
	'reputation_time_limit' => 'User cannot change reputation of the same member more than once in %s minutes.',
	'reputation_rotation_limit' => 'Reputation user spread: %s users.',
	'reputation_rotation_limit_exp' => 'This setting dictates how many unique members that a user must rate before they are able to rate the same member twice.',
	'reputation_most_respected' => 'Show %s most respected users.',
	'reputation_least_respected' => 'Show %s least respected users.',
	'reputation_display' => 'Reputation display',
	'reputation_display_sum' => 'Single number (sum)',
	'reputation_display_plusminus' => 'Positive and negative separated (+2/-3)',

	'reputation_infinite' => 'Infinite',
	'reputation_infinite_exp' => 'Moderators should expire or delete warnings manually.',
	'reputation_infinite_ban_exp' => 'Moderators should expire or delete bans manually.',
	'reputation_fixed' => 'Fixed: %s days.',
	'reputation_modifiable' => 'Can be chosen by moderator between %s and %s days.',
	'reputation_modifiable_exp' => 'Leave the fields blank not to put restrictions.',
	'reputation_store' => 'Mark as expired and store',
	'reputation_delete_days' => 'Mark as expired and delete after %s days.',
	'reputation_ban_warnings' => 'Users will get banned after receiving %s active warnings.',
	'reputation_ban_warnings_exp' => 'When this option is enabled, the last warning will just turn into ban.',
	'reputation_check_rate' => 'Expired warnings and bans check rate: %s minutes.',
	'reputation_check_rate_exp' => 'Manipulate delay between checkups to reduce the workload.',

	'reputation_check_confirm' => 'Please confirm your intention to change settings by checking the appropriate checkbox!',

	'reputation_reports_color' => 'Color used to distinguish the link to reports page:',
	'reputation_reports_color_exp' => 'If there are any reports. Leave blank if you don\'t want the link to have different color.',

	'reputation_warning_expiry' => 'Warnings expiration',
	'reputation_ban_expiry' => 'Bans expiration',
	'reputation_expired_warnings' => 'Expired warnings and bans',
	'reputation_index_page' => 'Index page',
	'reputation_prerequirements' => 'Requirements to the user changing reputation',
	'reputation_limits' => 'Other requirements',

	'reputation_maintenance' => 'Maintenance',
	'reputation_resync' => 'Ensure data integrity between users, posts and reputation table.',
	'reputation_resync_exp' => 'Use this when user\'s reputation or warnings don\'t match actual number of reviews.',
	'reputation_success' => 'Operation completed successfully.',

	/*
	'reputation_reports_per_page' => 'Reports per page',
	'reputation_reviews_per_page' => 'Reputation reviews per page',
	'reputation_allow_empty_warns' => 'Allow warnings without the reason specified.',
	*/
) + $lang;

#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_main.php
#
#-----[ FIND ]------------------------------------------
#
$lang['Reputation'] =
$lang['Warnings'] =
$lang['Reason'] =
$lang['Warning'] =
$lang['New_warning'] =
$lang['Post_Reports'] =
$lang['Review'] =
$lang['Reviews'] =
$lang['New_review'] =
$lang['Official'] =
$lang['Display'] =
$lang['User'] =
$lang['Edit'] =
$lang['Post_locked'] =
$lang['reputation_days'] =
$lang['reputation_seconds'] =
$lang['reputation_and'] =
$lang['reputation_expire_hint_inf'] =
$lang['reputation_lock_post'] =
$lang['reputation_for'] =
$lang['reputation_from'] =
$lang['reputation_to'] =
$lang['reputation_approve'] =
$lang['reputation_approved'] =
$lang['reputation_disapprove'] =
$lang['reputation_disapproved'] =
$lang['reputation_post_ref'] =
$lang['reputation_post_reviews'] =
$lang['reputation_post_was_deleted'] =
$lang['reputation_warning_issued'] =
$lang['reputation_total'] =
$lang['reputation_issued'] =
$lang['reputation_expire'] =
$lang['reputation_expired'] =
$lang['reputation_never'] =
$lang['reputation_warning'] =
$lang['reputation_ban'] =
$lang['reputation_description'] =
$lang['reputation_edit_review'] =
$lang['reputation_delete_review'] =
$lang['reputation_warnings_to'] =
$lang['reputation_reviewed'] =
$lang['reputation_actions'] =
$lang['reputation_order_by'] =
$lang['reputation_post_peports_exp'] =
$lang['reputation_report_date'] =
$lang['reputation_reports_number'] =
$lang['reputation_first_reported'] =
$lang['reputation_of'] =
$lang['reputation_view_details'] =
$lang['reputation_warn_user'] =
$lang['reputation_ban_user'] =
$lang['reputation_view_reviews'] =
$lang['reputation_report_post'] =
$lang['reputation_report'] =
$lang['reputation_report_success'] =
$lang['reputation_view_reported_posts'] =
$lang['reputation_reported_posts'] =
$lang['reputation_modify'] =
$lang['reputation_give_warning'] =
$lang['reputation_user'] =
$lang['reputation_display_expired'] =
$lang['reputation_expire_never'] =
$lang['reputation_expire_after'] =
$lang['reputation_expire_hint'] =
$lang['reputation_warning_expired'] =
$lang['reputation_warnings_expired'] =
$lang['reputation_most_respected_user'] =
$lang['reputation_most_respected_users'] =
$lang['reputation_note_cant_edit'] =
$lang['reputation_note_can_edit'] =
$lang['reputation_self_no_modify'] =
$lang['reputation_anonymous_no_reputation'] =
$lang['reputation_anonymous_no_reviews'] =
$lang['reputation_already_voted'] =
$lang['reputation_cant_warn_mods'] =
$lang['reputation_no_comments_entered'] =
$lang['reputation_no_post_spec'] =
$lang['reputation_no_user_spec'] =
$lang['reputation_no_review_spec'] =
$lang['reputation_update_successfull'] =
$lang['reputation_sorry_auth_view'] =
$lang['reputation_warning_successfull'] =
$lang['reputation_this_post_reviews'] =
$lang['reputation_deleted_no_edit'] =
$lang['reputation_no_reviews'] =
$lang['reputation_no_details'] =
$lang['reputation_last_warning_issued'] =
$lang['reputation_already_warned'] =
$lang['reputation_already_banned'] =
$lang['reputation_msg_view_warning'] =
$lang['reputation_msg_delete_report'] =
$lang['reputation_msg_view_profile'] =
$lang['reputation_msg_back_to_topic'] =
$lang['reputation_msg_back_to_reviews'] =
$lang['reputation_msg_view_your_review'] =
$lang['reputation_confirm_delete'] =
$lang['reputation_delete_success'] =
$lang['reputation_no_expire_entered'] =
$lang['reputation_confirm_report'] =
$lang['reputation_confirm_report2'] =
$lang['reputation_mail_warning'] =
$lang['reputation_mail_ban'] =
$lang['reputation_report_deleted'] =
$lang['reputation_msg_back_to_reports'] =

#
#-----[ REPLACE WITH ]------------------------------------------
#
$lang = array(
	// general & misc
	'Reputation' => 'Reputation',
	'Warnings' => 'Warnings',
	'Warning' => 'Warning',
	'reputation_display' => 'Display',
	'reputation_banned_permanently' => 'Banned permanently',

	// index page
	'reputation_reported_posts' => 'Posts reported by users: %s',
	'reputation_most_respected_user' => 'Our most respected user is ',
	'reputation_most_respected_users' => 'Our most respected users are ',
	'reputation_least_respected_user' => 'Our least respected user is ',
	'reputation_least_respected_users' => 'Our least respected users are ',

	// viewing reviews
	'New_warning' => 'New warning',
	'New_review' => 'New review',
	'Post_Reports' => 'Post Reports',
	'Review' => 'Review',
	'Official' => 'Review', // i.e. Moderator
	'reputation_of' => 'Reputation of %s',
	'reputation_warnings_to' => 'Warnings given to %s',
	'reputation_warnings_expired' =>  'Expired warnings given to %s',
	'reputation_display_expired' => 'Show expired warnings',
	'reputation_post_ref' => 'Post reference',
	'reputation_post_reviews' => 'Post reviews',
	'reputation_post_deleted' => 'Deleted',
	'reputation_total' => 'Total',
	'reputation_issued' => 'Issued',
	'Edit' => 'Edit',
	'reputation_edit_review' => 'Edit review',
	'reputation_delete_review' => 'Delete review',

	// viewing reports
	'reputation_actions' => 'Actions',
	'reputation_order_by' => 'Order by',
	'reputation_post_peports_exp' => 'Using the form below you can check out posts and reviews reported by users and perform actions on them.<br />Hint: After you resolve the report delete it to prevent other moderators from taking same actions as you did once more :)',
	'reputation_report_date' => 'Report date',
	'reputation_reports_number' => 'Reports number',
	'reputation_first_reported' => 'First reported by',
	'reputation_confirm_report' => 'Are you sure you want to report this post to moderator(s)?',
	'reputation_confirm_report2' => 'Are you sure you want to report this review to moderator(s)?',
	'reputation_report_deleted' => 'The report has been deleted.',
	'reputation_report_success' => 'The officials have been informed',
	'reputation_reviewed' => 'Reviewed', // TODO: replace

	// viewing profile
	'reputation_search_given' => 'Find all reviews written by %s',
	'reputation_search_reputation' => 'Find all reviews given to %s',
	'reputation_search_warnings' => 'Find all warnings given to %s',

	// viewing posts (+some general buttons)
	'Reviews' => 'Reviews',
	'reputation_view_reviews' => 'This post has %s review(s)',
	'reputation_post_warning' => 'Warned by %s on %s. Expires: %s',
	'reputation_post_ban' => 'Banned by %s at %s. Expires: %s',
	'reputation_approve' => 'Approve',
	'reputation_disapprove' => 'Disapprove',
	'reputation_reason' => 'Reason',
	'reputation_warn' => 'Warn',
	'reputation_ban' => 'Ban',
	'reputation_warn_user' => 'Give this user a warning',
	'reputation_ban_user' => 'Ban this user',
	'reputation_report_post' => 'Report this post to moderator(s)',
	'reputation_report' => 'Report',

	// expiration
	'reputation_expire' => 'Expire',
	'reputation_expired' => 'Expired',
	'reputation_expire_never' => 'Never',

	// adding/editing reviews
	'reputation_modify' => 'Modify user\'s reputation',
	'reputation_mail_warning' => 'You have recieved a warning',
	'reputation_mail_ban' => 'You have been banned',

	'reputation_expire_fixed' => 'After %s days.',
	'reputation_expire_limited_bottom' => 'Minimum value is %d day(s)',
	'reputation_expire_limited' => 'Possible values are %d to %d days',
	'reputation_note_cant_edit' => 'Please note that you won\'t be able to edit your review later',
	'reputation_note_can_edit' => 'Please note that you\'ll be able to edit only your review text',
	'reputation_for_days' => 'for %d day(s)',

	'reputation_confirm_delete' => 'Are you sure you want to delete this review?',
	'reputation_update_successfull' => 'You have successfully voted for this user\'s reputation',
	'reputation_warning_successfull' => 'The user has been warned successfully',
	'reputation_delete_success' => 'Review was deleted successfully. User\'s reputation has been updated.',

	// input errors
	'reputation_no_comments_entered' => 'You didn\'t enter any comment!',
	'reputation_no_post_spec' => 'No post specified!',
	'reputation_no_user_spec' => 'No user specified!',
	'reputation_no_review_spec' => 'No review specified!',
	'reputation_no_expire_entered' => 'You didn\'t enter an expire date for this warning',

	// procedural errors
	'reputation_deleted_no_edit' => 'The review you try to edit referres to deleted post',
	'reputation_last_warning_issued' => 'The user has already got last warning',
	'reputation_already_warned' => 'This user has been already warned for this post',
	'reputation_already_banned' => 'This user is already banned',
	'reputation_already_voted' => 'You have already referred to this post!',

	// auth_personal errors
	'reputation_not_applicable' => 'This user can\'t have reputation.',
	'reputation_cant_warn_mods' => 'Moderators and administrators cannot be given warnings',
	'reputation_self_no_modify' => 'You can\'t modify your own reputation!',
	'reputation_others_no_edit' => 'You can\'t edit others\' reviews',
	'reputation_other_mods_no_edit' => 'You can\'t edit warnings or bans given by other moderators/admins.',
	'reputation_anonymous_no_reputation' => 'Anonymous users don\'t have reputation!',
	'reputation_anonymous_no_reviews' => 'Anonymous posts don\'t have reviews!',
	'reputation_limits_apply' => 'To change reputation you should met requirements on the number of posts, reputation points and active warnings.',
	'reputation_time_limit' => 'You can\'t change reputation of the same member more than once in %d minutes.',
	'reputation_rotation_limit' => 'You mush change reputation of % different member to be able to change reputation of the same member twice.',

	// emptiness errors
	'reputation_no_reviews' => 'This post hasn\'t got any reviews',
	'reputation_no_details' => 'This user hasn\'t got any reputation details',
	'reputation_no_warnings' => 'This post hasn\'t got any warnings',

	// backlinks
	'reputation_msg_view_warning' => '%sView this warning%s',
	'reputation_msg_delete_report' => '%sDelete report%s',
	'reputation_msg_view_profile' => '%sView this user\'s profile%s',
	'reputation_msg_back_to_topic' => '%sGo back to topic%s',
	'reputation_msg_back_to_reviews' => '%sGo back to reviews%s',
	'reputation_msg_view_your_review' => '%sView your review of this post%s',
	'reputation_msg_back_to_reports' => '%sBack to the Reports page%s',

	// posting
	'Post_locked' => 'Sorry, you are not allowed edit or delete this post any more.',
	'reputation_lock_post' => 'Lock this post',
) + $lang;

#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/index_body.tpl
#
#-----[ FIND ]------------------------------------------
#
	<td class="row1" align="left" width="100%"><span class="gensmall">{TOTAL_POSTS}<br />{TOTAL_USERS}<br />{RESPECTED_USERS}{NEWEST_USER}</span>

#
#-----[ REPLACE WITH ]------------------------------------------
#
	<td class="row1" align="left" width="100%"><span class="gensmall">{TOTAL_POSTS}<br />{TOTAL_USERS}<br />{NEWEST_USER}{MOST_RESPECTED_USERS}{LEAST_RESPECTED_USERS}</span>

#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/profile_view_body.tpl
#
#-----[ FIND ]------------------------------------------
#
		<!-- BEGIN warnings -->
		<tr>
		  <td valign="top" align="right" nowrap="nowrap"><span class="gen">{L_WARNINGS}:&nbsp;</span></td>
		  <td width="100%"><b><span class="gen">{warnings.WARNINGS}</span></b> <span class="genmed">[ <a href="{warnings.U_VIEW_WARNINGS}" class="genmed">{L_VIEW_DETAILS}</a> ]</span></td>
		</tr>
		<!-- END warnings -->
		<!-- BEGIN reputation -->
		<tr>
		  <td valign="top" align="right" nowrap="nowrap"><span class="gen">{L_REPUTATION}:&nbsp;</span></td>
		  <td width="100%"><b><span class="gen">{reputation.REPUTATION}</span></b> <span class="genmed">[ <a href="{reputation.U_VIEW_REPUTATION}" class="genmed">{L_VIEW_DETAILS}</a> ]</span></td>
		</tr>
		<!-- END reputation -->

#
#-----[ REPLACE WITH ]------------------------------------------
# Just remove the lines

#
#-----[ FIND ]------------------------------------------
#
		  <td> <b><span class="gen">{INTERESTS}</span></b></td>
		</tr>

#
#-----[ AFTER, ADD ]------------------------------------------
#
		<!-- BEGIN warnings -->
		<tr>
		  <td align="right" nowrap="nowrap"><span class="gen">{warnings.L_WARNINGS}:&nbsp;</span></td>
		  <td><b><span class="gen">{warnings.WARNINGS}</span></b> &nbsp; {warnings.YELLOW_IMG} {warnings.RED_IMG}
		  <!-- BEGIN details -->
		  <br /><span class="genmed"><a href="{warnings.details.U_SEARCH}" class="genmed">{warnings.details.L_SEARCH}</a></span>
		  <!-- END details -->
		</tr>
		<!-- END warnings -->
		<!-- BEGIN reputation -->
		<tr>
		  <td align="right" nowrap="nowrap"><span class="gen">{reputation.L_REPUTATION}:&nbsp;</span></td>
		  <td><b><span class="gen">{reputation.REPUTATION}</span></b>
		  <!-- BEGIN details -->
		  <br /><span class="genmed"><a href="{reputation.details.U_SEARCH}" class="genmed">{reputation.details.L_SEARCH}</a></span>
		  <!-- END details -->
		</tr>
		<!-- END reputation -->

#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/viewtopic_body.tpl
#
#-----[ FIND ]------------------------------------------
#
			<tr>
				<td colspan="2"><span class="postbody">{postrow.MESSAGE}{postrow.SIGNATURE}</span><span class="gensmall">{postrow.EDITED_MESSAGE}</span></td>
			</tr>

#
#-----[ AFTER, ADD ]------------------------------------------
#
			<!-- BEGIN warning -->
			<tr>
				<td><br /><table border="0" cellpadding="0" cellspacing="3"><tr><td valign="top">{postrow.warning.ICON}</td><td class="gensmall">{postrow.warning.DETAILS}<br /><b>{L_REASON}:</b> {postrow.warning.MESSAGE}</td></tr></table></td>
			</tr>
			<!-- END warning -->

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#

#
#-----[ DIY INSTRUCTIONS ]-------------------------
#

Delete file templates/subSilver/modcp_post_report_body.tpl

Go to Reputation page in Admin Control Panel (General Admin section), check "Ensure data integrity" in "Maintenance" block (at the bottom) and press Submit.

# EoM