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

Revision 15215, 8.0 KB checked in by nanasess, 17 years ago (diff)

LC_Page のクラス化対応

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