<?php
/**
@file
@brief エントリー投稿時の確認 & CSRF ガード
@author minahito
@version $Id: entry_confirm.php,v 1.4 2004/07/26 10:52:29 minahito Exp $
*/

$xoopsOption['nocommon']=true;
include_once "../../mainfile.php";
include_once XOOPS_ROOT_PATH."/modules/exFrame/frameloader.php";
include_once "class/global.php";

// FrameLoader
include_once "frameloader.php";

// Form を読み込む
require_once "exComponent/Preview.php";
require_once "./include/EntryForm.php";
require_once "./include/EntryConfirm.php";

include_once "class/party.php";
include_once "class/entry.php";
require_once "include/OnetimeTicket.php";

// session_start
include_once XOOPS_ROOT_PATH."/include/common.php";
include_once XOOPS_ROOT_PATH."/header.php";

$compo = new exPreviewComponent(null,
			new exConrimComponentModelRender(new EntryConfirmRenderModel()),'edit_entry');

switch($ret=$compo->init()) {
	case COMPONENT_INIT_FAIL:
		die;

	case ACTIONFORM_POST_SUCCESS:
		$handler=bxParty::getHandler("entry");
		$editform=&Session::get($compo->name_);
		$editform->data_->setDirty();
		if($handler->insert($editform->data_)) {
			Session::unregister($compo->name_);
			redirect_header("./detail.php?id=".$editform->data_->getVar('id'), 1, "新しい登録を受け付けました");
		}
		else {
			print "Fatal::データーベースへの書き込みに失敗しました";
		}
		break;

	case ACTIONFORM_INIT_FAIL:
	case ACTIONFORM_INIT_SUCCESS:
	case COMPONENT_INIT_SUCCESS:
		$compo->display();
		break;
}

include_once XOOPS_ROOT_PATH."/footer.php";

?>