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

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

if (self::$db_alter->fetch_table_info('dbtech_vbshop_itemtype'))
{
	$lite = array(
		'threadbump' 	=> array(
			'title' 		=> 'Manual Thread Bump',
			'description' 	=> 'Bumps a thread upon configuration of the purchased item.',
		),
	);
	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(
		'autobump' 	=> array(
			'title' 		=> 'Automatic Thread Bump',
			'description' 	=> 'Bumps a thread every X hours.',
		),
	);
	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');
}