source: branches/feature-module-update/data/class/pages/regist/LC_Page_Regist.php @ 16582

Revision 16582, 10.5 KB checked in by nanasess, 16 years ago (diff)

ライセンス表記変更

  • 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-2007 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_PATH . "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    var $arrInfo;
40
41    /** 設定情報 */
42    var $CONF;
43
44    // }}}
45    // {{{ functions
46
47    /**
48     * Page を初期化する.
49     *
50     * @return void
51     */
52    function init() {
53        parent::init();
54    }
55
56    /**
57     * Page のプロセス.
58     *
59     * @return void
60     */
61    function process() {
62        $objQuery = new SC_Query();
63        $objView = new SC_SiteView();
64        $objSiteInfo = $objView->objSiteInfo;
65        $objCustomer = new SC_Customer();
66        $objDb = new SC_Helper_DB_Ex();
67        $this->CONF = $objDb->sf_getBasisData();
68        $this->arrInfo = $objSiteInfo->data;
69
70        // キャンペーンからの登録の場合の処理
71        if($_GET["cp"] != "") {
72            $etc_val = array("cp" => $_GET['cp']);
73        }
74
75        //-- 本登録完了のためにメールから接続した場合
76        if ($_GET["mode"] == "regist") {
77
78            //-- 入力チェック
79            $this->arrErr = $this->lfErrorCheck($_GET);
80            if ($this->arrErr) {
81                $this->tpl_mainpage = 'regist/error.tpl';
82                $this->tpl_css = "/css/layout/regist/error.css";
83                $this->tpl_title = 'エラー';
84
85            } else {
86                $registSecretKey = $this->lfRegistData($_GET);          //本会員登録(フラグ変更)
87                $this->lfSendRegistMail($registSecretKey);              //本会員登録完了メール送信
88
89                // ログイン済みの状態にする。
90                $email = $objQuery->get("dtb_customer", "email", "secret_key = ?", array($registSecretKey));
91                $objCustomer->setLogin($email);
92                $this->sendRedirect($this->getLocation("./complete.php", $etc_val));
93                exit;
94            }
95
96        //-- それ以外のアクセスは無効とする
97        } else {
98            $this->arrErr["id"] = "無効なアクセスです。";
99            $this->tpl_mainpage = 'regist/error.tpl';
100            $this->tpl_css = "/css/layout/regist/error.css";
101            $this->tpl_title = 'エラー';
102
103        }
104
105        //---- ページ表示
106        $objView->assignobj($this);
107        $objView->display(SITE_FRAME);
108    }
109
110
111    /**
112     * モバイルページを初期化する.
113     *
114     * @return void
115     */
116    function mobileInit() {
117    }
118
119    /**
120     * Page のプロセス(モバイル).
121     *
122     * @return void
123     */
124    function mobileProcess() {
125        $objQuery = new SC_Query();
126        $objView = new SC_MobileView();
127        $objSiteInfo = $objView->objSiteInfo;
128        $objCustomer = new SC_Customer();
129        $objDb = new SC_Helper_DB_Ex();
130        $this->CONF = $objDb->sf_getBasisData();
131        $arrInfo = $objSiteInfo->data;
132
133        //-- 本登録完了のためにメールから接続した場合
134        if ($_GET["mode"] == "regist") {
135
136            //-- 入力チェック
137            $this->arrErr = $this->lfErrorCheck($_GET);
138            if ($this->arrErr) {
139                $this->tpl_mainpage = 'regist/error.tpl';
140                $this->tpl_title = 'エラー';
141
142            } else {
143                $registSecretKey = $this->lfRegistData($_GET);          //本会員登録(フラグ変更)
144                $this->lfSendRegistMail($registSecretKey);              //本会員登録完了メール送信
145
146                // ログイン済みの状態にする。
147
148                $email = $objQuery->get("dtb_customer", "email", "secret_key = ?", array($registSecretKey));
149                $objCustomer->setLogin($email);
150                $this->sendRedirect($this->getLocation("./complete.php"), true);
151                exit;
152            }
153
154            //-- それ以外のアクセスは無効とする
155        } else {
156            $this->arrErr["id"] = "無効なアクセスです。";
157            $this->tpl_mainpage = 'regist/error.tpl';
158            $this->tpl_css = "/css/layout/regist/error.css";
159            $this->tpl_title = 'エラー';
160
161        }
162
163        //---- ページ表示
164        $objView->assignobj($this);
165        $objView->display(SITE_FRAME);
166    }
167
168    /**
169     * デストラクタ.
170     *
171     * @return void
172     */
173    function destroy() {
174        parent::destroy();
175    }
176
177    //---- 登録
178    function lfRegistData($array) {
179        $objQuery = new SC_Query();
180        $this->arrInfo;
181
182        do {
183            $secret = SC_Utils_Ex::sfGetUniqRandomId("r");
184        } while( ($result = $objQuery->getOne("SELECT COUNT(*) FROM dtb_customer WHERE secret_key = ?", array($secret)) ) != 0);
185
186        $sql = "SELECT email FROM dtb_customer WHERE secret_key = ? AND status = 1";
187        $email = $objQuery->getOne($sql, array($array["id"]));
188
189        $objQuery->begin();
190        $arrRegist["secret_key"] = $secret; // 本登録ID発行
191        $arrRegist["status"] = 2;
192        $arrRegist["update_date"] = "NOW()";
193
194        $where = "secret_key = ? AND status = 1";
195
196        $arrRet = $objQuery->select("point", "dtb_customer", $where, array($array["id"]));
197        // 会員登録時の加算ポイント(購入時会員登録の場合は、ポイント加算)
198        $arrRegist['point'] = $arrRet[0]['point'] + $arrInfo['welcome_point'];
199
200        $objQuery->update("dtb_customer", $arrRegist, $where, array($array["id"]));
201
202        /* 購入時の自動会員登録は行わないためDEL
203        // 購入時登録の場合、その回の購入を会員購入とみなす。
204        // 会員情報の読み込み
205        $where1 = "secret_key = ? AND status = 2";
206        $customer = $objQuery->select("*", "dtb_customer", $where1, array($secret));
207        // 初回購入情報の読み込み
208        $order_temp_id = $objQuery->get("dtb_order_temp", "order_temp_id");
209        // 購入情報の更新
210        if ($order_temp_id != null) {
211            $arrCustomer['customer_id'] = $customer[0]['customer_id'];
212            $where3 = "order_temp_id = ?";
213            $objQuery->update("dtb_order_temp", $arrCustomer, $where3, array($order_temp_id));
214            $objQuery->update("dtb_order", $arrCustomer, $where3, array($order_temp_id));
215        }
216        */
217
218        $sql = "SELECT mailmaga_flg FROM dtb_customer WHERE email = ?";
219        $result = $objQuery->getOne($sql, array($email));
220
221        switch($result) {
222        // 仮HTML
223        case '4':
224            $arrRegistMail["mailmaga_flg"] = 1;
225            break;
226        // 仮TEXT
227        case '5':
228            $arrRegistMail["mailmaga_flg"] = 2;
229            break;
230        // 仮なし
231        case '6':
232            $arrRegistMail["mailmaga_flg"] = 3;
233            break;
234        default:
235            $arrRegistMail["mailmaga_flg"] = $result;
236            break;
237        }
238
239        $objQuery->update("dtb_customer", $arrRegistMail, "email = " . SC_Utils_Ex::sfQuoteSmart($email). " AND del_flg = 0");
240        $objQuery->commit();
241
242        return $secret;     // 本登録IDを返す
243    }
244
245    //---- 入力エラーチェック
246    function lfErrorCheck($array) {
247
248        $objQuery = new SC_Query();
249        $objErr = new SC_CheckError($array);
250
251        $objErr->doFunc(array("仮登録ID", 'id'), array("EXIST_CHECK"));
252        if (! EregI("^[[:alnum:]]+$",$array["id"] )) {
253            $objErr->arrErr["id"] = "無効なURLです。メールに記載されている本会員登録用URLを再度ご確認ください。";
254        }
255        if (! $objErr->arrErr["id"]) {
256
257            $sql = "SELECT customer_id FROM dtb_customer WHERE secret_key = ? AND status = 1 AND del_flg = 0";
258            $result = $objQuery->getOne($sql, array($array["id"]));
259
260            if (! is_numeric($result)) {
261                $objErr->arrErr["id"] .= "※ 既に会員登録が完了しているか、無効なURLです。<br>";
262                return $objErr->arrErr;
263
264            }
265        }
266
267        return $objErr->arrErr;
268    }
269
270    //---- 正会員登録完了メール送信
271    function lfSendRegistMail($registSecretKey) {
272        $objQuery = new SC_Query();
273        $objHelperMail = new SC_Helper_Mail_Ex();
274
275        //-- 姓名を取得
276        $sql = "SELECT email, name01, name02 FROM dtb_customer WHERE secret_key = ?";
277        $result = $objQuery->getAll($sql, array($registSecretKey));
278        $data = $result[0];
279
280        //-- メール送信
281        $objMailText = new SC_SiteView();
282        $objMailText->assign("CONF", $this->CONF);
283        $objMailText->assign("name01", $data["name01"]);
284        $objMailText->assign("name02", $data["name02"]);
285        $toCustomerMail = $objMailText->fetch("mail_templates/customer_regist_mail.tpl");
286        $subject = $objHelperMail->sfMakesubject($objQuery, $objMailText, $this, '会員登録が完了しました。');
287        $objMail = new SC_SendMail();
288
289        $objMail->setItem(
290                              ''                                // 宛先
291                            , $subject                          // サブジェクト
292                            , $toCustomerMail                   // 本文
293                            , $CONF["email03"]                  // 配送元アドレス
294                            , $CONF["shop_name"]                // 配送元 名前
295                            , $CONF["email03"]                  // reply_to
296                            , $CONF["email04"]                  // return_path
297                            , $CONF["email04"]                  //  Errors_to
298                        );
299        // 宛先の設定
300        $name = $data["name01"] . $data["name02"] ." 様";
301        $objMail->setTo($data["email"], $name);
302        $objMail->sendMail();
303    }
304}
305?>
Note: See TracBrowser for help on using the repository browser.