<?php
/*
 * shopping/promotion/UnLock.class.php
 * 
 * CopyRight(C) 2010 Shopformer Development Team. All Right Reserved
 * URL: http://sourceforge.jp/projects/shopformer/
 * 
 * 
 * Mail: m_nakashima@users.sourceforge.jp
 * Auther: Masanori Nakashima
 * Last Update: 2010-02-12
 * 
 */
require_once( dirname(dirname(__FILE__))
.DIRECTORY_SEPARATOR.'PackageConfig.class.php');
class shopping_promotion_UnLock extends system_login_ModuleBase {
	function shopping_promotion_UnLock() {
	}
	function execute( & $request ) {
		
		$dbo					= $request->getAttribute( 'dbo' );
		$promotionNumber		= stripslashes( $_GET['shppn'] );
		$promotionId			= stripslashes( $_GET['shppi'] );
		$shoppingProductObject	= spider_Controller::createObject('shopping_DaoShoppingPromotion');
		
		if ( strlen(trim($promotionNumber)) == 0 && strlen(trim($promotionId)) == 0 ) {
			$request->addLocaledError('system.error.common.data.selectunlock',SPIDER_LOG_LEVEL_FATAL,array(''));
		} else if( strlen(trim($promotionNumber)) > 0 && preg_match('/^[0-9]+$/',$promotionNumber) > 0 ){
			if ( $dbo->loadByNumber( $shoppingProductObject, $promotionNumber ) ) {
				$this->unlockData( $request, $shoppingProductObject );
			} else {
				$request->addLocaledError('system.error.common.data.invalidselect',SPIDER_LOG_LEVEL_FATAL,array(''));
			}
		} else if( strlen(trim($promotionId)) > 0 && preg_match('/^[0-9a-zA-Z]+$/',$promotionId) > 0 ){
			if ( $dbo->loadById( $shoppingProductObject, $promotionId ) ) {
				$this->unlockData( $request, $shoppingProductObject );
			} else {
				$request->addLocaledError('system.error.common.data.invalidselect',SPIDER_LOG_LEVEL_FATAL,array(''));
			}
		}
		$request->setAttribute('shopping.promotion.promotion_object',			$shoppingProductObject);
	}
}
?>