############################################################## 
## MOD Title: User Shop Addon
## MOD Author: Zarath < zarath@knightsofchaos.com [invalid] > http://www.ffsource.net
## MOD Description: Adds user shops to your shop section!
## MOD Version: 1.0.0
## 
## Installation Level: Easy
## Installation Time: 5 Minutes 
## Files To Edit: 
## Included Files: 
############################################################## 
## Author Notes: Please check
## http://www.zarath.com/mods/extended.php?action=faq
## and http://www.zarath.com/mods/extended.php?action=bugs
## if you're having any troubles before posting/emailing me.
## Any major problems or bug fixes will be posted there. Also 
## make sure you're using the latest version of the mod.
############################################################## 
## MOD History:
## v1.0.0  First version.
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
##############################################################

# 
#-----[ COPY ]------------------------------------------ 
#
copy shop_users.php			to shop_users.php
copy shop_users_edit.php		to shop_users_edit.php
copy shop_users_view.php		to shop_users_view.php
copy mod_install.php			to mod_install.php
copy shop_users_body.tpl		to /templates/*/shop_users_body.tpl
copy shop_users_config.tpl		to /templates/*/shop_users_config.tpl
copy shop_users_view.tpl		to /templates/*/shop_users_view.tpl

# 
#-----[ SQL ]------------------------------------------ 
#
#   Only do these SQL queries if you can not run the mod_install.php file.
#   Otherwise, please run (go to it in your browswer) that as it's easier.
#
#   If you don't use MySQL, you'll need to edit these queries accordingly
# 
#   If you have a different table prefix then change these commands accordingly. 
#   These currently use the default table prefix. 

CREATE TABLE `phpbb_user_shops` (
  `id` INT( 5 ) NOT NULL AUTO_INCREMENT ,
  `user_id` INT( 10 ) NOT NULL ,
  `username` VARCHAR( 32 ) NOT NULL ,
  `shop_name` VARCHAR( 32 ) NOT NULL ,
  `shop_type` VARCHAR( 32 ) NOT NULL ,
  `shop_opened` INT( 30 ) NOT NULL ,
  `shop_updated` INT( 30 ) NOT NULL,
  `shop_status` INT( 1 ) DEFAULT '0' NOT NULL ,
  `amount_earnt` INT( 10 ) DEFAULT '0' NOT NULL ,
  `amount_holding` INT( 10 ) DEFAULT '0' NOT NULL ,
  `items_sold` INT( 10 ) DEFAULT '0' NOT NULL ,
  `items_holding` INT( 10 ) DEFAULT '0' NOT NULL ,
  PRIMARY KEY ( `user_id` ) ,
  INDEX ( `id` ) 
);

CREATE TABLE `phpbb_user_shops_items` (
  `id` INT( 10 ) NOT NULL AUTO_INCREMENT ,
  `shop_id` INT( 10 ) NOT NULL ,
  `item_id` INT( 10 ) NOT NULL ,
  `seller_notes` VARCHAR( 255 ) NOT NULL ,
  `cost` INT( 10 ) NOT NULL ,
  `time_added` MEDIUMINT( 30 ) NOT NULL ,
  INDEX ( `shop_id` ) ,
  PRIMARY KEY ( `id` ) 
);

INSERT INTO `phpbb_config` (config_name, config_value) VALUES ('u_shops_enabled', '0');

INSERT INTO `phpbb_config` (config_name, config_value) VALUES ('u_shops_open_cost', '0');

INSERT INTO `phpbb_config` (config_name, config_value) VALUES ('u_shops_tax_percent', '0');

INSERT INTO `phpbb_config` (config_name, config_value) VALUES ('u_shops_max_items', '100');


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

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

#
#-----[ BEFORE, ADD ]------------------------------------------ 
#
DEFINE('TABLE_USER_SHOPS', $table_prefix . 'user_shops');
DEFINE('TABLE_USER_SHOP_ITEMS', $table_prefix . 'user_shops_items');

#
# Note: The follow are two different options for where you want to link
#       the user shops. One is in the header, the other is in shops.php
#       You can add both, but it's recommended you just pick one.
#

#
# Option 1
#
#-----[ OPEN ]------------------------------------------ 
#
templates/*/overall_header.tpl

# 
#-----[ FIND ]------------------------------------------ 
#
<a href="{U_LOGIN_LOGOUT}" class="mainmenu">{L_LOGIN_LOGOUT}</a>

#
#-----[ BEFORE, ADD ]------------------------------------------ 
#
<a href="{U_USER_SHOPS}" class="mainmenu">{L_USER_SHOPS}</a>

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

# 
#-----[ FIND ]------------------------------------------ 
#
	'PAGE_TITLE' => $page_title,

#
#-----[ AFTER, ADD ]------------------------------------------ 
#
	'L_USER_SHOPS' => 'User Shops',

# 
#-----[ FIND ]------------------------------------------ 
#
	'U_FAQ' => append_sid('faq.'.$phpEx),

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

#
# Option 2
#
#-----[ OPEN ]------------------------------------------ 
#
shop.php

# 
#-----[ FIND ]------------------------------------------ 
#
	for ($x = 0; $x < $shoparraycount; $x++)
	{
		$temparray = explode("", $shoparray[$x]);
		$shopstatarray[] = $temparray[0];
		$shopstatarray[] = $temparray[1];
	}

#
#-----[ AFTER, ADD ]------------------------------------------ 
#
	$shops .= '<tr><td class="row1"><a href="' . append_sid('shop_users.' . $phpEx) . '" title="User Shops" class="nav">User Shops</a></td><td class="row2"><span class="gensmall">Users</span></td></tr>';

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