source: branches/version-2_5-dev/data/class/pages/regist/LC_Page_Regist.php @ 20089

Revision 20089, 5.6 KB checked in by kimoto, 13 years ago (diff)

仮会員登録処理リファクタリング #985

  • Property svn:eol-style set to LF
  • 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$
33 */
34class LC_Page_Regist extends LC_Page {
35
36    // {{{ properties
37
38    // }}}
39    // {{{ functions
40
41    /**
42     * Page を初期化する.
43     *
44     * @return void
45     */
46    function init() {
47        parent::init();
48    }
49
50    /**
51     * Page のプロセス.
52     *
53     * @return void
54     */
55    function process() {
56        parent::process();
57        $this->action();
58        $this->sendResponse();
59    }
60
61    /**
62     * Page のAction.
63     *
64     * @return void
65     */
66    function action() {
67
68        switch ($this->getMode()) {
69        case 'regist':
70        //-- 本登録完了のためにメールから接続した場合
71            //-- 入力チェック
72            $this->arrErr       = $this->lfErrorCheck($_GET);
73            if ($this->arrErr) SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, "", true, $this->arrErr["id"]);
74
75            $registSecretKey    = $this->lfRegistData($_GET);       //本会員登録(フラグ変更)
76            $this->lfSendRegistMail($registSecretKey);              //本会員登録完了メール送信
77
78            SC_Response_Ex::sendRedirect('complete.php', array("ci" => SC_Helper_Customer_Ex::sfGetCustomerId($registSecretKey)));
79            break;
80        //-- それ以外のアクセスは無効とする
81        default:
82            SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, "", true, "無効なアクセスです。");
83            break;
84        }
85    }
86
87    /**
88     * デストラクタ.
89     *
90     * @return void
91     */
92    function destroy() {
93        parent::destroy();
94    }
95
96    /**
97     * lfRegistData
98     *
99     * 仮会員を本会員にUpdateする
100     *
101     * @param mixed $array
102     * @access public
103     * @return void
104     */
105    function lfRegistData($array) {
106        $objQuery = new SC_Query();
107
108        $arrRegist["secret_key"]    = SC_Helper_Customer_Ex::sfGetUniqSecretKey(); // 本登録ID発行
109        $arrRegist["status"]        = 2;
110        $arrRegist["update_date"]   = "NOW()";
111
112        $objQuery->begin();
113        $objQuery->update("dtb_customer", $arrRegist, "secret_key = ? AND status = 1", array($array["id"]));
114        $objQuery->commit();
115
116        return $arrRegist["secret_key"];        // 本登録IDを返す
117    }
118
119    //---- 入力エラーチェック
120    function lfErrorCheck($array) {
121        $objErr     = new SC_CheckError($array);
122
123        if (preg_match("/^[[:alnum:]]+$/", $array["id"])) {
124
125            if (!is_numeric(SC_Helper_Customer_Ex::sfGetCustomerId($array["id"], true))) {
126                $objErr->arrErr["id"] = "※ 既に会員登録が完了しているか、無効なURLです。<br>";
127            }
128
129        } else {
130            $objErr->arrErr["id"] = "無効なURLです。メールに記載されている本会員登録用URLを再度ご確認ください。";
131        }
132        return $objErr->arrErr;
133    }
134
135    //---- 正会員登録完了メール送信
136    function lfSendRegistMail($registSecretKey) {
137        $objCustomer    = new SC_Customer();
138        $objQuery       = new SC_Query();
139        $objHelperMail  = new SC_Helper_Mail_Ex();
140        $this->CONF     = SC_Helper_DB_Ex::sfGetBasisData();
141
142        //-- 会員データを取得
143        $result         = $objQuery->select("*", "dtb_customer", "secret_key = ?", array($registSecretKey));
144        $data           = $result[0];
145        $objCustomer->setLogin($data['email']);
146
147        //-- メール送信
148        $objMailText    = new SC_SiteView();
149        $objMailText->assign("CONF", $this->CONF);
150        $objMailText->assign("name01", $data["name01"]);
151        $objMailText->assign("name02", $data["name02"]);
152        $toCustomerMail = $objMailText->fetch("mail_templates/customer_regist_mail.tpl");
153        $subject = $objHelperMail->sfMakesubject('会員登録が完了しました。');
154        $objMail = new SC_SendMail();
155
156        $objMail->setItem(
157                              ''                                // 宛先
158                            , $subject                          // サブジェクト
159                            , $toCustomerMail                   // 本文
160                            , $this->CONF["email03"]            // 配送元アドレス
161                            , $this->CONF["shop_name"]          // 配送元 名前
162                            , $this->CONF["email03"]            // reply_to
163                            , $this->CONF["email04"]            // return_path
164                            , $this->CONF["email04"]            // Errors_to
165                        );
166        // 宛先の設定
167        $name = $data["name01"] . $data["name02"] ." 様";
168        $objMail->setTo($data["email"], $name);
169        $objMail->sendMail();
170    }
171}
172?>
Note: See TracBrowser for help on using the repository browser.