####################################################################################################
## 
## MOD Title: Democracy MOD - Update from 0.1.1 to 0.1.2
## MOD Author: Carbofos < carbofos@mail.ru > (N/A) N/A
## MOD Description: Adds some social mechanisms to the phpBB
## MOD Version: 0.1.2
## 
## Installation Level: Easy
## Installation Time: 5 Minutes 
## Files To Edit: 7:
##	post_report.php
##	includes/constants.php
##	includes/functions_post.php
##	includes/usercp_reputation.php
##	language/lang_english/lang_main.php
##	language/lang_english/email/reputation_ban.php
##	templates/subSilver/profile_view_reputation.php
##
####################################################################################################
## 
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the 
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code 
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered 
## in our MOD-Database, located at: http://www.phpbb.com/mods/ 
## 
####################################################################################################
## 
## Fixed bug introduced in version 0.1.1 + some improvements
##  
####################################################################################################
## 
## IMPORTANT:
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
## 
####################################################################################################
#
#------------------------[ OPEN ]------------------------
#
post_report.php
#
#------------------------[ FIND ]------------------------
# 
'U_MINI_POST' => append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $reports[$i]['post_id'])
#
#--------------------[ IN-LINE FIND ]--------------------
# 
$reports[$i]['post_id'])
#
#-----------------[ IN-LINE AFTER, ADD ]-----------------
# 
 . '#' . $reports[$i]['post_id']
#
#------------------------[ FIND ]------------------------
# 
'U_MINI_POST' => append_sid("profile.$phpEx?mode=reputation&amp;m=" . REPUTATION_VIEW . "&amp;" . POST_REVIEWS_URL . '=' . $reports[$i]['review_id']),
#
#--------------------[ IN-LINE FIND ]--------------------
# 
$reports[$i]['review_id'])
#
#-----------------[ IN-LINE AFTER, ADD ]-----------------
# 
 . '#' . $reports[$i]['review_id']
#
#------------------------[ FIND ]------------------------
# 
		break;
}
#
#---------------------[ BEFORE, ADD ]--------------------
#
		break;
	case 'delete':
		$report_id = 0;
		if ( isset($HTTP_POST_VARS[POST_REVIEWS_URL]) || isset($HTTP_GET_VARS[POST_REVIEWS_URL]) )
		{
			$report_id = isset($HTTP_POST_VARS[POST_REVIEWS_URL]) ? intval($HTTP_POST_VARS[POST_REVIEWS_URL]) : intval($HTTP_GET_VARS[POST_REVIEWS_URL]);
		}
		if ( $report_id <= 0 )
		{
			message_die(GENERAL_MESSAGE, $lang['No_such_post']);
		}

		//
		// Start session management
		//
		$userdata = session_pagestart($user_ip, PAGE_INDEX);
		init_userprefs($userdata);
		//
		// End session management
		//
		$page_title = $lang['Mod_CP'];
		include($phpbb_root_path . 'includes/page_header.'.$phpEx); 

		//
		// Check the user's access level
		//
		switch ( $userdata['user_level'] )
		{
			case ADMIN:
				break;
			case MOD:
				$sql = 'SELECT r.report_id
					FROM ' . POST_REPORTS_TABLE . ' r, ' . USER_GROUP_TABLE . ' g, ' . AUTH_ACCESS_TABLE . ' a
					WHERE r.report_id = ' . $report_id . '
						AND 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'];
				if ( !($result = $db->sql_query($sql)) )
				{
					message_die(GENERAL_ERROR, 'Could not obtain post report', '', __LINE__, __FILE__, $sql);
				}
				if ( !$db->sql_fetchrow($result) )
				{
					message_die(GENERAL_MESSAGE, $lang['reputation_sorry_auth_view']);
				}
				break;
			default:
				// Die
				message_die(GENERAL_MESSAGE, $lang['reputation_sorry_auth_view']);
				break;
		}
		//
		// We won't ask to confirm the deletion of the report as moderators sure have other things to do rather than clicking yes every time :)
		//
		$sql = "DELETE FROM " . POST_REPORTS_TABLE . " 
			WHERE report_id = $report_id";
		if (!$db->sql_query($sql))
		{
			message_die(GENERAL_ERROR, 'Error in deleting post reports', '', __LINE__, __FILE__, $sql);
		}
		
		message_die(GENERAL_MESSAGE, $lang['reputation_report_deleted'] . '<br /><br />' . sprintf($lang['reputation_msg_back_to_reports'], '<a href="' . append_sid($phpbb_root_path . 'post_report.' . $phpEx . '?mode=view') . '">', '</a>'));
		break;
	default:
		message_die(GENERAL_MESSAGE, $lang['reputation_sorry_auth_view']);
#
#------------------------[ FIND ]------------------------
# 
redirect(append_sid(
#
#--------------------[ REPLACE WITH ]--------------------
# 
message_die(GENERAL_MESSAGE, $lang['reputation_sorry_auth_view']);
#
#------------------------[ OPEN ]------------------------
#
includes/constants.php
#
#------------------------[ FIND ]------------------------
# 
define('REPUTATION_WARNING_EXPIRED', 7);
#
#---------------------[ AFTER, ADD ]---------------------
#
define('REPUTATION_BAN_EXPIRED', 8);
#
#------------------------[ OPEN ]------------------------
#
includes/functions_post.php
#
#------------------------[ FIND ]------------------------
# 
function delete_post
#
#------------------------[ FIND ]------------------------
# 
		$sql = "UPDATE " . REPUTATION_TABLE . " 
#
#---------------------[ BEFORE, ADD ]--------------------
#
		$sql = "DELETE FROM " . POST_REPORTS_TABLE . " 
			WHERE post_id = $post_id";
		if (!$db->sql_query($sql))
		{
			message_die(GENERAL_ERROR, 'Error in deleting post reports', '', __LINE__, __FILE__, $sql);
		}
#
#------------------------[ OPEN ]------------------------
#
includes/usercp_reputation.php
#
#------------------------[ FIND ]------------------------
# 
			switch ( $info[$i]['modification'] )
#
#------------------------[ FIND ]------------------------
# 
				default:
#
#---------------------[ BEFORE, ADD ]--------------------
#
				case REPUTATION_BAN_EXPIRED:
					$review = '<img src="' . $images['user_ban'] . '" alt="" border="0" />';
					$expire = ( $warning[$i]['expire'] == -1 ) ? $lang['reputation_never'] : create_date('d.m.Y', $info[$i]['expire'], $board_config['board_timezone']);
					$l_expire = $lang['reputation_expired'];
					break;
#
#------------------------[ FIND ]------------------------
# 
	$select_post_order = '<select name="postorder"
#
#--------------------[ IN-LINE FIND ]--------------------
# 
name="postorder"
#
#-----------------[ IN-LINE AFTER, ADD ]-----------------
# 
 onchange="this.form.submit();"
#
#------------------------[ FIND ]------------------------
# 
	$plus = 0;
	$minus = 0;
	$warnings = 0;
	$ban = 0;
#
#--------------------[ REPLACE WITH ]--------------------
# 
	$ban_expired = $warning_expired = $ban = $warnings = $plus = $minus = 0;
#
#------------------------[ FIND ]------------------------
# 
			case REPUTATION_BAN:
#
#---------------------[ AFTER, ADD ]---------------------
#
			case REPUTATION_BAN_EXPIRED: $ban_expired = $data[$i]['cnt']; break; //---------------
#
#------------------------[ FIND ]------------------------
# 
	if( $warning_expired > 0 && $display_expired_warnings && $board_config['reputation_delete_expired'] == 0 )
#
#--------------------[ IN-LINE FIND ]--------------------
# 
$warning_expired > 0
#
#----------------[ IN-LINE REPLACE WITH ]----------------
# 
( $warning_expired > 0 || $ban_expired > 0 )
#
#------------------------[ FIND ]------------------------
# 
		$modification = '(r.modification = ' . REPUTATION_WARNING_EXPIRED . ')';
#
#--------------------[ IN-LINE FIND ]--------------------
# 
REPUTATION_WARNING_EXPIRED . '
#
#-----------------[ IN-LINE AFTER, ADD ]-----------------
# 
 OR r.modification = ' . REPUTATION_BAN_EXPIRED
#
#------------------------[ FIND ]------------------------
# 
	if ( $board_config['reputation_delete_expired'] == 0 && $warning_expired > 0
#
#--------------------[ IN-LINE FIND ]--------------------
# 
$warning_expired > 0
#
#----------------[ IN-LINE REPLACE WITH ]----------------
# 
( $warning_expired > 0 || $ban_expired > 0 )
#
#------------------------[ FIND ]------------------------
# 
		$s_display_expired = $lang['reputation_display_expired']
#
#--------------------[ IN-LINE FIND ]--------------------
# 
<select name="exp"
#
#-----------------[ IN-LINE AFTER, ADD ]-----------------
# 
 onchange="this.form.submit();"
#
#------------------------[ FIND ]------------------------
# 
		$sql = 'DELETE FROM ' . REPUTATION_TABLE . "
			WHERE id = $review_id";
		if ( !($result = $db->sql_query($sql)) )
#
#--------------------[ IN-LINE FIND ]--------------------
# 
$db->sql_query($sql
#
#-----------------[ IN-LINE AFTER, ADD ]-----------------
# 
, BEGIN_TRANSACTION
#
#------------------------[ FIND ]------------------------
# 
		$sql = 'DELETE FROM ' . REPUTATION_TEXT_TABLE . "
#
#---------------------[ BEFORE, ADD ]--------------------
#
		$sql = 'DELETE FROM ' . POST_REPORTS_TABLE . "
			WHERE review_id = $review_id";
		if ( !($result = $db->sql_query($sql)) )
		{
			message_die(CRITICAL_ERROR, "Could not delete review", '', __LINE__, __FILE__, $sql);
		}
#
#------------------------[ FIND ]------------------------
# 
		$sql = 'UPDATE ' . POSTS_TABLE . " 
			SET post_reviews = post_reviews - 1 
			WHERE post_id = $post_id";
		if (!$db->sql_query($sql))
#
#--------------------[ IN-LINE FIND ]--------------------
# 
$db->sql_query($sql
#
#-----------------[ IN-LINE AFTER, ADD ]-----------------
# 
, END_TRANSACTION
#
#------------------------[ OPEN ]------------------------
#
language/lang_english/lang_main.php
#
#------------------------[ FIND ]------------------------
# 
$lang['reputation_msg_delete_report']
#
#---------------------[ BEFORE, ADD ]--------------------
#
$lang['reputation_report_deleted'] = 'The report has been deleted';
$lang['reputation_msg_back_to_reports'] = '%sGo back to the report page%s';
#
#------------------------[ OPEN ]------------------------
#
language/lang_english/email/reputation_ban.tpl
#
#------------------------[ FIND ]------------------------
# 
"{SITENAME}"
#
#--------------------[ IN-LINE FIND ]--------------------
# 
"{SITENAME}"
#
#-----------------[ IN-LINE AFTER, ADD ]-----------------
# 
{TIME}
#
#------------------------[ OPEN ]------------------------
#
templates/subSilver/profile_view_reputation.tpl
#
#------------------------[ FIND ]------------------------
# 
	<!-- BEGIN rep -->
#
#------------------------[ FIND ]------------------------
# 
<td class="{rep.rows.ROW_CLASS}" nowrap="nowrap"
#
#--------------------[ IN-LINE FIND ]--------------------
# 
class="{rep.rows.ROW_CLASS}"
#
#-----------------[ IN-LINE AFTER, ADD ]-----------------
# 
 width="100%"
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
#
# EoM 