## EasyMod 0.3.0 Compatible
############################################################## 
## MOD Title: Topic Cost
## MOD Author: Zarath < null@null.com > ( Jamie ) http://www.zarath.com
## MOD Description: Allows you to charge for posts and topics in each forum.
## MOD Version: 1.2.1
## 
## Installation Level: Easy
## Installation Time: 2 Minutes 
## Files To Edit: includes/functions_post.php
##                language/lang_english/lang_main.php
##                language/lang_english/lang_admin.php
## Included Files: admin/admin_topic_cost.php
##                 templates/admin/topic_config_body.tpl
##                 templates/admin/topic_edit_body.tpl
############################################################## 
## Author Notes: First version of the mod, it's fairly simple. Tested,  
##               so it should have no problems. Email me if you find any.
##
##               This mod will work with the points and cash mod as long
##               as your cash_column is named user_points.
############################################################## 
## MOD History:
## v1.1.0 Changed to allow post and topic charges.
## v1.1.0 Rewritten to comply to phpBB standards.
## v1.0.0 First version release. All seems to work okay.
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
##############################################################

# 
#-----[ COPY ]------------------------------------------ 
# Remember to copy templates for each theme on your forum
#
copy admin/admin_topic_cost.php to admin/admin_topic_cost.php
copy templates/admin/topic_config_body.tpl to /templates/subSilver/admin/topic_config_body.tpl
copy templates/admin/topic_edit_body.tpl to /templates/subSilver/admin/topic_edit_body.tpl

# 
#-----[ SQL ]------------------------------------------ 
#
#   Only do these SQL queries if you can not run the sql_install.php file.
#   Otherwise, please run that as it's easier.
#
#   If you don't use MySQL, you'll have to edit these queries accordingly
# 
#   If you have a different table prefix then change this command accordingly. 
#   I have used the default table prefix! 

ALTER TABLE `phpbb_forums` ADD `topic_cost` INT (5) DEFAULT '0';
ALTER TABLE `phpbb_forums` ADD `post_cost` INT (5) DEFAULT '0';

# 
#-----[ OPEN ]------------------------------------------ 
# 
includes/functions_post.php

# 
#-----[ FIND ]------------------------------------------ 
#
					message_die(GENERAL_MESSAGE, $lang['Flood_Error']);
				}
			}
		}
	}

# 
#-----[ AFTER, AFTER ]------------------------------------------ 
#
		$topic_cost = ( $mode == 'newtopic' ) ? intval($row['topic_cost']) : intval($row['post_cost']);

		if ($topic_cost > 0)
		{
			if ($userdata['user_points'] < $topic_cost)
			{ 
				$message = ( $mode == 'newtopic' ) ? $lang['points_post_topic'] : $lang['points_post_reply'];
				message_die(GENERAL_MESSAGE, sprintf($lang['not_enough_points'], $board_config['points_name'], $message)); 
			}
			else { 
				$sql = "UPDATE " . USERS_TABLE . " 
					SET user_points = user_points - $topic_cost
					 WHERE user_id = '{$userdata['user_id']}'";
				if ( !($db->sql_query($sql)) )
				{
					message_die(GENERAL_ERROR, 'Error charging', '', __LINE__, __FILE__, $sql);
				}
			}
		}

# 
#-----[ OPEN ]------------------------------------------ 
# 
language/lang_english/lang_main.php

# 
#-----[ FIND ]------------------------------------------ 
#
?>

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
#
// Topic cost variables
$lang['not_enough_points'] = 'You do not have enough %s to %s in this forum!';
$lang['points_post_reply'] = 'post a reply';
$lang['points_post_topic'] = 'create a topic';

# 
#-----[ OPEN ]------------------------------------------ 
# 
language/lang_english/lang_admin.php

# 
#-----[ FIND ]------------------------------------------ 
#
?>

# 
#-----[ BEFORE, ADD ]------------------------------------------ 
#
// Topic cost variables
$lang['topic_cost_index_ttitle'] = 'Modify Topic Cost Settings';
$lang['topic_cost_index_title'] = 'Forum Topic Editor';
$lang['topic_cost_index_explain'] = 'This section allows you to add a cost to making topics in a specified forum.';
$lang['topic_cost_index_edit'] = 'Edit Costs';
$lang['topic_cost_index_forum'] = 'Forum Name';
$lang['topic_cost_index_none'] = 'No Forums';

$lang['topic_cost_index_ftitle'] = 'Modify %s\'s Settings';
$lang['topic_cost_edit_explain'] = 'This section allows you to add a cost to making topics in a specified forum.';
$lang['topic_cost_edit_update'] = 'Update Costs';
$lang['topic_cost_edit_tcost'] = 'Topic Cost';
$lang['topic_cost_edit_pcost'] = 'Post Cost';


$lang['topic_cost_updated'] = '%s has been sucessfully updated!';

$lang['topic_cost_error_fetch'] = 'Error fetching forum information';
$lang['topic_cost_error_get'] = 'Error getting forum information';
$lang['topic_cost_error_invalid'] = 'Invalid forum id!';
$lang['topic_cost_error_topic'] = 'Invalid Topic Cost!';
$lang['topic_cost_error_post'] = 'Invalid Post Cost!';
# 
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
# 
# EoM 
