source: branches/version-2_13_3/data/class/pages/products/LC_Page_Products_Review.php @ 23654

Revision 23654, 6.6 KB checked in by kim, 9 years ago (diff)

#2560 r23461 r23464 をリバート

既存関数の削除が多く、2.13.3では採用を見送ります。
下位互換が担保された場合、2.13.4で採用を検討します。

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2014 LOCKON CO.,LTD. All Rights Reserved.
6 *
7 * http://www.lockon.co.jp/
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 */
23
24require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';
25
26/**
27 * お客様の声投稿のページクラス.
28 *
29 * @package Page
30 * @author LOCKON CO.,LTD.
31 * @version $Id:LC_Page_Products_Review.php 15532 2007-08-31 14:39:46Z nanasess $
32 */
33class LC_Page_Products_Review extends LC_Page_Ex
34{
35    /** おすすめレベル */
36    public $arrRECOMMEND;
37
38    /** 性別 */
39    public $arrSex;
40
41    /** 入力禁止URL */
42    public $arrReviewDenyURL;
43
44    /**
45     * Page を初期化する.
46     *
47     * @return void
48     */
49    public function init()
50    {
51        parent::init();
52
53        $masterData = new SC_DB_MasterData_Ex();
54        $this->arrRECOMMEND = $masterData->getMasterData('mtb_recommend');
55        $this->arrSex = $masterData->getMasterData('mtb_sex');
56        $this->arrReviewDenyURL = $masterData->getMasterData('mtb_review_deny_url');
57        $this->tpl_mainpage = 'products/review.tpl';
58        $this->httpCacheControl('nocache');
59    }
60
61    /**
62     * Page のプロセス.
63     */
64    public function process()
65    {
66        parent::process();
67        $this->action();
68        $this->sendResponse();
69    }
70
71    /**
72     * Page のAction.
73     *
74     * @return void
75     */
76    public function action()
77    {
78        $objFormParam = new SC_FormParam_Ex();
79        $this->lfInitParam($objFormParam);
80        $objFormParam->setParam($_POST);
81        $objFormParam->convParam();
82
83        switch ($this->getMode()) {
84            case 'confirm':
85                $this->arrErr = $this->lfCheckError($objFormParam);
86
87                //エラーチェック
88                if (empty($this->arrErr)) {
89                    $this->tpl_mainpage = 'products/review_confirm.tpl';
90                }
91                break;
92
93            case 'return':
94                break;
95
96            case 'complete':
97                $this->arrErr = $this->lfCheckError($objFormParam);
98                //エラーチェック
99                if (empty($this->arrErr)) {
100                    //登録実行
101                    $this->lfRegistRecommendData($objFormParam);
102
103                    //レビュー書き込み完了ページへ
104                    SC_Response_Ex::sendRedirect('review_complete.php');
105                    SC_Response_Ex::actionExit();
106                }
107                break;
108
109            default:
110                // 最初のproduct_idは、$_GETで渡ってくる。
111                $objFormParam->setParam($_GET);
112                break;
113        }
114
115        $this->arrForm = $objFormParam->getHashArray();
116
117        //商品名の取得
118        $this->arrForm['name'] = $this->lfGetProductName($this->arrForm['product_id']);
119        if (empty($this->arrForm['name'])) {
120            SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
121        }
122
123        $this->setTemplate($this->tpl_mainpage);
124    }
125
126    /**
127     * パラメーター情報の初期化を行う.
128     *
129     * @param  SC_FormParam $objFormParam SC_FormParam インスタンス
130     * @return void
131     */
132    public function lfInitParam(&$objFormParam)
133    {
134        $objFormParam->addParam('レビューID', 'review_id', INT_LEN, 'aKV');
135        $objFormParam->addParam('商品ID', 'product_id', INT_LEN, 'n', array('NUM_CHECK','EXIST_CHECK', 'MAX_LENGTH_CHECK'));
136        $objFormParam->addParam('投稿者名', 'reviewer_name', STEXT_LEN, 'aKV', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK'));
137        $objFormParam->addParam('投稿者URL', 'reviewer_url', MTEXT_LEN, 'a', array('NO_SPTAB', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK', 'URL_CHECK'));
138        $objFormParam->addParam('性別', 'sex', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
139        $objFormParam->addParam('おすすめレベル', 'recommend_level', INT_LEN, 'n', array('EXIST_CHECK', 'SELECT_CHECK'));
140        $objFormParam->addParam('タイトル', 'title', STEXT_LEN, 'aKV', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK'));
141        $objFormParam->addParam('コメント', 'comment', LTEXT_LEN, 'aKV', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK'));
142    }
143
144    /**
145     * 入力内容のチェックを行う.
146     *
147     * @param  SC_FormParam $objFormParam SC_FormParam インスタンス
148     * @return array        エラーメッセージの配列
149     */
150    public function lfCheckError(&$objFormParam)
151    {
152        $arrErr = $objFormParam->checkError();
153
154        if (REVIEW_ALLOW_URL == false) {
155            $objErr = new SC_CheckError_Ex($objFormParam->getHashArray());
156            // コメント欄へのURLの入力を禁止
157            $objErr->doFunc(array('URL', 'comment', $this->arrReviewDenyURL), array('PROHIBITED_STR_CHECK'));
158            $arrErr += $objErr->arrErr;
159        }
160
161        return $arrErr;
162    }
163
164    /**
165     * 商品名を取得
166     *
167     * @param  integer $product_id 商品ID
168     * @return string  $product_name 商品名
169     */
170    public function lfGetProductName($product_id)
171    {
172        $objQuery =& SC_Query_Ex::getSingletonInstance();
173
174        return $objQuery->get('name', 'dtb_products', 'product_id = ? AND ' . SC_Product_Ex::getProductDispConditions(), array($product_id));
175    }
176
177    //登録実行
178    public function lfRegistRecommendData(&$objFormParam)
179    {
180        $objQuery =& SC_Query_Ex::getSingletonInstance();
181        $objCustomer = new SC_Customer_Ex();
182
183        $arrRegist = $objFormParam->getDbArray();
184
185        $arrRegist['create_date'] = 'CURRENT_TIMESTAMP';
186        $arrRegist['update_date'] = 'CURRENT_TIMESTAMP';
187        $arrRegist['creator_id'] = '0';
188
189        if ($objCustomer->isLoginSuccess(true)) {
190            $arrRegist['customer_id'] = $objCustomer->getValue('customer_id');
191        }
192
193        //-- 登録実行
194        $objQuery->begin();
195        $arrRegist['review_id'] = $objQuery->nextVal('dtb_review_review_id');
196        $objQuery->insert('dtb_review', $arrRegist);
197        $objQuery->commit();
198    }
199}
Note: See TracBrowser for help on using the repository browser.