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

Revision 21596, 9.9 KB checked in by Seasoft, 12 years ago (diff)

#1613 (typo修正・ソース整形・ソースコメントの改善)

  • 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-2011 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
24// {{{ requires
25require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';
26
27/**
28 * 会員登録のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id:LC_Page_Entry.php 15532 2007-08-31 14:39:46Z nanasess $
33 */
34class LC_Page_Entry extends LC_Page_Ex {
35
36    // {{{ properties
37
38    // }}}
39    // {{{ functions
40
41    /**
42     * Page を初期化する.
43     * @return void
44     */
45    function init() {
46        parent::init();
47        $masterData         = new SC_DB_MasterData_Ex();
48        $this->arrPref      = $masterData->getMasterData('mtb_pref');
49        $this->arrJob       = $masterData->getMasterData('mtb_job');
50        $this->arrReminder  = $masterData->getMasterData('mtb_reminder');
51
52        // 生年月日選択肢の取得
53        $objDate            = new SC_Date_Ex(BIRTH_YEAR, date('Y',strtotime('now')));
54        $this->arrYear      = $objDate->getYear('', START_BIRTH_YEAR, '');
55        $this->arrMonth     = $objDate->getMonth(true);
56        $this->arrDay       = $objDate->getDay(true);
57
58        $this->httpCacheControl('nocache');
59    }
60
61    /**
62     * Page のプロセス.
63     *
64     * @return void
65     */
66    function process() {
67        parent::process();
68        $this->action();
69        $this->sendResponse();
70    }
71
72    /**
73     * Page のプロセス
74     * @return void
75     */
76    function action() {
77        // フックポイント.
78        $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
79        $objPlugin->doAction('lc_page_entry_action_start', array($this));
80
81        $objFormParam = new SC_FormParam_Ex();
82
83        SC_Helper_Customer_Ex::sfCustomerEntryParam($objFormParam);
84        $objFormParam->setParam($_POST);
85        $arrForm  = $objFormParam->getHashArray();
86
87        // PC時は規約ページからの遷移でなければエラー画面へ遷移する
88        if ($this->lfCheckReferer($arrForm, $_SERVER['HTTP_REFERER']) === false) {
89            SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, '', true);
90        }
91
92        // mobile用(戻るボタンでの遷移かどうかを判定)
93        if (!empty($arrForm['return'])) {
94            $_POST['mode'] = 'return';
95        }
96
97        switch ($this->getMode()) {
98            case 'confirm':
99                //-- 確認
100                $this->arrErr = SC_Helper_Customer_Ex::sfCustomerEntryErrorCheck($objFormParam);
101                $this->arrForm  = $objFormParam->getHashArray();
102                // 入力エラーなし
103                if (empty($this->arrErr)) {
104                    //パスワード表示
105                    $this->passlen      = SC_Utils_Ex::sfPassLen(strlen($this->arrForm['password']));
106
107                    $this->tpl_mainpage = 'entry/confirm.tpl';
108                    $this->tpl_title    = '会員登録(確認ページ)';
109                }
110                break;
111            case 'complete':
112                //-- 会員登録と完了画面
113                $this->arrErr = SC_Helper_Customer_Ex::sfCustomerEntryErrorCheck($objFormParam);
114                $this->arrForm  = $objFormParam->getHashArray();
115                if (empty($this->arrErr)) {
116
117                    $uniqid             = $this->lfRegistCustomerData($this->lfMakeSqlVal($objFormParam));
118
119                    $this->tpl_mainpage = 'entry/complete.tpl';
120                    $this->tpl_title    = '会員登録(完了ページ)';
121                    $this->lfSendMail($uniqid, $this->arrForm);
122
123                    // 仮会員が無効の場合
124                    if (CUSTOMER_CONFIRM_MAIL == false) {
125                        // ログイン状態にする
126                        $objCustomer = new SC_Customer_Ex();
127                        $objCustomer->setLogin($this->arrForm['email']);
128                    }
129                    // フックポイント.
130                    $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
131                    $objPlugin->doAction('lc_page_entry_action_complete', array($this));
132
133                    // 完了ページに移動させる。
134                    SC_Response_Ex::sendRedirect('complete.php', array('ci' => SC_Helper_Customer_Ex::sfGetCustomerId($uniqid)));
135                }
136                break;
137            case 'return':
138                $this->arrForm  = $objFormParam->getHashArray();
139                break;
140            default:
141                break;
142        }
143        // フックポイント.
144        $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
145        $objPlugin->doAction('lc_page_entry_action_end', array($this));
146    }
147
148    /**
149     * デストラクタ.
150     *
151     * @return void
152     */
153    function destroy() {
154        parent::destroy();
155    }
156
157    // }}}
158    // {{{ protected functions
159    /**
160     * 会員情報の登録
161     *
162     * @access private
163     * @return uniqid
164     */
165    function lfRegistCustomerData($sqlval) {
166        SC_Helper_Customer_Ex::sfEditCustomerData($sqlval);
167        return $sqlval['secret_key'];
168    }
169
170    /**
171     * 会員登録に必要なSQLパラメーターの配列を生成する.
172     *
173     * フォームに入力された情報を元に, SQLパラメーターの配列を生成する.
174     * モバイル端末の場合は, email を email_mobile にコピーし,
175     * mobile_phone_id に携帯端末IDを格納する.
176     *
177     * @param mixed $objFormParam
178     * @access private
179     * @return $arrResults
180     */
181    function lfMakeSqlVal(&$objFormParam) {
182        $arrForm                = $objFormParam->getHashArray();
183        $arrResults             = $objFormParam->getDbArray();
184
185        // 生年月日の作成
186        $arrResults['birth']    = SC_Utils_Ex::sfGetTimestamp($arrForm['year'], $arrForm['month'], $arrForm['day']);
187
188        // 仮会員 1 本会員 2
189        $arrResults['status']   = (CUSTOMER_CONFIRM_MAIL == true) ? '1' : '2';
190
191        /*
192         * secret_keyは、テーブルで重複許可されていない場合があるので、
193         * 本会員登録では利用されないがセットしておく。
194         */
195        $arrResults['secret_key'] = SC_Helper_Customer_Ex::sfGetUniqSecretKey();
196
197        // 入会時ポイント
198        $CONF = SC_Helper_DB_Ex::sfGetBasisData();
199        $arrResults['point'] = $CONF['welcome_point'];
200
201        if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) {
202            // 携帯メールアドレス
203            $arrResults['email_mobile']     = $arrResults['email'];
204            // PHONE_IDを取り出す
205            $arrResults['mobile_phone_id']  =  SC_MobileUserAgent_Ex::getId();
206        }
207        return $arrResults;
208    }
209
210    /**
211     * 会員登録完了メール送信する
212     *
213     * @access private
214     * @return void
215     */
216    function lfSendMail($uniqid, $arrForm) {
217        $CONF           = SC_Helper_DB_Ex::sfGetBasisData();
218
219        $objMailText    = new SC_SiteView_Ex();
220        $objMailText->assign('CONF', $CONF);
221        $objMailText->assign('name01', $arrForm['name01']);
222        $objMailText->assign('name02', $arrForm['name02']);
223        $objMailText->assign('uniqid', $uniqid);
224        $objMailText->assignobj($this);
225
226        $objHelperMail  = new SC_Helper_Mail_Ex();
227
228        // 仮会員が有効の場合
229        if (CUSTOMER_CONFIRM_MAIL == true) {
230            $subject        = $objHelperMail->sfMakeSubject('会員登録のご確認');
231            $toCustomerMail = $objMailText->fetch('mail_templates/customer_mail.tpl');
232        } else {
233            $subject        = $objHelperMail->sfMakeSubject('会員登録のご完了');
234            $toCustomerMail = $objMailText->fetch('mail_templates/customer_regist_mail.tpl');
235        }
236
237        $objMail = new SC_SendMail();
238        $objMail->setItem(
239            ''                    // 宛先
240            , $subject              // サブジェクト
241            , $toCustomerMail       // 本文
242            , $CONF['email03']      // 配送元アドレス
243            , $CONF['shop_name']    // 配送元 名前
244            , $CONF['email03']      // reply_to
245            , $CONF['email04']      // return_path
246            , $CONF['email04']      // Errors_to
247            , $CONF['email01']      // Bcc
248        );
249        // 宛先の設定
250        $objMail->setTo($arrForm['email'],
251                        $arrForm['name01'] . $arrForm['name02'] .' 様');
252
253        $objMail->sendMail();
254    }
255
256    /**
257     * kiyaku.php からの遷移の妥当性をチェックする
258     *
259     * 以下の内容をチェックし, 妥当であれば true を返す.
260     * 1. 規約ページからの遷移かどうか
261     * 2. PC及びスマートフォンかどうか
262     * 3. $post に何も含まれていないかどうか
263     *
264     * @access protected
265     * @param array $post $_POST のデータ
266     * @param string $referer $_SERVER['HTTP_REFERER'] のデータ
267     * @return boolean kiyaku.php からの妥当な遷移であれば true
268     */
269    function lfCheckReferer(&$post, $referer) {
270
271        if (SC_Display_Ex::detectDevice() !== DEVICE_TYPE_MOBILE
272            && empty($post)
273            && (preg_match('/kiyaku.php/', basename($referer)) === 0)) {
274            return false;
275            }
276        return true;
277    }
278}
Note: See TracBrowser for help on using the repository browser.