##############################################################
## MOD Title: Report Posts (upgrade from 1.0.2 to 1.2.3)
## MOD Author: chatasos < chatasos@psclub.gr > (Tassos Chatzithomaoglou) http://www.psclub.gr
## MOD Description: This mod upgrades an installation of Report Posts from version 1.0.2 to version 1.2.3.
## MOD Version: 1.2.3a
## 
## Installation Level: Intermediate
## Installation Time: 15 minutes
## Files To Edit: 
##                includes/constants.php
##                viewtopic.php
##                includes/page_tail.php
##                language/lang_english/lang_main.php
##                templates/subSilver/overall_footer.tpl
## Included Files:
##               viewpost_reports.php
##               includes/functions_report.php
##               language/lang_english/email/report_posts.tpl
##               templates/subSilver/report_post.tpl
##               templates/subSilver/report_comment.tpl
##               templates/subSilver/reports_view.tpl
##               templates/subSilver/images/icon_report.gif
## 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/
##############################################################
## Author Notes: This is an upgrade mod that assumes you already have version 1.0.2 of Report Posts installed
##
##############################################################
## MOD History:
##
##   2005-08-26 - Version 1.2.3a
##		- Corrected a tiny error in sql instructions.
##
##   2005-08-17 - Version 1.2.3
##		- Initial version of upgrade to 1.2.3.
## 
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
##############################################################
#
#-----[ COPY ]------------------------------------------
#

copy viewpost_reports.php to viewpost_reports.php
copy includes/functions_report.php to includes/functions_report.php
copy language/lang_english/email/report_post.tpl to language/lang_english/email/report_post.tpl
copy templates/subSilver/report_post.tpl to templates/subSilver/report_post.tpl
copy templates/subSilver/report_comment.tpl to templates/subSilver/report_comment.tpl
copy templates/subSilver/reports_view.tpl to templates/subSilver/reports_view.tpl
copy templates/subSilver/images/icon_report.gif to templates/subSilver/images/icon_report.gif

#
#-----[ SQL ]------------------------------------------
#

ALTER TABLE `phpbb_post_reports` ADD `last_action_user_id` mediumint(8) default '0';
ALTER TABLE `phpbb_post_reports` ADD `last_action_time` int(11) NOT NULL default '0';
ALTER TABLE `phpbb_post_reports` ADD `last_action_comments` text;

#
#-----[ OPEN ]------------------------------------------
#
includes/constants.php
#
#-----[ FIND ]------------------------------------------
#
// Table names
define('CONFIRM_TABLE', $table_prefix.'confirm');
#
#-----[ BEFORE, ADD ]------------------------------------------
#
/*******************
** MOD: Report Posts
*******************/
// BEGIN : BEFORE, ADD
// Report posts
define('REPORT_POST_NEW', 1);
define('REPORT_POST_CLOSED', 2);
// END : BEFORE, ADD

#
#-----[ FIND ]------------------------------------------
#
define('POST_REPORTS_TABLE', $table_prefix . 'post_reports');
#
#-----[ REPLACE WITH ]------------------------------------------
#
/*******************
** MOD: Report Posts
*******************/
// BEGIN : AFTER, ADD
define('POST_REPORTS_TABLE', $table_prefix.'post_reports');
// END : AFTER, ADD

