source: branches/version-2_13_0/data/class/pages/products/LC_Page_Products_Review.php @ 23074

Revision 23074, 6.8 KB checked in by h_yoshimoto, 11 years ago (diff)

#2327 LC_Page_Products_Review への対応が漏れていたので修正

  • 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-2013 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    var $arrRECOMMEND;
37
38    /** 性別 */
39    var $arrSex;
40
41    /** 入力禁止URL */
42    var $arrReviewDenyURL;
43
44    /**
45     * Page を初期化する.
46     *
47     * @return void
48     */
49    function init()
50    {
51        $this->skip_load_page_layout = true;
52        parent::init();
53
54        $masterData = new SC_DB_MasterData_Ex();
55        $this->arrRECOMMEND = $masterData->getMasterData('mtb_recommend');
56        $this->arrSex = $masterData->getMasterData('mtb_sex');
57        $this->arrReviewDenyURL = $masterData->getMasterData('mtb_review_deny_url');
58        $this->tpl_mainpage = 'products/review.tpl';
59        $this->httpCacheControl('nocache');
60    }
61
62    /**
63     * Page のプロセス.
64     */
65    function process()
66    {
67        parent::process();
68        $this->action();
69        $this->sendResponse();
70    }
71
72    /**
73     * Page のAction.
74     *
75     * @return void
76     */
77    function action()
78    {
79        $objFormParam = new SC_FormParam_Ex();
80        $this->lfInitParam($objFormParam);
81        $objFormParam->setParam($_POST);
82        $objFormParam->convParam();
83
84        switch ($this->getMode()) {
85            case 'confirm':
86                $this->arrErr = $this->lfCheckError($objFormParam);
87
88                //エラーチェック
89                if (empty($this->arrErr)) {
90                    //重複タイトルでない
91                    $this->tpl_mainpage = 'products/review_confirm.tpl';
92                }
93                break;
94
95            case 'return':
96                break;
97
98            case 'complete':
99                $this->arrErr = $this->lfCheckError($objFormParam);
100                //エラーチェック
101                if (empty($this->arrErr)) {
102                    //登録実行
103                    $this->lfRegistRecommendData($objFormParam);
104
105                    //レビュー書き込み完了ページへ
106                    SC_Response_Ex::sendRedirect('review_complete.php');
107                    SC_Response_Ex::actionExit();
108                }
109                break;
110
111            default:
112                // 最初のproduct_idは、$_GETで渡ってくる。
113                $objFormParam->setParam($_GET);
114                break;
115        }
116
117        $this->arrForm = $objFormParam->getHashArray();
118
119        //商品名の取得
120        $this->arrForm['name'] = $this->lfGetProductName($this->arrForm['product_id']);
121        if (empty($this->arrForm['name'])) {
122            SC_Utils_Ex::sfDispSiteError(PRODUCT_NOT_FOUND);
123        }
124
125        $this->setTemplate($this->tpl_mainpage);
126    }
127
128    /**
129     * パラメーター情報の初期化を行う.
130     *
131     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
132     * @return void
133     */
134    function lfInitParam(&$objFormParam)
135    {
136        $objFormParam->addParam('レビューID', 'review_id', INT_LEN, 'aKV');
137        $objFormParam->addParam('商品ID', 'product_id', INT_LEN, 'n', array('NUM_CHECK','EXIST_CHECK', 'MAX_LENGTH_CHECK'));
138        $objFormParam->addParam('投稿者名', 'reviewer_name', STEXT_LEN, 'aKV', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK'));
139        $objFormParam->addParam('投稿者URL', 'reviewer_url', MTEXT_LEN, 'a', array('NO_SPTAB', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK', 'URL_CHECK'));
140        $objFormParam->addParam('性別', 'sex', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
141        $objFormParam->addParam('おすすめレベル', 'recommend_level', INT_LEN, 'n', array('EXIST_CHECK', 'SELECT_CHECK'));
142        $objFormParam->addParam('タイトル', 'title', STEXT_LEN, 'aKV', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK'));
143        $objFormParam->addParam('コメント', 'comment', LTEXT_LEN, 'aKV', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK'));
144    }
145
146    /**
147     * 入力内容のチェックを行う.
148     *
149     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
150     * @return array エラーメッセージの配列
151     */
152    function lfCheckError(&$objFormParam)
153    {
154        $arrErr = $objFormParam->checkError();
155
156        $arrForm = $objFormParam->getHashArray();
157
158        // 重複メッセージの判定
159        $objQuery =& SC_Query_Ex::getSingletonInstance();
160        $exists = $objQuery->exists('dtb_review','product_id = ? AND title = ? ', array($arrForm['product_id'], $arrForm['title']));
161        if ($exists) {
162            $arrErr['title'] .= '重複したタイトルは登録できません。';
163        }
164
165        if (REVIEW_ALLOW_URL == false) {
166            $objErr = new SC_CheckError_Ex($objFormParam->getHashArray());
167            // コメント欄へのURLの入力を禁止
168            $objErr->doFunc(array('URL', 'comment', $this->arrReviewDenyURL), array('PROHIBITED_STR_CHECK'));
169            $arrErr += $objErr->arrErr;
170        }
171
172        return $arrErr;
173    }
174
175    /**
176     * 商品名を取得
177     *
178     * @param integer $product_id 商品ID
179     * @return string $product_name 商品名
180     */
181    function lfGetProductName($product_id)
182    {
183        $objQuery =& SC_Query_Ex::getSingletonInstance();
184
185        return $objQuery->get('name', 'dtb_products', 'product_id = ? AND ' . SC_Product_Ex::getProductDispConditions(), array($product_id));
186    }
187
188    //登録実行
189    function lfRegistRecommendData(&$objFormParam)
190    {
191        $objQuery =& SC_Query_Ex::getSingletonInstance();
192        $arrRegist = $objFormParam->getDbArray();
193
194        $arrRegist['create_date'] = 'CURRENT_TIMESTAMP';
195        $arrRegist['update_date'] = 'CURRENT_TIMESTAMP';
196        $arrRegist['creator_id'] = '0';
197
198        //-- 登録実行
199        $objQuery->begin();
200        $arrRegist['review_id'] = $objQuery->nextVal('dtb_review_review_id');
201        $objQuery->insert('dtb_review', $arrRegist);
202        $objQuery->commit();
203    }
204}
Note: See TracBrowser for help on using the repository browser.