<?php
/**
@brief AlterTable の発行
@version $Id$
*/
$xoopsOption['nocommon']=true;
include_once "../../../mainfile.php";
require_once XOOPS_ROOT_PATH."/modules/exFrame/frameloader.php";
require_once "../class/global.php";

// Form を読み込む
require_once "exComponent/DeleteConfirm.php";

// Session 開始
require_once XOOPS_ROOT_PATH."/include/common.php";
require_once XOOPS_ROOT_PATH."/include/cp_header.php";

// SimpleなConfirm の代わりに DeleteTypical を使用する
class AdminUpdateProcessor extends exDeleteConfirmTypicalComponentProcessor
{
	function _processDelete(&$component)
	{
		global $xoopsDB;
		
		$sql="ALTER TABLE ".$xoopsDB->prefix('bxparty')." ADD place varchar(255) NOT NULL DEFAULT 0";
		$flag = (bool)($xoopsDB->query($sql));

		$sql="ALTER TABLE ".$xoopsDB->prefix('bxparty')." ADD status int(10) NOT NULL DEFAULT 0";
		if($flag) $flag = $xoopsDB->query($sql);

		$sql ="CREATE TABLE ".$xoopsDB->prefix('bxparty_status')." (".
			" id int(10) DEFAULT '1' NOT NULL auto_increment,".
			" priority tinyint(3) NOT NULL default '0',".
			" type tinyint(1) NOT NULL default '0',".
			" name varchar(64) NOT NULL default '',".
			" ex varchar(255) NOT NULL default '',".
			" PRIMARY KEY (id)".
			" ) TYPE=MyISAM";
		if($flag) $flag = $xoopsDB->query($sql);

		return $flag;
	}
}

// 画面遷移設定
$forwards=array(new exSuccessForwardConfig(EXFORWARD_REDIRECT,"index.php","UPDATE SUCCESS"),
		new exFailForwardConfig(EXFORWARD_REDIRECT,"index.php","UPDATE FAILED"));

$compo = new exDeleteConfirmTypicalComponent(new AdminUpdateProcessor(),null,'delete_message',
				new exConfirmTicketForm(),$forwards);

switch($compo->init(null,"テーブルのアップデート処理を行いますか？")) {
	case COMPONENT_INIT_FAIL:
		die;

	case COMPONENT_INIT_SUCCESS:
		xoops_cp_header();
		$compo->display();
		xoops_cp_footer();
		break;
}

?>