#
#-----[ OPEN ]------------------------------------------
#
viewtopic.php
#
#-----[ FIND ]------------------------------------------
#
	//
	// report post
	//
	if ( isset($HTTP_GET_VARS['report']) || isset($HTTP_POST_VARS['report']) )
	{
		include($phpbb_root_path . 'includes/functions_report.'.$phpEx);
		
		$comments = ( !empty($HTTP_POST_VARS['comments']) ) ? htmlspecialchars(trim($HTTP_POST_VARS['comments'])) : '';

		if ( empty($comments) )
		{
			// show form to add comments about topic
			$page_title = $lang['Report_post'] . ' - ' . $topic_title;
			include($phpbb_root_path . 'includes/page_header.'.$phpEx);

			$template->set_filenames(array(
				'body' => 'report_post.tpl')
			);

			$template->assign_vars(array(
				'TOPIC_TITLE'	=> $topic_title,
				'POST_ID'		=> $post_id,
				'U_VIEW_TOPIC'	=> append_sid($phpbb_root_path . 'viewtopic.'.$phpEx.'?' . POST_TOPIC_URL . '=' . $topic_id),

				'L_REPORT_POST'	=> $lang['Report_post'],
				'L_COMMENTS'	=> $lang['Comments'],				
				'L_SUBMIT'		=> $lang['Submit'],

				'S_ACTION'		=> append_sid($phpbb_root_path . 'viewtopic.'.$phpEx.'?report=true&amp;' . POST_POST_URL . '=' . $post_id))
			);

			$template->pparse('body');

			include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
			exit;
		}
		else
		{
			if ( !report_flood() )
			{
				message_die(GENERAL_MESSAGE, $lang['Flood_Error']);
			}
			// insert the report
			insert_report($post_id, $comments);

			// email the report if need to
			if ( $board_config['report_email'] )
			{
				email_report($forum_id, $post_id, $topic_title, $comments);
			}

			$template->assign_vars(array(
				'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . '">')
			);
			$message =  $lang['Post_reported'] . '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . '">', '</a>');
			message_die(GENERAL_MESSAGE, $message);
		}
	}
#
#-----[ REPLACE WITH ]------------------------------------------
#
	/*******************
	** MOD: Report Posts
	*******************/
	// BEGIN : AFTER, ADD
	if ( isset($HTTP_GET_VARS['report']) || isset($HTTP_POST_VARS['report']) )
	{
		include($phpbb_root_path . 'includes/functions_report.'.$phpEx);

		// check if the post has already been reported
		if ( report_exists($post_id) )
		{
			$template->assign_vars(array(
				'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=$post_id#$post_id") . '">')
			);
			
			$message = $lang['Post_already_reported'] . '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=$post_id#$post_id") . '">', '</a>');
			message_die(GENERAL_MESSAGE, $message);
		}

		$comments = ( !empty($HTTP_POST_VARS['comments']) ) ? htmlspecialchars(trim($HTTP_POST_VARS['comments'])) : '';

		if ( empty($comments) )
		{
			// show form to add comments about topic
			$page_title = $lang['Report_post'] . ' - ' . $topic_title;
			include($phpbb_root_path . 'includes/page_header.'.$phpEx);

			$template->set_filenames(array(
				'body' => 'report_post.tpl')
			);

			$template->assign_vars(array(
				'TOPIC_TITLE'	=> $topic_title,
				'POST_ID'		=> $post_id,
				'U_VIEW_TOPIC'	=> append_sid($phpbb_root_path . 'viewtopic.'.$phpEx.'?' . POST_TOPIC_URL . '=' . $topic_id),

				'L_REPORT_POST'	=> $lang['Report_post'],
				'L_COMMENTS'	=> $lang['Comments'],
				'L_COMMENTS_EXPLAIN'	=> $lang['Comments_explain'],

				'L_SUBMIT'		=> $lang['Submit'],

				'S_ACTION'		=> append_sid($phpbb_root_path . 'viewtopic.'.$phpEx.'?report=true&amp;' . POST_POST_URL . '=' . $post_id))
			);

			$template->pparse('body');

			include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
			exit;
		}
		else
		{
			if ( !report_flood() )
			{
				message_die(GENERAL_MESSAGE, $lang['Flood_Error']);
			}
			
			// insert the report
			insert_report($post_id, $comments);

			// email the report if need to
			if ( $board_config['report_email'] )
			{
				email_report($forum_id, $post_id, $topic_title, $comments);
			}
	
			$template->assign_vars(array(
				'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=$post_id#$post_id") . '">')
			);
			$message = $lang['Post_reported'] . '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=$post_id#$post_id") . '">', '</a>');
			message_die(GENERAL_MESSAGE, $message);
		}
	}
	// END : AFTER, ADD

#
#-----[ FIND ]------------------------------------------
#
	if ( $userdata['session_logged_in'] )
	{
		$report_img = '<a href="' . append_sid($phpbb_root_path . 'viewtopic.'.$phpEx.'?report=true&amp;' . POST_POST_URL . '=' . $postrow[$i]['post_id']) . '"><img src="' . $images['icon_report'] . '" border="0" width="20" height="20" alt="' . $lang['Report_post'] . '" title="' . $lang['Report_post'] . '" /></a>';
	}
	else
	{
		$report_img = '';
	}
#
#-----[ REPLACE WITH ]------------------------------------------
#
	/*******************
	** MOD: Report Posts
	*******************/
	// BEGIN : BEFORE, ADD
	if ( $userdata['session_logged_in'] )
	{
		$report_img = '<a href="' . append_sid($phpbb_root_path . 'viewtopic.'.$phpEx.'?report=true&amp;' . POST_POST_URL . '=' . $postrow[$i]['post_id']) . '"><img src="' . $images['icon_report'] . '" border="0" alt="' . $lang['Report_post'] . '" title="' . $lang['Report_post'] . '" /></a>';
	}
	else
	{
		$report_img = '';
	}
	// END : BEFORE, ADD

#
#-----[ FIND ]------------------------------------------
#
		'REPORT_IMG'	=> $report_img,
#
#-----[ REPLACE WITH ]------------------------------------------
#
		/*******************
		** MOD: Report Posts
		*******************/
		// BEGIN : AFTER, ADD
		'REPORT_IMG'	=> $report_img,
		// END : AFTER, ADD
#
#-----[ OPEN ]------------------------------------------
#
includes/page_tail.php
#
#-----[ FIND ]------------------------------------------
#
include_once($phpbb_root_path . 'includes/functions_report.'.$phpEx);
$report_link = ( $userdata['user_level'] >= ADMIN ) ? '&nbsp; <a href="' . append_sid($phpbb_root_path . 'viewpost_reports.'.$phpEx) . '">' . sprintf($lang['Post_reports_cp'], reports_count()) . '</a> &nbsp;' : '';
#
#-----[ REPLACE WITH ]------------------------------------------
#
/*******************
** MOD: Report Posts
*******************/
// BEGIN : AFTER, ADD
include_once($phpbb_root_path . 'includes/functions_report.'.$phpEx);

if ( $userdata['user_level'] >= ADMIN )
{
	$open_reports = reports_count();
	if ( $open_reports == 0 )
	{
		$open_reports = sprintf($lang['Post_reports_none_cp'],$open_reports);
	}
	else 
	{
		$open_reports = sprintf(( ($open_reports == 1) ? $lang['Post_reports_one_cp'] : $lang['Post_reports_many_cp']), $open_reports);
		$open_reports = '<b style="color:#' . $theme['fontcolor2'] . '">' . $open_reports . '</b>';
	}

	$report_link = '&nbsp; <a href="' . append_sid($phpbb_root_path . 'viewpost_reports.'.$phpEx) . '">' . $open_reports . '</a> &nbsp;';
}
else
{
	$report_link = '';
}
// END : AFTER, ADD

#
#-----[ FIND ]------------------------------------------
#
	'ADMIN_LINK' => $report_link . $admin_link)
#
#-----[ REPLACE WITH ]------------------------------------------
#
/*******************
** MOD: Report Posts
*******************/
// BEGIN : BEFORE, ADD
	'REPORT_LINK' => $report_link,
// END : BEFORE, ADD
	'ADMIN_LINK' => $admin_link)
#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_main.php
#
#-----[ FIND ]------------------------------------------
#
//
// Report Post
//
$lang['Post_reports_cp'] = 'There is %s open Reported Post(s)';
$lang['Closed'] = 'Closed';
$lang['Close'] = 'Close';
$lang['Open'] = 'Open';
$lang['All'] = 'All';
$lang['Display'] = 'Display only';
$lang['Report_post'] = 'Report Post';
$lang['Comments'] = 'Comments';
$lang['Reporter'] = 'Reporter';
$lang['Status'] = 'Status';
$lang['Select_one'] = 'Select One';
$lang['Opt_in'] = 'Opt in to recieve emails when a report is submitted';
$lang['Opt_out'] = 'Opt out so you don\'t recieve emails when a report is submitted';
$lang['Post_reported'] = 'Post report submitted successfully.';
$lang['Close_success'] = 'Reports were Opened/Closed successfully.';
$lang['Opt_success'] = 'You have opt out/in successfully.';
$lang['Delete_success'] = 'Reports were deleted successfully.';
$lang['Click_return_reports'] = 'Click %shere%s to return to the Report Posts control panel.';
$lang['Report_email'] = 'Send Email when Post Reported';
#
#-----[ REPLACE WITH ]------------------------------------------
#

#
#-----[ FIND ]------------------------------------------
#
//
// That's all, Folks!
#
#-----[ BEFORE, ADD ]------------------------------------------
#
/*******************
** MOD: Report Posts
*******************/
// BEGIN : BEFORE, ADD
$lang['Post_reports_none_cp'] = 'There aren\'t any open Reported Posts';
$lang['Post_reports_one_cp'] = 'There is %s open Reported Post';
$lang['Post_reports_many_cp'] = 'There are %s open Reported Posts';

$lang['All'] = 'All';
$lang['Display'] = 'Display only';
$lang['Report_post'] = 'Report Post';

$lang['Reporter'] = 'Reporter';
$lang['Status'] = 'Status';
$lang['Select_one'] = 'Select One';

$lang['Opt_in'] = 'Opt in to receive emails when a report is submitted';
$lang['Opt_out'] = 'Opt out so you don\'t receive emails when a report is submitted';

$lang['Post_reported'] = 'Post report submitted successfully.';
$lang['Close_success'] = 'Reports were Opened/Closed successfully.';
$lang['Opt_success'] = 'You have opt out/in successfully.';
$lang['Delete_success'] = 'Reports were deleted successfully.';
$lang['Click_return_reports'] = 'Click %shere%s to return to the Report Posts control panel.';
$lang['Report_email'] = 'Send Email when Post Reported';

$lang['Post_already_reported'] = 'This post has already been reported.';

$lang['Report_not_selected'] = 'You haven\'t selected any reports.';

$lang['Comments'] = 'Comments';
$lang['Last_action_comments'] = 'Comments from Moderators';
$lang['Last_action_comments_explain'] = 'Please write some comments about your action on this specific report';
$lang['Comments_explain'] = 'Please write some comments about your report on this specific post.';

$lang['Action'] = 'Action';
$lang['Report_comment'] = 'Comments regarding your action';
$lang['Previous_comments'] = 'Previous comments';

$lang['Last_action_checkbox'] = 'This action was done through the checkbox and drop down menu.';

$lang['Opened_by_user_on_date'] = 'Opened by %s on %s';
$lang['Closed_by_user_on_date'] = 'Closed by %s on %s';
$lang['Opened'] = 'Open';
$lang['Closed'] = 'Closed';
$lang['Open'] = 'Open';
$lang['Close'] = 'Close';

$lang['Non_existent_posts'] = 'Found and deleted %s leftover report(s) pointing to non-existent (deleted) posts';
// END : BEFORE, ADD

#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/overall_footer.tpl
#
#-----[ FIND ]------------------------------------------
#
<div align="center"><span class="copyright"><br />{ADMIN_LINK}<br />
#
#-----[ IN-LINE FIND ]------------------------------------------
#
{ADMIN_LINK}
#
#-----[ IN-LINE BEFORE, ADD ]------------------------------------------
#
{REPORT_LINK}<br /><br />
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM
