source: branches/version-2_13_0/data/class/pages/entry/LC_Page_Entry.php @ 23182

Revision 23182, 11.6 KB checked in by h_yoshimoto, 11 years ago (diff)

#1506 「決済処理中」受注データの実行フラグを追加

  • 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_Entry.php 15532 2007-08-31 14:39:46Z nanasess $
32 */
33class LC_Page_Entry extends LC_Page_Ex
34{
35    /**
36     * Page を初期化する.
37     * @return void
38     */
39    public function init()
40    {
41        parent::init();
42        $masterData         = new SC_DB_MasterData_Ex();
43        $this->arrPref      = $masterData->getMasterData('mtb_pref');
44        $this->arrJob       = $masterData->getMasterData('mtb_job');
45        $this->arrReminder  = $masterData->getMasterData('mtb_reminder');
46        $this->arrCountry   = $masterData->getMasterData('mtb_country');
47        $this->arrSex       = $masterData->getMasterData('mtb_sex');
48        $this->arrMAILMAGATYPE = $masterData->getMasterData('mtb_mail_magazine_type');
49
50        // 生年月日選択肢の取得
51        $objDate            = new SC_Date_Ex(BIRTH_YEAR, date('Y',strtotime('now')));
52        $this->arrYear      = $objDate->getYear('', START_BIRTH_YEAR, '');
53        $this->arrMonth     = $objDate->getMonth(true);
54        $this->arrDay       = $objDate->getDay(true);
55
56        $this->httpCacheControl('nocache');
57    }
58
59    /**
60     * Page のプロセス.
61     *
62     * @return void
63     */
64    public function process()
65    {
66        parent::process();
67        $this->action();
68        $this->sendResponse();
69    }
70
71    /**
72     * Page のプロセス
73     * @return void
74     */
75    public function action()
76    {
77        //決済処理中ステータスのロールバック
78        $objPurchase = new SC_Helper_Purchase_Ex();
79        $objPurchase->cancelPendingOrder(PENDING_ORDER_CANCEL_FLAG);
80
81        $objFormParam = new SC_FormParam_Ex();
82
83        // PC時は規約ページからの遷移でなければエラー画面へ遷移する
84        if ($this->lfCheckReferer() === false) {
85            SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, '', true);
86        }
87
88        SC_Helper_Customer_Ex::sfCustomerEntryParam($objFormParam);
89        $objFormParam->setParam($_POST);
90
91        // mobile用(戻るボタンでの遷移かどうかを判定)
92        if (!empty($_POST['return'])) {
93            $_REQUEST['mode'] = 'return';
94        }
95
96        switch ($this->getMode()) {
97            case 'confirm':
98                if (isset($_POST['submit_address'])) {
99                    // 入力エラーチェック
100                    $this->arrErr = $this->lfCheckError($_POST);
101                    // 入力エラーの場合は終了
102                    if (count($this->arrErr) == 0) {
103                        // 郵便番号検索文作成
104                        $zipcode = $_POST['zip01'] . $_POST['zip02'];
105
106                        // 郵便番号検索
107                        $arrAdsList = SC_Utils_Ex::sfGetAddress($zipcode);
108
109                        // 郵便番号が発見された場合
110                        if (!empty($arrAdsList)) {
111                            $data['pref'] = $arrAdsList[0]['state'];
112                            $data['addr01'] = $arrAdsList[0]['city']. $arrAdsList[0]['town'];
113                            $objFormParam->setParam($data);
114
115                            // 該当無し
116                        } else {
117                            $this->arrErr['zip01'] = '※該当する住所が見つかりませんでした。<br>';
118                        }
119                    }
120                    break;
121                }
122
123                //-- 確認
124                $this->arrErr = SC_Helper_Customer_Ex::sfCustomerEntryErrorCheck($objFormParam);
125                // 入力エラーなし
126                if (empty($this->arrErr)) {
127                    //パスワード表示
128                    $this->passlen      = SC_Utils_Ex::sfPassLen(strlen($objFormParam->getValue('password')));
129
130                    $this->tpl_mainpage = 'entry/confirm.tpl';
131                    $this->tpl_title    = '会員登録(確認ページ)';
132                }
133                break;
134            case 'complete':
135                //-- 会員登録と完了画面
136                $this->arrErr = SC_Helper_Customer_Ex::sfCustomerEntryErrorCheck($objFormParam);
137                if (empty($this->arrErr)) {
138                    $uniqid             = $this->lfRegistCustomerData($this->lfMakeSqlVal($objFormParam));
139
140                    $this->lfSendMail($uniqid, $objFormParam->getHashArray());
141
142                    // 仮会員が無効の場合
143                    if (CUSTOMER_CONFIRM_MAIL == false) {
144                        // ログイン状態にする
145                        $objCustomer = new SC_Customer_Ex();
146                        $objCustomer->setLogin($objFormParam->getValue('email'));
147                    }
148
149                    // 完了ページに移動させる。
150                    SC_Response_Ex::sendRedirect('complete.php', array('ci' => SC_Helper_Customer_Ex::sfGetCustomerId($uniqid)));
151                }
152                break;
153            case 'return':
154                // quiet.
155                break;
156            default:
157                break;
158        }
159        $this->arrForm = $objFormParam->getFormParamList();
160    }
161
162    /**
163     * 会員情報の登録
164     *
165     * @access private
166     * @return uniqid
167     */
168    public function lfRegistCustomerData($sqlval)
169    {
170        SC_Helper_Customer_Ex::sfEditCustomerData($sqlval);
171
172        return $sqlval['secret_key'];
173    }
174
175    /**
176     * 会員登録に必要なSQLパラメーターの配列を生成する.
177     *
178     * フォームに入力された情報を元に, SQLパラメーターの配列を生成する.
179     * モバイル端末の場合は, email を email_mobile にコピーし,
180     * mobile_phone_id に携帯端末IDを格納する.
181     *
182     * @param mixed $objFormParam
183     * @access private
184     * @return $arrResults
185     */
186    public function lfMakeSqlVal(&$objFormParam)
187    {
188        $arrForm                = $objFormParam->getHashArray();
189        $arrResults             = $objFormParam->getDbArray();
190
191        // 生年月日の作成
192        $arrResults['birth']    = SC_Utils_Ex::sfGetTimestamp($arrForm['year'], $arrForm['month'], $arrForm['day']);
193
194        // 仮会員 1 本会員 2
195        $arrResults['status']   = (CUSTOMER_CONFIRM_MAIL == true) ? '1' : '2';
196
197        /*
198         * secret_keyは、テーブルで重複許可されていない場合があるので、
199         * 本会員登録では利用されないがセットしておく。
200         */
201        $arrResults['secret_key'] = SC_Helper_Customer_Ex::sfGetUniqSecretKey();
202
203        // 入会時ポイント
204        $CONF = SC_Helper_DB_Ex::sfGetBasisData();
205        $arrResults['point'] = $CONF['welcome_point'];
206
207        if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) {
208            // 携帯メールアドレス
209            $arrResults['email_mobile']     = $arrResults['email'];
210            // PHONE_IDを取り出す
211            $arrResults['mobile_phone_id']  =  SC_MobileUserAgent_Ex::getId();
212        }
213
214        return $arrResults;
215    }
216
217    /**
218     * 会員登録完了メール送信する
219     *
220     * @access private
221     * @return void
222     */
223    public function lfSendMail($uniqid, $arrForm)
224    {
225        $CONF           = SC_Helper_DB_Ex::sfGetBasisData();
226
227        $objMailText    = new SC_SiteView_Ex();
228        $objMailText->setPage($this);
229        $objMailText->assign('CONF', $CONF);
230        $objMailText->assign('name01', $arrForm['name01']);
231        $objMailText->assign('name02', $arrForm['name02']);
232        $objMailText->assign('uniqid', $uniqid);
233        $objMailText->assignobj($this);
234
235        $objHelperMail  = new SC_Helper_Mail_Ex();
236        $objHelperMail->setPage($this);
237
238        // 仮会員が有効の場合
239        if (CUSTOMER_CONFIRM_MAIL == true) {
240            $subject        = $objHelperMail->sfMakeSubject('会員登録のご確認');
241            $toCustomerMail = $objMailText->fetch('mail_templates/customer_mail.tpl');
242        } else {
243            $subject        = $objHelperMail->sfMakeSubject('会員登録のご完了');
244            $toCustomerMail = $objMailText->fetch('mail_templates/customer_regist_mail.tpl');
245        }
246
247        $objMail = new SC_SendMail_Ex();
248        $objMail->setItem(
249            ''                    // 宛先
250            , $subject              // サブジェクト
251            , $toCustomerMail       // 本文
252            , $CONF['email03']      // 配送元アドレス
253            , $CONF['shop_name']    // 配送元 名前
254            , $CONF['email03']      // reply_to
255            , $CONF['email04']      // return_path
256            , $CONF['email04']      // Errors_to
257            , $CONF['email01']      // Bcc
258        );
259        // 宛先の設定
260        $objMail->setTo($arrForm['email'],
261                        $arrForm['name01'] . $arrForm['name02'] .' 様');
262
263        $objMail->sendMail();
264    }
265
266    /**
267     * kiyaku.php からの遷移の妥当性をチェックする
268     *
269     * 以下の内容をチェックし, 妥当であれば true を返す.
270     * 1. 規約ページからの遷移かどうか
271     * 2. PC及びスマートフォンかどうか
272     * 3. 自分自身(会員登録ページ)からの遷移はOKとする
273     *
274     * @access protected
275     * @return boolean kiyaku.php からの妥当な遷移であれば true
276     */
277    public function lfCheckReferer()
278    {
279        $arrRefererParseUrl = parse_url($_SERVER['HTTP_REFERER']);
280        $referer_urlpath = $arrRefererParseUrl['path'];
281
282        $kiyaku_urlpath = ROOT_URLPATH . 'entry/kiyaku.php';
283
284        $arrEntryParseUrl = parse_url(ENTRY_URL);
285        $entry_urlpath = $arrEntryParseUrl['path'];
286
287        $allowed_urlpath = array(
288            $kiyaku_urlpath,
289            $entry_urlpath,
290        );
291
292        if (SC_Display_Ex::detectDevice() !== DEVICE_TYPE_MOBILE
293            && !in_array($referer_urlpath, $allowed_urlpath)) {
294            return false;
295        }
296
297        return true;
298    }
299
300    /**
301     * 入力エラーのチェック.
302     *
303     * @param  array $arrRequest リクエスト値($_GET)
304     * @return array $arrErr エラーメッセージ配列
305     */
306    public function lfCheckError($arrRequest)
307    {
308        // パラメーター管理クラス
309        $objFormParam = new SC_FormParam_Ex();
310        // パラメーター情報の初期化
311        $objFormParam->addParam('郵便番号1', 'zip01', ZIP01_LEN, 'n', array('EXIST_CHECK', 'NUM_COUNT_CHECK', 'NUM_CHECK'));
312        $objFormParam->addParam('郵便番号2', 'zip02', ZIP02_LEN, 'n', array('EXIST_CHECK', 'NUM_COUNT_CHECK', 'NUM_CHECK'));
313        // // リクエスト値をセット
314        $arrData['zip01'] = $arrRequest['zip01'];
315        $arrData['zip02'] = $arrRequest['zip02'];
316        $objFormParam->setParam($arrData);
317        // エラーチェック
318        $arrErr = $objFormParam->checkError();
319
320        return $arrErr;
321    }
322}
Note: See TracBrowser for help on using the repository browser.