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

Revision 20095, 15.0 KB checked in by kimoto, 13 years ago (diff)

リファクタリング方針に従って修正 #979

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Id Revision Date
  • 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-2010 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_REALDIR . "pages/LC_Page.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 {
35
36    // {{{ properties
37
38    /** フォームパラメータの配列 */
39    var $objFormParam;
40
41
42    // }}}
43    // {{{ functions
44
45    /**
46     * Page を初期化する.
47     * @return void
48     */
49    function init() {
50        parent::init();
51        $masterData         = new SC_DB_MasterData_Ex();
52        $this->arrPref      = $masterData->getMasterData('mtb_pref');
53        $this->arrJob       = $masterData->getMasterData("mtb_job");
54        $this->arrReminder  = $masterData->getMasterData("mtb_reminder");
55
56        // 生年月日選択肢の取得
57        $objDate            = new SC_Date(START_BIRTH_YEAR, date("Y",strtotime("now")));
58        $this->arrYear      = $objDate->getYear('', 1950, '');
59        $this->arrMonth     = $objDate->getMonth(true);
60        $this->arrDay       = $objDate->getDay(true);
61
62        $this->httpCacheControl('nocache');
63
64        $this->isMobile     = Net_UserAgent_Mobile::isMobile();
65
66        // パラメータ管理クラス,パラメータ情報の初期化
67        $this->objFormParam = new SC_FormParam();
68        $this->lfInitParam();
69    }
70
71    /**
72     * Page のプロセス.
73     *
74     * @return void
75     */
76    function process() {
77        $this->action();
78        $this->sendResponse();
79    }
80
81    /* パラメータ情報の初期化 */
82    function lfInitParam() {
83
84        $this->objFormParam->addParam("お名前(姓)", 'name01', STEXT_LEN, "aKV", array("EXIST_CHECK", "NO_SPTAB", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK"));
85        $this->objFormParam->addParam("お名前(名)", 'name02', STEXT_LEN, "aKV", array("EXIST_CHECK", "NO_SPTAB", "SPTAB_CHECK" , "MAX_LENGTH_CHECK"));
86        $this->objFormParam->addParam("お名前(フリガナ・姓)", 'kana01', STEXT_LEN, "CKV", array("EXIST_CHECK", "NO_SPTAB", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK", "KANA_CHECK"));
87        $this->objFormParam->addParam("お名前(フリガナ・名)", 'kana02', STEXT_LEN, "CKV", array("EXIST_CHECK", "NO_SPTAB", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK", "KANA_CHECK"));
88        $this->objFormParam->addParam("パスワード", 'password', STEXT_LEN, "a", array("EXIST_CHECK", "SPTAB_CHECK" ,"ALNUM_CHECK"));
89        $this->objFormParam->addParam("パスワード確認用の質問", "reminder", STEXT_LEN, "n", array("EXIST_CHECK", "NUM_CHECK"));
90        $this->objFormParam->addParam("パスワード確認用の質問の答え", "reminder_answer", STEXT_LEN, "aKV", array("EXIST_CHECK","SPTAB_CHECK" , "MAX_LENGTH_CHECK"));
91        $this->objFormParam->addParam("郵便番号1", "zip01", ZIP01_LEN, "n", array("EXIST_CHECK", "SPTAB_CHECK" ,"NUM_CHECK", "NUM_COUNT_CHECK"));
92        $this->objFormParam->addParam("郵便番号2", "zip02", ZIP02_LEN, "n", array("EXIST_CHECK", "SPTAB_CHECK" ,"NUM_CHECK", "NUM_COUNT_CHECK"));
93        $this->objFormParam->addParam("都道府県", 'pref', INT_LEN, "n", array("EXIST_CHECK","NUM_CHECK"));
94        $this->objFormParam->addParam("住所1", "addr01", MTEXT_LEN, "aKV", array("EXIST_CHECK","SPTAB_CHECK" ,"MAX_LENGTH_CHECK"));
95        $this->objFormParam->addParam("住所2", "addr02", MTEXT_LEN, "aKV", array("EXIST_CHECK","SPTAB_CHECK" ,"MAX_LENGTH_CHECK"));
96        $this->objFormParam->addParam("お電話番号1", 'tel01', TEL_ITEM_LEN, "n", array("EXIST_CHECK","SPTAB_CHECK" ));
97        $this->objFormParam->addParam("お電話番号2", 'tel02', TEL_ITEM_LEN, "n", array("EXIST_CHECK","SPTAB_CHECK" ));
98        $this->objFormParam->addParam("お電話番号3", 'tel03', TEL_ITEM_LEN, "n", array("EXIST_CHECK","SPTAB_CHECK" ));
99        $this->objFormParam->addParam("性別", "sex", INT_LEN, "n", array("EXIST_CHECK", "NUM_CHECK"));
100        $this->objFormParam->addParam("職業", "job", INT_LEN, "n", array("NUM_CHECK"));
101        $this->objFormParam->addParam("年", "year", INT_LEN, "n", array("MAX_LENGTH_CHECK"), "", false);
102        $this->objFormParam->addParam("月", "month", INT_LEN, "n", array("MAX_LENGTH_CHECK"), "", false);
103        $this->objFormParam->addParam("日", "day", INT_LEN, "n", array("MAX_LENGTH_CHECK"), "", false);
104        $this->objFormParam->addParam("メールマガジン", "mailmaga_flg", INT_LEN, "n", array("EXIST_CHECK", "NUM_CHECK"));
105
106        if (SC_Display::detectDevice() !== DEVICE_TYPE_MOBILE){
107            $this->objFormParam->addParam("FAX番号1", 'fax01', TEL_ITEM_LEN, "n", array("SPTAB_CHECK"));
108            $this->objFormParam->addParam("FAX番号2", 'fax02', TEL_ITEM_LEN, "n", array("SPTAB_CHECK"));
109            $this->objFormParam->addParam("FAX番号3", 'fax03', TEL_ITEM_LEN, "n", array("SPTAB_CHECK"));
110            $this->objFormParam->addParam("パスワード(確認)", 'password02', STEXT_LEN, "a", array("EXIST_CHECK", "SPTAB_CHECK" ,"ALNUM_CHECK"), "", false);
111            $this->objFormParam->addParam('メールアドレス', "email", MTEXT_LEN, "a", array("NO_SPTAB", "EXIST_CHECK", "EMAIL_CHECK", "SPTAB_CHECK" ,"EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK"));
112            $this->objFormParam->addParam('メールアドレス(確認)', "email02", MTEXT_LEN, "a", array("NO_SPTAB", "EXIST_CHECK", "EMAIL_CHECK","SPTAB_CHECK" , "EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK"), "", false);
113        } else {
114            $this->objFormParam->addParam('メールアドレス', "email", MTEXT_LEN, "a", array("EXIST_CHECK", "EMAIL_CHECK", "NO_SPTAB" ,"EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK","MOBILE_EMAIL_CHECK"));
115        }
116    }
117
118    /**
119     * Page のプロセス
120     * @return void
121     */
122    function action() {
123        // PC時は規約ページからの遷移でなければエラー画面へ遷移する
124        if ($this->lfCheckReferer($_POST, $_SERVER['HTTP_REFERER']) === false) {
125            SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, "", true);
126        }
127
128        // mobile用(戻るボタンでの遷移かどうかを判定)
129        if (!empty($_POST["return"])) {
130            $_POST["mode"] = "return";
131        }
132
133        if ($_SERVER["REQUEST_METHOD"] == "POST") {
134            if (!SC_Helper_Session_Ex::isValidToken()) {
135                SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, "", true);
136            }
137        }
138
139        $this->objFormParam->setParam($_POST);    // POST値の取得
140        $this->objFormParam->convParam();
141        $this->objFormParam->toLower('email');
142        $this->objFormParam->toLower('email02');
143        $this->arrForm  = $this->objFormParam->getHashArray();
144
145        switch ($this->getMode()) {
146        case 'confirm':
147            //-- 確認
148            $this->arrErr = $this->lfErrorCheck($this->arrForm);
149            // 入力エラーなし
150            if(empty($this->arrErr)) {
151                //パスワード表示
152                $this->passlen      = SC_Utils_Ex::sfPassLen(strlen($this->arrForm['password']));
153
154                $this->tpl_mainpage = 'entry/confirm.tpl';
155                $this->tpl_title    = '会員登録(確認ページ)';
156            }
157            break;
158        case 'complete':
159            //-- 会員登録と完了画面
160            $this->arrErr = $this->lfErrorCheck($this->arrForm);
161            if(empty($this->arrErr)) {
162                $uniqid             = $this->lfRegistData($this->arrForm, $this->objFormParam->getDbArray());
163
164                $this->tpl_mainpage = 'entry/complete.tpl';
165                $this->tpl_title    = '会員登録(完了ページ)';
166                $this->lfSendMail($uniqid, $this->arrForm);
167
168                // 仮会員が無効の場合
169                if(CUSTOMER_CONFIRM_MAIL == false) {
170                    // ログイン状態にする
171                    $objCustomer = new SC_Customer();
172                    $objCustomer->setLogin($this->arrForm["email"]);
173                }
174
175                // 完了ページに移動させる。
176                SC_Response_Ex::sendRedirect('complete.php', array("ci" => SC_Helper_Customer_Ex::sfGetCustomerId($uniqid)));
177            }
178            break;
179        default:
180            break;
181        }
182
183        $this->transactionid = SC_Helper_Session_Ex::getToken();
184    }
185
186    /**
187     * デストラクタ.
188     *
189     * @return void
190     */
191    function destroy() {
192        parent::destroy();
193    }
194
195    // }}}
196    // {{{ protected functions
197    /**
198     * lfRegistData
199     *
200     * 会員情報の登録
201     *
202     * @access public
203     * @return void
204     */
205    function lfRegistData($arrForm, $arrResults) {
206        $objQuery   = SC_Query::getSingletonInstance();
207        //-- 登録実行
208        $sqlval     = $this->lfMakeSqlVal($arrForm, $arrResults);
209        $objQuery->begin();
210        SC_Helper_Customer_Ex::sfEditCustomerData($sqlval);
211        $objQuery->commit();
212
213        return $sqlval["secret_key"];
214    }
215
216
217    /**
218     * 会員登録に必要なSQLパラメータの配列を生成する.
219     *
220     * フォームに入力された情報を元に, SQLパラメータの配列を生成する.
221     * モバイル端末の場合は, email を email_mobile にコピーし,
222     * mobile_phone_id に携帯端末IDを格納する.
223     *
224     * @access protected
225     * @param array $arrForm フォームパラメータの配列
226     * @param array $arrResults 結果用の配列. SC_FormParam::getDbArray() の結果
227     * @return array SQLパラメータの配列
228     * @see SC_FormParam::getDbArray()
229     */
230    function lfMakeSqlVal($arrForm, $arrResults) {
231        // 生年月日の作成
232        $arrResults['birth']  = SC_Utils_Ex::sfGetTimestamp($arrForm['year'], $arrForm['month'], $arrForm['day']);
233
234        // 仮会員 1 本会員 2
235        $arrResults["status"] = (CUSTOMER_CONFIRM_MAIL == true) ? "1" : "2";
236
237        /*
238         * secret_keyは、テーブルで重複許可されていない場合があるので、
239         * 本会員登録では利用されないがセットしておく。
240         */
241        $arrResults["secret_key"] = SC_Helper_Customer_Ex::sfGetUniqSecretKey();
242
243        // 入会時ポイント
244        $CONF = SC_Helper_DB_Ex::sfGetBasisData();
245        $arrResults["point"] = $CONF["welcome_point"];
246
247        if (SC_Display::detectDevice() == DEVICE_TYPE_MOBILE) {
248            // 携帯メールアドレス
249            $arrResults['email_mobile']     = $arrResults['email'];
250            // PHONE_IDを取り出す
251            $arrResults['mobile_phone_id']  =  SC_MobileUserAgent::getId();
252        }
253        return $arrResults;
254    }
255
256
257    /**
258     * 会員登録完了メール送信する
259     *
260     * @access public
261     * @return void
262     */
263    function lfSendMail($uniqid, $arrForm){
264        $CONF           = SC_Helper_DB_Ex::sfGetBasisData();
265
266        $objMailText    = new SC_SiteView();
267        $objMailText->assign("CONF", $CONF);
268        $objMailText->assign("name01", $arrForm['name01']);
269        $objMailText->assign("name02", $arrForm['name02']);
270        $objMailText->assign("uniqid", $uniqid);
271        $objMailText->assignobj($this);
272
273        $objHelperMail  = new SC_Helper_Mail_Ex();
274
275        // 仮会員が有効の場合
276        if(CUSTOMER_CONFIRM_MAIL == true) {
277            $subject        = $objHelperMail->sfMakeSubject('会員登録のご確認');
278            $toCustomerMail = $objMailText->fetch("mail_templates/customer_mail.tpl");
279        } else {
280            $subject        = $objHelperMail->sfMakeSubject('会員登録のご完了');
281            $toCustomerMail = $objMailText->fetch("mail_templates/customer_regist_mail.tpl");
282        }
283
284        $objMail = new SC_SendMail();
285        $objMail->setItem(
286            ''                    // 宛先
287            , $subject              // サブジェクト
288            , $toCustomerMail       // 本文
289            , $CONF["email03"]      // 配送元アドレス
290            , $CONF["shop_name"]    // 配送元 名前
291            , $CONF["email03"]      // reply_to
292            , $CONF["email04"]      // return_path
293            , $CONF["email04"]      // Errors_to
294            , $CONF["email01"]      // Bcc
295        );
296        // 宛先の設定
297        $objMail->setTo($arrForm["email"],
298                        $arrForm["name01"] . $arrForm["name02"] ." 様");
299
300        $objMail->sendMail();
301    }
302
303    /**
304     * lfErrorCheck
305     *
306     * 入力エラーチェック
307     *
308     * @param mixed $array
309     * @access public
310     * @return void
311     */
312    function lfErrorCheck($arrForm) {
313
314        // 入力データを渡す。
315        $objErr = new SC_CheckError($arrForm);
316        $objErr->arrErr = $this->objFormParam->checkError();
317
318        $objErr->doFunc(array("お電話番号", "tel01", "tel02", "tel03"),array("TEL_CHECK"));
319        $objErr->doFunc(array("郵便番号", "zip01", "zip02"), array("ALL_EXIST_CHECK"));
320        $objErr->doFunc(array("生年月日", "year", "month", "day"), array("CHECK_BIRTHDAY"));
321
322        if (SC_Display::detectDevice() !== DEVICE_TYPE_MOBILE){
323            $objErr->doFunc(array('パスワード', 'パスワード(確認)', "password", "password02") ,array("EQUAL_CHECK"));
324            $objErr->doFunc(array('メールアドレス', 'メールアドレス(確認)', "email", "email02") ,array("EQUAL_CHECK"));
325            $objErr->doFunc(array("FAX番号", "fax01", "fax02", "fax03") ,array("TEL_CHECK"));
326        }
327
328        // 現会員の判定 → 現会員もしくは仮登録中は、メアド一意が前提になってるので同じメアドで登録不可
329        $objErr->doFunc(array("メールアドレス", "email"), array("CHECK_REGIST_CUSTOMER_EMAIL"));
330
331        return $objErr->arrErr;
332    }
333
334    /**
335     * kiyaku.php からの遷移の妥当性をチェックする
336     *
337     * 以下の内容をチェックし, 妥当であれば true を返す.
338     * 1. 規約ページからの遷移かどうか
339     * 2. PC及びスマートフォンかどうか
340     * 3. $post に何も含まれていないかどうか
341     *
342     * @access protected
343     * @param array $post $_POST のデータ
344     * @param string $referer $_SERVER['HTTP_REFERER'] のデータ
345     * @return boolean kiyaku.php からの妥当な遷移であれば true
346     */
347    function lfCheckReferer(&$post, $referer){
348
349        if (SC_Display::detectDevice() !== DEVICE_TYPE_MOBILE
350            && empty($post)
351            && (preg_match('/kiyaku.php/', basename($referer)) === 0)) {
352            return false;
353            }
354        return true;
355    }
356}
Note: See TracBrowser for help on using the repository browser.