<?php
if (self::$db_alter->fetch_table_info('dbtech_vbshop_item'))
{
	self::$db_alter->add_field(array(
		'name'       => 'active',
		'type'       => 'tinyint',
		'length'	 => '1',
		'attributes' => 'unsigned',
		'null'       => false,	// True = NULL, false = NOT NULL
		'default'    => '4'
	));
	self::report('Altered Table', 'dbtech_vbshop_item');
}

// Add itemtype table
self::$db->query_write("
	CREATE TABLE IF NOT EXISTS `" . TABLE_PREFIX . "dbtech_vbshop_threadban`
	(
		`threadid` int(10) unsigned NOT NULL DEFAULT '0',
		`userid` int(10) unsigned NOT NULL DEFAULT '0',
		PRIMARY KEY (`threadid`, `userid`)
	) ENGINE=MyISAM
");
self::report('Created Table', 'dbtech_vbshop_threadban');

if (self::$db_alter->fetch_table_info('dbtech_vbshop_itemtype'))
{
	$lite = array(
		'firemoderator' 	=> array(
			'title' 		=> 'Fire A Moderator',
			'description' 	=> 'Purchase the ability to fire a moderator.',
		),
		'forumpassword' 	=> array(
			'title' 		=> 'Forum Password',
			'description' 	=> 'Purchase the password for forums.',
		),
	);
	foreach ($lite as $filename => $info)
	{
		self::$db->query_write("
			REPLACE INTO `" . TABLE_PREFIX . "dbtech_vbshop_itemtype`
				(`itemtypeid`, `title`, `description`, `filename`)
			VALUES (
				" . self::$db->sql_prepare($filename) . ",
				" . self::$db->sql_prepare($info['title']) . ",
				" . self::$db->sql_prepare($info['description']) . ",
				'/dbtech/vbshop/items/" . $filename . ".php'
			)
		");
	}

	$pro = array(
		'avatarchange' 	=> array(
			'title' 		=> 'Avatar Change',
			'description' 	=> 'Purchase a custom avatar change.',
		),
		'signaturechange' 	=> array(
			'title' 		=> 'Signature Change',
			'description' 	=> 'Purchase a custom signature change.',
		),
		'usernamestyle2' 	=> array(
			'title' 		=> 'Username Style (Pre-Defined)',
			'description' 	=> 'Purchase a pre-defined username style.',
		),
		'usertitlestyle2' 	=> array(
			'title' 		=> 'User Title Style (Pre-Defined)',
			'description' 	=> 'Purchase a pre-defined user title style.',
		),
		'usertitlechange2' 	=> array(
			'title' 		=> 'User Title Change (Pre-Defined)',
			'description' 	=> 'Purchase a pre-defined user title.',
		),
		'deletethread' 	=> array(
			'title' 		=> 'Delete Thread',
			'description' 	=> 'Purchase the ability to delete a thread.',
		),
		'threadban' 	=> array(
			'title' 		=> 'Ban User From Thread',
			'description' 	=> 'Purchase the ability to ban a user from a thread.',
		),
		'forumdescription' 	=> array(
			'title' 		=> 'Change Forum Description',
			'description' 	=> 'Purchase the ability to change a forum description.',
		),
	);
	foreach ($pro as $filename => $info)
	{
		self::$db->query_write("
			REPLACE INTO `" . TABLE_PREFIX . "dbtech_vbshop_itemtype`
				(`itemtypeid`, `title`, `description`, `filename`)
			VALUES (
				" . self::$db->sql_prepare($filename) . ",
				" . self::$db->sql_prepare($info['title']) . ",
				" . self::$db->sql_prepare($info['description']) . ",
				'/dbtech/vbshop_pro/items/" . $filename . ".php'
			)
		");
	}
	self::report('Populated Table', 'dbtech_vbshop_itemtype');
}

if (class_exists('VBSHOP_CACHE'))
{
	VBSHOP_CACHE::build('itemtype');
}