## EasyMod 0.3.0 Compatible
##############################################################
## MOD Title: Bank Mod
## MOD Author: Zarath < null@null.com > ( Jamie ) http://www.zarath.com
## MOD Description: A bank system for your forums.
## MOD Version: 2.0.0
##
## Installation Level: Easy
## Installation Time: ~5 Minutes
## Files To Edit:	viewtopic.php
## 			includes/constants.php
##			includes/page_header.php
##			includes/usercp_viewprofile.php
##			templates/*/overall_header.tpl
##			templates/*/profile_view_body.tpl
##			templates/*/viewtopic_body.tpl
## Included Files:	bank.php
## 			admin/admin_bank.php
## 			language/lang_english/lang_bank.php
## 			templates/bank_body.tpl
## 			templates/admin/bank_config_body.tpl
## 			templates/admin/bank_edit_user.tpl
## 			images/icon_bank.gif
## License: http://opensource.org/licenses/gpl-license.php GNU General Public License v2
##############################################################
## For security purposes, please check: http://www.zarath.com
## for the latest version of this MOD.
##############################################################
## Author Notes: Please note, I will not give any kind of email 
##               or PM support. Post in the relevant threads on
##               http://forums.zarath.com
##
##############################################################
## MOD History:
##
##   2006-01-06 - Version 2.0.0
##      - Rewrite
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################

#
#-----[ DIY INSTRUCTIONS ]------------------------------------------
#
 If you are updating from a previous version of this mod, please use the sql_update.php file and mod_update.txt files.

# 
#-----[ COPY ]------------------------------------------ 
#
copy bank.php to bank.php
copy admin/admin_bank.php to admin/admin_bank.php
copy language/lang_english/lang_bank.php to language/lang_english/lang_bank.php
copy templates/bank_body.tpl to templates/subSilver/bank_body.tpl
copy templates/admin/bank_config_body.tpl to templates/subSilver/admin/bank_config_body.tpl
copy templates/admin/bank_edit_user.tpl to templates/subSilver/admin/bank_edit_user.tpl
copy images/icon_bank.gif to templates/subSilver/images/icon_bank.gif

#
#-----[ SQL ]------------------------------------------
#
# You can either alter the table prefix and run this through phpMyAdmin or
# upload the sql_install.php file to your forum index and run it from an
# admin account. No need to do both... SQL install file is made for MySQL.
#
CREATE TABLE `phpbb_bank`
	(`id` INT UNSIGNED NOT NULL AUTO_INCREMENT, 
		`user_id` INT (10) NOT NULL, 
		`holding` INT (10) UNSIGNED DEFAULT '0', 
		`totalwithdrew` INT (10) UNSIGNED DEFAULT '0', 
		`totaldeposit` INT (10) UNSIGNED DEFAULT '0', 
		`opentime` INT (10) UNSIGNED NOT NULL, 
		`fees` CHAR (5) NOT NULL DEFAULT 'on', 
	PRIMARY KEY(`user_id`), 
	INDEX(`id`));
insert into `phpbb_config` (config_name, config_value) values ('bankinterest', '2');
insert into `phpbb_config` (config_name, config_value) values ('bankfees', '2');
insert into `phpbb_config` (config_name, config_value) values ('bankpayouttime', '84600');
insert into `phpbb_config` (config_name, config_value) values ('bankname', 'Forums Bank');
insert into `phpbb_config` (config_name, config_value) values ('bankopened', 'off');
insert into `phpbb_config` (config_name, config_value) values ('bankholdings', '0');
insert into `phpbb_config` (config_name, config_value) values ('banktotaldeposits', '0');
insert into `phpbb_config` (config_name, config_value) values ('banktotalwithdrew', '0');
insert into `phpbb_config` (config_name, config_value) values ('banklastrestocked', '0');
insert into `phpbb_config` (config_name, config_value) values ('bank_minwithdraw', '0');
insert into `phpbb_config` (config_name, config_value) values ('bank_mindeposit', '0');
insert into `phpbb_config` (config_name, config_value) values ('bank_interestcut', '0');

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

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

#
#-----[ BEFORE, ADD ]------------------------------------------
#
define('BANK_TABLE', $table_prefix.'bank');

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

#
#-----[ FIND ]------------------------------------------
#
	'L_MEMBERLIST' => $lang['Memberlist'],
	'L_FAQ' => $lang['FAQ'],

#
#-----[ AFTER, ADD ]------------------------------------------
#
	'L_BANK' => $lang['bank'],

