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

Revision 16401, 9.7 KB checked in by nanasess, 17 years ago (diff)

不要な $tpl_css を削除

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