source: branches/version-2_13-dev/data/class/pages/entry/LC_Page_Entry.php @ 23040

Revision 23040, 11.2 KB checked in by nanasess, 11 years ago (diff)

#2234 (非会員お客様情報入力テンプレートと機能の共通化)

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