#
#-----[ FIND ]------------------------------------------
#
	'U_LOGIN_LOGOUT' => append_sid($u_login_logout),
	'U_GROUP_CP' => append_sid('groupcp.'.$phpEx),

#
#-----[ AFTER, ADD ]------------------------------------------
#
	'U_BANK' => append_sid('bank.'.$phpEx),

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

#
#-----[ FIND ]------------------------------------------
#
$template->assign_vars(array(
	'USERNAME' => $profiledata['username'],

#
#-----[ BEFORE, ADD ]------------------------------------------
#
// Bank Code
if ( empty($holding[$poster_id]) )
{
	$sql = "SELECT holding
		FROM " . BANK_TABLE . "
		WHERE user_id = '{$profiledata['user_id']}'";
	$result = $db->sql_query($sql);
	$bank_row = $db->sql_fetchrow($result);

	$bank_row['holding'] = ( empty($bank_row['holding']) ) ? '0' : $bank_row['holding'];
}

#
#-----[ FIND ]------------------------------------------
#
	'YIM' => $yim,

#
#-----[ AFTER, ADD ]------------------------------------------
#
	'BANK_GOLD' => $bank_row['holding'],
	'L_POINTS_NAME' => $board_config['points_name'],

#
#-----[ FIND ]------------------------------------------
#
	'L_INTERESTS' => $lang['Interests'],

#
#-----[ AFTER, ADD ]------------------------------------------
#
	'L_BANK' => $lang['bank'],

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

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

#
#-----[ BEFORE, ADD ]------------------------------------------
#
$lang['bank'] = 'Bank';

#
#-----[ OPEN ]------------------------------------------
#
viewtopic.php

#
#-----[ FIND ]------------------------------------------
#
	$template->assign_block_vars('postrow', array(

#
#-----[ BEFORE, ADD ]------------------------------------------
#
	// Bank Code
	$holding = ( empty($holding) ) ? array() : $holding;
	if ( empty($holding[$poster_id]) )
	{
		$sql = "SELECT holding
			FROM " . BANK_TABLE . "
			WHERE user_id = '$poster_id'";
		$result = $db->sql_query($sql);
		$bank_row = $db->sql_fetchrow($result);

		$holding[$poster_id] = ( $bank_row['holding'] ) ? $bank_row['holding'] : '0';
		$bank_row = '';
	}
#
#-----[ FIND ]------------------------------------------
#
		'EDITED_MESSAGE' => $l_edited_by,

#
#-----[ AFTER, ADD ]------------------------------------------
#
		'L_BANK' => $lang['bank'],
		'BANK_GOLD' => $holding[$poster_id],
		'L_POINTS_NAME' => $board_config['points_name'],
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/overall_header.tpl

#
#-----[ FIND ]------------------------------------------
#
						<td align="center" valign="top" nowrap="nowrap"><span class="mainmenu">&nbsp;<a href="{U_FAQ}" class="mainmenu"><img src="templates/subSilver/images/icon_mini_faq.gif" width="12" height="13" border="0" alt="{L_FAQ}" hspace="3" />{L_FAQ}</a> 

#
#-----[ IN-LINE FIND ]------------------------------------------
#
 hspace="3" />{L_FAQ}</a>

#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
&nbsp; &nbsp;<a href="{U_BANK}" class="mainmenu"><img src="templates/subSilver/images/icon_bank.gif" width="12" height="13" border="0" alt="{L_BANK}" hspace="3" />{L_BANK}</a>

#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/profile_view_body.tpl

#
#-----[ FIND ]------------------------------------------
#
		<tr> 
		  <td valign="top" align="right" nowrap="nowrap"><span class="gen">{L_INTERESTS}:</span></td>
		  <td> <b><span class="gen">{INTERESTS}</span></b></td>
		</tr>

#
#-----[ AFTER, ADD ]------------------------------------------
#
		<tr> 
		  <td valign="top" align="right" nowrap="nowrap"><span class="gen">{L_BANK}:</span></td>
		  <td> <span class="gen">{BANK_GOLD} {L_POINTS_NAME}</span></td>
		</tr>

#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/viewtopic_body.tpl

#
#-----[ FIND ]------------------------------------------
#
{postrow.POSTER_FROM}

#
#-----[ IN-LINE FIND ]------------------------------------------
#
{postrow.POSTER_FROM}

#
#-----[ IN-LINE AFTER, ADD ]------------------------------------------
#
<br />{postrow.L_BANK}: {postrow.BANK_GOLD} {postrow.L_POINTS_NAME}

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