source: branches/version-2_5-dev/data/class/pages/mypage/LC_Page_Mypage_Change.php @ 19995

Revision 19995, 14.1 KB checked in by AMUAMU, 13 years ago (diff)

#335 (パスワードリマインダの改修) の解決

  • 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_Mypage_Change extends LC_Page {
35
36
37    // }}}
38    // {{{ functions
39
40    /**
41     * Page を初期化する.
42     *
43     * @return void
44     */
45    function init() {
46        parent::init();
47        $this->tpl_title = 'MYページ';
48        $this->tpl_subtitle = '会員登録内容変更(入力ページ)';
49        $this->tpl_navi = TEMPLATE_REALDIR . 'mypage/navi.tpl';
50        $this->tpl_mainno = 'mypage';
51        $this->tpl_mypageno = 'change';
52
53        $masterData = new SC_DB_MasterData_Ex();
54        $this->arrReminder = $masterData->getMasterData("mtb_reminder");
55        $this->arrPref = $masterData->getMasterData('mtb_pref');
56        $this->arrJob = $masterData->getMasterData("mtb_job");
57        $this->arrMAILMAGATYPE = $masterData->getMasterData("mtb_mail_magazine_type");
58        $this->arrSex = $masterData->getMasterData("mtb_sex");
59        $this->httpCacheControl('nocache');
60       
61        // 生年月日選択肢の取得
62        $objDate = new SC_Date(START_BIRTH_YEAR, date("Y",strtotime("now")));
63        $this->arrYear = $objDate->getYear('', 1950, '');
64        $this->arrMonth = $objDate->getMonth(true);
65        $this->arrDay = $objDate->getDay(true);
66       
67        $this->isMobile = Net_UserAgent_Mobile::isMobile();
68    }
69
70    /**
71     * Page のプロセス.
72     *
73     * @return void
74     */
75    function process() {
76        $this->action();
77        $this->sendResponse();
78    }
79   
80    /**
81     * Page のプロセス
82     * @return void
83     */
84    function action() {
85        $objDb = new SC_Helper_DB_Ex();
86        $CONF = $objDb->sfGetBasisData();
87       
88        $objQuery = new SC_Query();
89        $objCustomer = new SC_Customer();
90       
91        // ログインチェック
92        if (!$objCustomer->isLoginSuccess(true)){
93            SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
94        }else {
95            //マイページトップ顧客情報表示用
96            $this->CustomerName1 = $objCustomer->getvalue('name01');
97            $this->CustomerName2 = $objCustomer->getvalue('name02');
98            $this->CustomerPoint = $objCustomer->getvalue('point');
99        }
100       
101        // mobile用(戻るボタンでの遷移かどうかを判定)
102        if (!empty($_POST["return"])) {
103            $_POST["mode"] = "return";
104        }
105       
106        // パラメータ管理クラス,パラメータ情報の初期化
107        $this->objFormParam = new SC_FormParam();
108        $this->lfInitParam();
109        $this->objFormParam->setParam($_POST);    // POST値の取得
110       
111       
112        if ($_SERVER["REQUEST_METHOD"] == "POST") {
113           
114            //CSRF対策
115            /*
116            if (!SC_Helper_Session_Ex::isValidToken()) {
117                SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, "", true);
118            }
119            */
120                       
121            $this->objFormParam->convParam();
122            $this->objFormParam->toLower('email');
123            $this->objFormParam->toLower('email02');
124            $this->objFormParam->toLower('email_mobile');
125            $this->objFormParam->toLower('email_mobile02');
126            $this->arrForm = $this->objFormParam->getHashArray();
127                 
128            //-- 確認
129            if ($_POST["mode"] == "confirm") {
130
131                $this->arrErr = $this->lfErrorCheck();
132               
133                // 入力エラーなし
134                if(count($this->arrErr) == 0) {
135                   
136                    $this->list_data = $this->objFormParam->getHashArray();
137               
138                    //パスワード表示
139                    $passlen = strlen($this->arrForm['password']);
140                    $this->passlen = SC_Utils_Ex::lfPassLen($passlen);
141   
142                    $this->tpl_mainpage = 'mypage/change_confirm.tpl';
143                    $this->tpl_title = '会員登録(確認ページ)';
144                }
145
146            } elseif ($_POST["mode"] == "complete") {
147                //-- 会員登録と完了画面
148           
149                // 会員情報の登録
150                $this->CONF = $CONF;
151                $this->lfRegistData();
152               
153                // 完了ページに移動させる。
154                SC_Response_Ex::sendRedirect('change_complete.php');
155                exit;
156               
157            }
158        } else {
159            $this->arrForm = $this->lfGetCustomerData();
160            $this->arrForm['password'] = DEFAULT_PASSWORD;
161            $this->arrForm['password02'] = DEFAULT_PASSWORD;
162            $this->arrForm['reminder_answer'] = DEFAULT_PASSWORD;
163        }
164        $this->transactionid = SC_Helper_Session_Ex::getToken();
165    }
166
167    /**
168     * デストラクタ.
169     *
170     * @return void
171     */
172    function destroy() {
173        parent::destroy();
174    }
175
176    /* パラメータ情報の初期化 */
177    function lfInitParam() {
178                         
179        $this->objFormParam->addParam("お名前(姓)", 'name01', STEXT_LEN, "aKV", array("EXIST_CHECK", "NO_SPTAB", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK"));
180        $this->objFormParam->addParam("お名前(名)", 'name02', STEXT_LEN, "aKV", array("EXIST_CHECK", "NO_SPTAB", "SPTAB_CHECK" , "MAX_LENGTH_CHECK"));
181        $this->objFormParam->addParam("お名前(フリガナ・姓)", 'kana01', STEXT_LEN, "CKV", array("EXIST_CHECK", "NO_SPTAB", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK", "KANA_CHECK"));
182        $this->objFormParam->addParam("お名前(フリガナ・名)", 'kana02', STEXT_LEN, "CKV", array("EXIST_CHECK", "NO_SPTAB", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK", "KANA_CHECK"));
183        $this->objFormParam->addParam("パスワード", 'password', STEXT_LEN, "a", array("EXIST_CHECK", "SPTAB_CHECK" ,"ALNUM_CHECK"));
184        $this->objFormParam->addParam("パスワード確認用の質問", "reminder", STEXT_LEN, "n", array("EXIST_CHECK", "NUM_CHECK"));
185        $this->objFormParam->addParam("パスワード確認用の質問の答え", "reminder_answer", STEXT_LEN, "aKV", array("EXIST_CHECK","SPTAB_CHECK" , "MAX_LENGTH_CHECK"));
186        $this->objFormParam->addParam("郵便番号1", "zip01", ZIP01_LEN, "n", array("EXIST_CHECK", "SPTAB_CHECK" ,"NUM_CHECK", "NUM_COUNT_CHECK"));
187        $this->objFormParam->addParam("郵便番号2", "zip02", ZIP02_LEN, "n", array("EXIST_CHECK", "SPTAB_CHECK" ,"NUM_CHECK", "NUM_COUNT_CHECK"));
188        $this->objFormParam->addParam("都道府県", 'pref', INT_LEN, "n", array("EXIST_CHECK","NUM_CHECK"));
189        $this->objFormParam->addParam("住所1", "addr01", MTEXT_LEN, "aKV", array("EXIST_CHECK","SPTAB_CHECK" ,"MAX_LENGTH_CHECK"));
190        $this->objFormParam->addParam("住所2", "addr02", MTEXT_LEN, "aKV", array("EXIST_CHECK","SPTAB_CHECK" ,"MAX_LENGTH_CHECK"));
191        $this->objFormParam->addParam("お電話番号1", 'tel01', TEL_ITEM_LEN, "n", array("EXIST_CHECK","SPTAB_CHECK" ));
192        $this->objFormParam->addParam("お電話番号2", 'tel02', TEL_ITEM_LEN, "n", array("EXIST_CHECK","SPTAB_CHECK" ));
193        $this->objFormParam->addParam("お電話番号3", 'tel03', TEL_ITEM_LEN, "n", array("EXIST_CHECK","SPTAB_CHECK" ));
194        $this->objFormParam->addParam("性別", "sex", INT_LEN, "n", array("EXIST_CHECK", "NUM_CHECK"));
195        $this->objFormParam->addParam("職業", "job", INT_LEN, "n", array("NUM_CHECK"));
196        $this->objFormParam->addParam("年", "year", INT_LEN, "n", array("MAX_LENGTH_CHECK"), "", false);
197        $this->objFormParam->addParam("月", "month", INT_LEN, "n", array("MAX_LENGTH_CHECK"), "", false);
198        $this->objFormParam->addParam("日", "day", INT_LEN, "n", array("MAX_LENGTH_CHECK"), "", false);
199        $this->objFormParam->addParam("メールマガジン", "mailmaga_flg", INT_LEN, "n", array("EXIST_CHECK", "NUM_CHECK"));
200       
201        if ($this->isMobile === false){
202            $this->objFormParam->addParam("FAX番号1", 'fax01', TEL_ITEM_LEN, "n", array("SPTAB_CHECK"));
203            $this->objFormParam->addParam("FAX番号2", 'fax02', TEL_ITEM_LEN, "n", array("SPTAB_CHECK"));
204            $this->objFormParam->addParam("FAX番号3", 'fax03', TEL_ITEM_LEN, "n", array("SPTAB_CHECK"));
205            $this->objFormParam->addParam("パスワード(確認)", 'password02', STEXT_LEN, "a", array("EXIST_CHECK", "SPTAB_CHECK" ,"ALNUM_CHECK"), "", false);
206            $this->objFormParam->addParam('メールアドレス', "email", MTEXT_LEN, "a", array("NO_SPTAB", "EXIST_CHECK", "EMAIL_CHECK", "SPTAB_CHECK" ,"EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK"));
207            $this->objFormParam->addParam('メールアドレス(確認)', "email02", MTEXT_LEN, "a", array("NO_SPTAB", "EXIST_CHECK", "EMAIL_CHECK","SPTAB_CHECK" , "EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK"), "", false);
208            $this->objFormParam->addParam('携帯メールアドレス', "email_mobile", MTEXT_LEN, "a", array("NO_SPTAB", "EMAIL_CHECK", "SPTAB_CHECK" ,"EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK"));
209            $this->objFormParam->addParam('携帯メールアドレス(確認)', "email_mobile02", MTEXT_LEN, "a", array("NO_SPTAB", "EMAIL_CHECK","SPTAB_CHECK" , "EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK"), "", false);
210        } else {
211            $this->objFormParam->addParam('メールアドレス', "email", MTEXT_LEN, "a", array("EXIST_CHECK", "EMAIL_CHECK", "NO_SPTAB" ,"EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK","MOBILE_EMAIL_CHECK"));
212        }
213    }
214
215    //---- 入力エラーチェック
216    function lfErrorCheck($array) {
217
218        // 入力データを渡す。
219        $arrRet = $this->objFormParam->getHashArray();
220        $objErr = new SC_CheckError($arrRet);
221        $objErr->arrErr = $this->objFormParam->checkError();
222        if(isset($objErr->arrErr['password']) and $arrRet['password'] == DEFAULT_PASSWORD) {
223            unset($objErr->arrErr['password']);
224            unset($objErr->arrErr['password02']);
225        }
226        if(isset($objErr->arrErr['reminder_answer']) and $arrRet['reminder_answer'] == DEFAULT_PASSWORD) {
227            unset($objErr->arrErr['reminder_answer']);
228        }
229                       
230        $objErr->doFunc(array("お電話番号", "tel01", "tel02", "tel03"),array("TEL_CHECK"));
231        $objErr->doFunc(array("郵便番号", "zip01", "zip02"), array("ALL_EXIST_CHECK"));
232        $objErr->doFunc(array("生年月日", "year", "month", "day"), array("CHECK_BIRTHDAY"));
233        if ($this->isMobile === false){
234            if( $arrRet['password'] != DEFAULT_PASSWORD ) {
235                $objErr->doFunc(array('パスワード', 'パスワード(確認)', "password", "password02") ,array("EQUAL_CHECK"));
236            }
237            $objErr->doFunc(array('メールアドレス', 'メールアドレス(確認)', "email", "email02") ,array("EQUAL_CHECK"));
238            $objErr->doFunc(array("FAX番号", "fax01", "fax02", "fax03") ,array("TEL_CHECK"));
239        }
240               
241        // 現会員の判定 → 現会員もしくは仮登録中は、メアド一意が前提になってるので同じメアドで登録不可
242        $register_user_flg = SC_Helper_Customer_Ex::sfCheckRegisterUserFromEmail($arrRet["email"]);
243        switch($register_user_flg) {
244            case 1:
245                $objErr->arrErr["email"] .= "※ すでに会員登録で使用されているメールアドレスです。<br />";
246                break;
247            case 2:
248                $objErr->arrErr["email"] .= "※ 退会から一定期間の間は、同じメールアドレスを使用することはできません。<br />";
249                break;
250            default:
251                break;
252        }
253        return $objErr->arrErr;
254    }
255   
256    function lfRegistData() {
257               
258        $objQuery = new SC_Query();
259        $objCustomer = new SC_Customer();
260       
261        $arrRet = $this->objFormParam->getHashArray();
262       
263        // 登録データの作成
264        $sqlval = $this->objFormParam->getDbArray();
265        $sqlval['birth'] = SC_Utils_Ex::sfGetTimestamp($arrRet['year'], $arrRet['month'], $arrRet['day']);
266                       
267        $objQuery->begin();
268        SC_Helper_Customer_Ex::sfEditCustomerData($sqlval, $objCustomer->getValue('customer_id'));       
269        $objQuery->commit();
270    }
271   
272    /**
273     * 顧客情報の取得
274     *
275     * @return array 顧客情報
276     */
277    function lfGetCustomerData(){
278        $objQuery = new SC_Query();
279        $objCustomer = new SC_Customer();
280       
281        // 顧客情報DB取得
282        $ret = $objQuery->select("*","dtb_customer","customer_id=?", array($objCustomer->getValue('customer_id')));
283        $arrForm = $ret[0];
284
285        // 確認項目に複製
286        $arrForm['email02'] = $arrForm['email'];
287        $arrForm['email_mobile02'] = $arrForm['email_mobile'];
288
289        // 誕生日を年月日に分ける
290        if (isset($arrForm['birth'])){
291            $birth = split(" ", $arrForm["birth"]);
292            list($arrForm['year'], $arrForm['month'], $arrForm['day']) = split("-",$birth[0]);
293        }
294        return $arrForm;
295    }
296
297    //エラー、戻る時にフォームに入力情報を返す
298    function lfFormReturn($array, &$objPage){
299        foreach($array as $key => $val){
300            switch ($key){
301            case 'password':
302            case 'password02':
303                $objPage->$key = $val;
304                break;
305            default:
306                $array[ $key ] = $val;
307                break;
308            }
309        }
310    }
311   
312}
313?>
Note: See TracBrowser for help on using the repository browser.