<?php
/*
 * shopping/flag/Form.class.php
 * 
 * CopyRight(C) 2010 Shopformer Development Team. All Right Reserved
 * URL: http://sourceforge.jp/projects/shopformer/
 * 
 * 
 * Mail: m_nakashima@users.sourceforge.jp
 * Last Update: 2010-02-12
 * 
 */
require_once( dirname(dirname(__FILE__))
.DIRECTORY_SEPARATOR.'PackageConfig.class.php' );
require_once( dirname(dirname(dirname(__FILE__)))
.DIRECTORY_SEPARATOR.'content'
.DIRECTORY_SEPARATOR.'Uploader.class.php');
class shopping_flag_Form extends system_login_ModuleBase {
	
	function shopping_flag_Form(){
	}
	function execute( & $request ) {
		$dbo						= $request->getAttribute( 'dbo' );
		$shoppingFlagNumber			= stripslashes( $_GET['shpfn'] );
		$sessionObjectName			= 'shopping.flag.modify.object.'.$shoppingFlagNumber;
		$sessionConfirmName			= 'shopping.flag.modify.confirm.'.$shoppingFlagNumber;
		$shoppingProductFlagObject	= $request->getSession($sessionObjectName);
		$request->removeSession($sessionConfirmName);
		
		$compareShoppingProductFlagObject	= spider_Controller::createObject('shopping_DaoShoppingProductFlag');
		if( 'shopping_daoshoppingproductflag' == strtolower(get_class($shoppingProductFlagObject)) ){
			// セッションに登録済みでアップロード一時ファイルがあるなら削除
			if( is_object($shoppingProductFlagObject->contentUploader)
				&& 'content_uploader' == strtolower(get_class($shoppingProductFlagObject->contentUploader)) ) {
				$shoppingProductFlagObject->contentUploader->initialize( $request );
			}
		} else {
			// セッションにないなら作成する
			$shoppingProductFlagObject	= spider_Controller::createObject('shopping_DaoShoppingProductFlag');
			if( strlen(trim($shoppingFlagNumber)) > 0 ) {
				// IDが指定されているなら編集のため読み込み
				if( $dbo->loadByNumber( $shoppingProductFlagObject, $shoppingFlagNumber ) ){
					
				} else {
					$request->addLocaledError('shopping.error.flag.notfound',SPIDER_LOG_LEVEL_FATAL,array(''));
				}
			} else {
				// IDが指定されていないなら新規作成
			}
		}
		$request->setAttribute('shopping.flag.flag_object',	$shoppingProductFlagObject);
	}
}
?>