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

Revision 20075, 13.8 KB checked in by kimoto, 13 years ago (diff)

lfPassLenという関数がSC_Utilsにあったので命名規則にあわせて修正 #700

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • 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->tpl_login = true;
97            $this->CustomerName1 = $objCustomer->getvalue('name01');
98            $this->CustomerName2 = $objCustomer->getvalue('name02');
99            $this->CustomerPoint = $objCustomer->getvalue('point');
100        }
101
102        // mobile用(戻るボタンでの遷移かどうかを判定)
103        if (!empty($_POST["return"])) {
104            $_POST["mode"] = "return";
105        }
106
107        // パラメータ管理クラス,パラメータ情報の初期化
108        $this->objFormParam = new SC_FormParam();
109        $this->lfInitParam();
110        $this->objFormParam->setParam($_POST);    // POST値の取得
111
112
113        if ($_SERVER["REQUEST_METHOD"] == "POST") {
114
115            //CSRF対策
116            /*
117            if (!SC_Helper_Session_Ex::isValidToken()) {
118                SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, "", true);
119            }
120            */
121
122            $this->objFormParam->convParam();
123            $this->objFormParam->toLower('email');
124            $this->objFormParam->toLower('email02');
125            $this->objFormParam->toLower('email_mobile');
126            $this->objFormParam->toLower('email_mobile02');
127            $this->arrForm = $this->objFormParam->getHashArray();
128
129
130            switch ($this->getMode()) {
131            case 'confirm':
132            //-- 確認
133                $this->arrErr = $this->lfErrorCheck();
134
135                // 入力エラーなし
136                if(count($this->arrErr) == 0) {
137
138                    $this->list_data = $this->objFormParam->getHashArray();
139
140                    //パスワード表示
141                    $passlen = strlen($this->arrForm['password']);
142                    $this->passlen = SC_Utils_Ex::sfPassLen($passlen);
143
144                    $this->tpl_mainpage = 'mypage/change_confirm.tpl';
145                    $this->tpl_title = '会員登録(確認ページ)';
146                }
147                break;
148            case 'complete':
149                //-- 会員登録と完了画面
150
151                // 会員情報の登録
152                $this->CONF = $CONF;
153                $this->lfRegistData();
154
155                // 完了ページに移動させる。
156                SC_Response_Ex::sendRedirect('change_complete.php');
157                exit;
158                break;
159            default:
160                break;
161            }
162        } else {
163            $this->arrForm = $this->lfGetCustomerData();
164            $this->arrForm['password'] = DEFAULT_PASSWORD;
165            $this->arrForm['password02'] = DEFAULT_PASSWORD;
166            $this->arrForm['reminder_answer'] = DEFAULT_PASSWORD;
167        }
168        $this->transactionid = SC_Helper_Session_Ex::getToken();
169    }
170
171    /**
172     * デストラクタ.
173     *
174     * @return void
175     */
176    function destroy() {
177        parent::destroy();
178    }
179
180    /* パラメータ情報の初期化 */
181    function lfInitParam() {
182
183        $this->objFormParam->addParam("お名前(姓)", 'name01', STEXT_LEN, "aKV", array("EXIST_CHECK", "NO_SPTAB", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK"));
184        $this->objFormParam->addParam("お名前(名)", 'name02', STEXT_LEN, "aKV", array("EXIST_CHECK", "NO_SPTAB", "SPTAB_CHECK" , "MAX_LENGTH_CHECK"));
185        $this->objFormParam->addParam("お名前(フリガナ・姓)", 'kana01', STEXT_LEN, "CKV", array("EXIST_CHECK", "NO_SPTAB", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK", "KANA_CHECK"));
186        $this->objFormParam->addParam("お名前(フリガナ・名)", 'kana02', STEXT_LEN, "CKV", array("EXIST_CHECK", "NO_SPTAB", "SPTAB_CHECK" ,"MAX_LENGTH_CHECK", "KANA_CHECK"));
187        $this->objFormParam->addParam("パスワード", 'password', STEXT_LEN, "a", array("EXIST_CHECK", "SPTAB_CHECK" ,"ALNUM_CHECK"));
188        $this->objFormParam->addParam("パスワード確認用の質問", "reminder", STEXT_LEN, "n", array("EXIST_CHECK", "NUM_CHECK"));
189        $this->objFormParam->addParam("パスワード確認用の質問の答え", "reminder_answer", STEXT_LEN, "aKV", array("EXIST_CHECK","SPTAB_CHECK" , "MAX_LENGTH_CHECK"));
190        $this->objFormParam->addParam("郵便番号1", "zip01", ZIP01_LEN, "n", array("EXIST_CHECK", "SPTAB_CHECK" ,"NUM_CHECK", "NUM_COUNT_CHECK"));
191        $this->objFormParam->addParam("郵便番号2", "zip02", ZIP02_LEN, "n", array("EXIST_CHECK", "SPTAB_CHECK" ,"NUM_CHECK", "NUM_COUNT_CHECK"));
192        $this->objFormParam->addParam("都道府県", 'pref', INT_LEN, "n", array("EXIST_CHECK","NUM_CHECK"));
193        $this->objFormParam->addParam("住所1", "addr01", MTEXT_LEN, "aKV", array("EXIST_CHECK","SPTAB_CHECK" ,"MAX_LENGTH_CHECK"));
194        $this->objFormParam->addParam("住所2", "addr02", MTEXT_LEN, "aKV", array("EXIST_CHECK","SPTAB_CHECK" ,"MAX_LENGTH_CHECK"));
195        $this->objFormParam->addParam("お電話番号1", 'tel01', TEL_ITEM_LEN, "n", array("EXIST_CHECK","SPTAB_CHECK" ));
196        $this->objFormParam->addParam("お電話番号2", 'tel02', TEL_ITEM_LEN, "n", array("EXIST_CHECK","SPTAB_CHECK" ));
197        $this->objFormParam->addParam("お電話番号3", 'tel03', TEL_ITEM_LEN, "n", array("EXIST_CHECK","SPTAB_CHECK" ));
198        $this->objFormParam->addParam("性別", "sex", INT_LEN, "n", array("EXIST_CHECK", "NUM_CHECK"));
199        $this->objFormParam->addParam("職業", "job", INT_LEN, "n", array("NUM_CHECK"));
200        $this->objFormParam->addParam("年", "year", INT_LEN, "n", array("MAX_LENGTH_CHECK"), "", false);
201        $this->objFormParam->addParam("月", "month", INT_LEN, "n", array("MAX_LENGTH_CHECK"), "", false);
202        $this->objFormParam->addParam("日", "day", INT_LEN, "n", array("MAX_LENGTH_CHECK"), "", false);
203        $this->objFormParam->addParam("メールマガジン", "mailmaga_flg", INT_LEN, "n", array("EXIST_CHECK", "NUM_CHECK"));
204
205        if ($this->isMobile === false){
206            $this->objFormParam->addParam("FAX番号1", 'fax01', TEL_ITEM_LEN, "n", array("SPTAB_CHECK"));
207            $this->objFormParam->addParam("FAX番号2", 'fax02', TEL_ITEM_LEN, "n", array("SPTAB_CHECK"));
208            $this->objFormParam->addParam("FAX番号3", 'fax03', TEL_ITEM_LEN, "n", array("SPTAB_CHECK"));
209            $this->objFormParam->addParam("パスワード(確認)", 'password02', STEXT_LEN, "a", array("EXIST_CHECK", "SPTAB_CHECK" ,"ALNUM_CHECK"), "", false);
210            $this->objFormParam->addParam('メールアドレス', "email", MTEXT_LEN, "a", array("NO_SPTAB", "EXIST_CHECK", "EMAIL_CHECK", "SPTAB_CHECK" ,"EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK"));
211            $this->objFormParam->addParam('メールアドレス(確認)', "email02", MTEXT_LEN, "a", array("NO_SPTAB", "EXIST_CHECK", "EMAIL_CHECK","SPTAB_CHECK" , "EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK"), "", false);
212            $this->objFormParam->addParam('携帯メールアドレス', "email_mobile", MTEXT_LEN, "a", array("NO_SPTAB", "EMAIL_CHECK", "SPTAB_CHECK" ,"EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK"));
213            $this->objFormParam->addParam('携帯メールアドレス(確認)', "email_mobile02", MTEXT_LEN, "a", array("NO_SPTAB", "EMAIL_CHECK","SPTAB_CHECK" , "EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK"), "", false);
214        } else {
215            $this->objFormParam->addParam('メールアドレス', "email", MTEXT_LEN, "a", array("EXIST_CHECK", "EMAIL_CHECK", "NO_SPTAB" ,"EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK","MOBILE_EMAIL_CHECK"));
216        }
217    }
218
219    //---- 入力エラーチェック
220    function lfErrorCheck($array) {
221
222        // 入力データを渡す。
223        $arrRet = $this->objFormParam->getHashArray();
224        $objErr = new SC_CheckError($arrRet);
225        $objErr->arrErr = $this->objFormParam->checkError();
226        if(isset($objErr->arrErr['password']) and $arrRet['password'] == DEFAULT_PASSWORD) {
227            unset($objErr->arrErr['password']);
228            unset($objErr->arrErr['password02']);
229        }
230        if(isset($objErr->arrErr['reminder_answer']) and $arrRet['reminder_answer'] == DEFAULT_PASSWORD) {
231            unset($objErr->arrErr['reminder_answer']);
232        }
233
234        $objErr->doFunc(array("お電話番号", "tel01", "tel02", "tel03"),array("TEL_CHECK"));
235        $objErr->doFunc(array("郵便番号", "zip01", "zip02"), array("ALL_EXIST_CHECK"));
236        $objErr->doFunc(array("生年月日", "year", "month", "day"), array("CHECK_BIRTHDAY"));
237        if ($this->isMobile === false){
238            if( $arrRet['password'] != DEFAULT_PASSWORD ) {
239                $objErr->doFunc(array('パスワード', 'パスワード(確認)', "password", "password02") ,array("EQUAL_CHECK"));
240            }
241            $objErr->doFunc(array('メールアドレス', 'メールアドレス(確認)', "email", "email02") ,array("EQUAL_CHECK"));
242            $objErr->doFunc(array("FAX番号", "fax01", "fax02", "fax03") ,array("TEL_CHECK"));
243        }
244
245        // 現会員の判定 → 現会員もしくは仮登録中は、メアド一意が前提になってるので同じメアドで登録不可
246        $register_user_flg = SC_Helper_Customer_Ex::sfCheckRegisterUserFromEmail($arrRet["email"]);
247        switch($register_user_flg) {
248            case 1:
249                $objErr->arrErr["email"] .= "※ すでに会員登録で使用されているメールアドレスです。<br />";
250                break;
251            case 2:
252                $objErr->arrErr["email"] .= "※ 退会から一定期間の間は、同じメールアドレスを使用することはできません。<br />";
253                break;
254            default:
255                break;
256        }
257        return $objErr->arrErr;
258    }
259
260    function lfRegistData() {
261
262        $objQuery = new SC_Query();
263        $objCustomer = new SC_Customer();
264
265        $arrRet = $this->objFormParam->getHashArray();
266
267        // 登録データの作成
268        $sqlval = $this->objFormParam->getDbArray();
269        $sqlval['birth'] = SC_Utils_Ex::sfGetTimestamp($arrRet['year'], $arrRet['month'], $arrRet['day']);
270
271        $objQuery->begin();
272        SC_Helper_Customer_Ex::sfEditCustomerData($sqlval, $objCustomer->getValue('customer_id'));
273        $objQuery->commit();
274    }
275
276    /**
277     * 顧客情報の取得
278     *
279     * @return array 顧客情報
280     */
281    function lfGetCustomerData(){
282        $objQuery = new SC_Query();
283        $objCustomer = new SC_Customer();
284
285        // 顧客情報DB取得
286        $ret = $objQuery->select("*","dtb_customer","customer_id=?", array($objCustomer->getValue('customer_id')));
287        $arrForm = $ret[0];
288
289        // 確認項目に複製
290        $arrForm['email02'] = $arrForm['email'];
291        $arrForm['email_mobile02'] = $arrForm['email_mobile'];
292
293        // 誕生日を年月日に分ける
294        if (isset($arrForm['birth'])){
295            $birth = split(" ", $arrForm["birth"]);
296            list($arrForm['year'], $arrForm['month'], $arrForm['day']) = split("-",$birth[0]);
297        }
298        return $arrForm;
299    }
300
301    //エラー、戻る時にフォームに入力情報を返す
302    function lfFormReturn($array, &$objPage){
303        foreach($array as $key => $val){
304            switch ($key){
305            case 'password':
306            case 'password02':
307                $objPage->$key = $val;
308                break;
309            default:
310                $array[ $key ] = $val;
311                break;
312            }
313        }
314    }
315
316}
317?>
Note: See TracBrowser for help on using the repository browser.