<?php
/**
 * @copyright ONE/DEPO Project
 * @license   PHP License 3.01 <http://www.php.net/license/3_01.txt>
 */


/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

/**
 * @access      public
 */
class Seller_Itemexhibit_Infomation_Done
{
    var $c_mypage;
    var $c_seller;
    var $auth;

    var $status;
    var $sellerdata;

    var $infomation;
    var $updcnt;

    var $actionChain;

    var $use_tags;

    function execute()
    {
        $log =& LogFactory::getLog();
        $log->debug("debug","");


        if (!$this->auth->checkAuth()) return 'autherr';

        $this->status = $this->c_mypage->checkStatus($this->auth->getAuthData("membercd"));

        if (!$this->status["scd"]) {
            $location = SSL_URL_ROOT.
                        htmlspecialchars($_SERVER["SCRIPT_NAME"], ENT_QUOTES).
                        '?action=customer_mypage_seller_insert_form';
            header('location:'.$location);
            exit;
        }

        $this->sellerdata = $this->c_seller->getSellerInfo($this->auth->getAuthData("membercd"));


        if (preg_match_all("@(?:</?([^>]*?)>)@im",$this->infomation, $match)) {
            $errorList =& $this->actionChain->getCurErrorList();

            $use_tags = str_replace(",", "|", $this->use_tags);
            foreach ($match[0] as $val) {
                if (!preg_match("@(?:</?[".$use_tags."]++(([\s]+[^>]*?)*)>)@im",$val)) {
                    $log->debug("@(?:</?[".$use_tags."]++(([\s]+[^>]*?)*)>)@im  : ". $val, "");
                    $errorList->add("error", "使用できないHTMLタグが入力されています。");
                    $errorList->add("error", "「".$this->use_tags."」が使用できます。");
                    return 'input';
                }
            }
        }

        $r = $this->c_seller->updateInfomation(
            $this->auth->getAuthData("membercd"),
            $this->infomation,
            $this->updcnt
        );
        if (!$r) {
            $errorList =& $this->actionChain->getCurErrorList();
            $errorList->add("error", "更新できませんでした。");
            return 'input';
        }
        return 'success';
    }
}
?>
