source: branches/version-2_12-multilang/data/class/pages/mypage/LC_Page_Mypage_Change.php @ 22428

Revision 22428, 8.7 KB checked in by kim, 11 years ago (diff)

#2060 メッセージIDの振り直し PARAM系

PARAM_LABEL_BIRTH_POINT~PARAM_LABEL_ZIP02

統合
PARAM_LABEL_SHOP_NAMEとLC_Page_Install_018
PARAM_LABEL_ZIP1,PARAM_LABEL_ZIP2とPARAM_LABEL_ZIP01,PARAM_LABEL_ZIP02を統合

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • 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-2012 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_EX_REALDIR . 'page_extends/mypage/LC_Page_AbstractMypage_Ex.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_AbstractMypage_Ex {
35
36    // }}}
37    // {{{ functions
38
39    /**
40     * Page を初期化する.
41     *
42     * @return void
43     */
44    function init() {
45        parent::init();
46        $this->tpl_subtitle = t('LC_Page_Mypage_Change_001');
47        $this->tpl_mypageno = 'change';
48
49        $masterData         = new SC_DB_MasterData_Ex();
50        $this->arrReminder  = $masterData->getMasterData('mtb_reminder');
51        $this->arrPref      = $masterData->getMasterData('mtb_pref');
52        $this->arrJob       = $masterData->getMasterData('mtb_job');
53        $this->arrMAILMAGATYPE = $masterData->getMasterData('mtb_mail_magazine_type');
54        $this->arrSex       = $masterData->getMasterData('mtb_sex');
55        $this->httpCacheControl('nocache');
56
57        // 生年月日選択肢の取得
58        $objDate            = new SC_Date_Ex(BIRTH_YEAR, date('Y',strtotime('now')));
59        $this->arrYear      = $objDate->getYear('', START_BIRTH_YEAR, '');
60        $this->arrMonth     = $objDate->getMonth(true);
61        $this->arrDay       = $objDate->getDay(true);
62    }
63
64    /**
65     * Page のプロセス.
66     *
67     * @return void
68     */
69    function process() {
70        parent::process();
71    }
72
73    /**
74     * Page のプロセス
75     * @return void
76     */
77    function action() {
78
79        $objCustomer = new SC_Customer_Ex();
80        $customer_id = $objCustomer->getValue('customer_id');
81
82        // mobile用(戻るボタンでの遷移かどうかを判定)
83        if (!empty($_POST['return'])) {
84            $_POST['mode'] = 'return';
85        }
86
87        // パラメーター管理クラス,パラメーター情報の初期化
88        $objFormParam = new SC_FormParam_Ex();
89        SC_Helper_Customer_Ex::sfCustomerMypageParam($objFormParam);
90        $objFormParam->setParam($_POST);    // POST値の取得
91
92        switch ($this->getMode()) {
93            // 確認
94            case 'confirm':
95                if (isset($_POST['submit_address'])) {
96                    // 入力エラーチェック
97                    $this->arrErr = $this->lfCheckError($_POST);
98                    // 入力エラーの場合は終了
99                    if (count($this->arrErr) == 0) {
100                        // 郵便番号検索文作成
101//                        $zipcode = $_POST['zip01'] . $_POST['zip02'];
102                        $zipcode = $_POST['zipcode'];
103
104                        // 郵便番号検索
105                        $arrAdsList = SC_Utils_Ex::sfGetAddress($zipcode);
106
107                        // 郵便番号が発見された場合
108                        if (!empty($arrAdsList)) {
109                            $data['pref'] = $arrAdsList[0]['state'];
110                            $data['addr01'] = $arrAdsList[0]['city']. $arrAdsList[0]['town'];
111                            $objFormParam->setParam($data);
112
113                        }
114                        // 該当無し
115                        else {
116//                            $this->arrErr['zip01'] =  t('LC_Page_Mypage_Change_002');
117                            $this->arrErr['zipcode'] =  t('LC_Page_Mypage_Change_002');
118                        }
119                    }
120                    $this->arrForm  = $objFormParam->getHashArray();
121                    break;
122                }
123                $this->arrErr = SC_Helper_Customer_Ex::sfCustomerMypageErrorCheck($objFormParam);
124                $this->arrForm = $objFormParam->getHashArray();
125
126                // 入力エラーなし
127                if (empty($this->arrErr)) {
128                    //パスワード表示
129                    $this->passlen      = SC_Utils_Ex::sfPassLen(strlen($this->arrForm['password']));
130
131                    $this->tpl_mainpage = 'mypage/change_confirm.tpl';
132                    $this->tpl_title    = t('LC_Page_Mypage_Change_003');
133                    $this->tpl_subtitle = t('LC_Page_Mypage_Change_004');
134                }
135                break;
136            // 会員登録と完了画面
137            case 'complete':
138                $this->arrErr = SC_Helper_Customer_Ex::sfCustomerMypageErrorCheck($objFormParam);
139                $this->arrForm = $objFormParam->getHashArray();
140
141                // 入力エラーなし
142                if (empty($this->arrErr)) {
143                    // 会員情報の登録
144                    $this->lfRegistCustomerData($objFormParam, $customer_id);
145
146                    //セッション情報を最新の状態に更新する
147                    $objCustomer->updateSession();
148
149
150                    // 完了ページに移動させる。
151                    SC_Response_Ex::sendRedirect('change_complete.php');
152                }
153                break;
154            // 確認ページからの戻り
155            case 'return':
156                $this->arrForm = $objFormParam->getHashArray();
157                break;
158            default:
159                $this->arrForm = SC_Helper_Customer_Ex::sfGetCustomerData($customer_id);
160                break;
161        }
162
163    }
164
165    /**
166     * デストラクタ.
167     *
168     * @return void
169     */
170    function destroy() {
171        parent::destroy();
172    }
173
174    /**
175     *  会員情報を登録する
176     *
177     * @param mixed $objFormParam
178     * @param mixed $customer_id
179     * @access private
180     * @return void
181     */
182    function lfRegistCustomerData(&$objFormParam, $customer_id) {
183        $arrRet             = $objFormParam->getHashArray();
184        $sqlval             = $objFormParam->getDbArray();
185        $sqlval['birth']    = SC_Utils_Ex::sfGetTimestamp($arrRet['year'], $arrRet['month'], $arrRet['day']);
186
187        SC_Helper_Customer_Ex::sfEditCustomerData($sqlval, $customer_id);
188    }
189
190    /**
191     * 入力エラーのチェック.
192     *
193     * @param array $arrRequest リクエスト値($_GET)
194     * @return array $arrErr エラーメッセージ配列
195     */
196    function lfCheckError($arrRequest) {
197        // パラメーター管理クラス
198        $objFormParam = new SC_FormParam_Ex();
199        // パラメーター情報の初期化
200//        $objFormParam->addParam(t('c_Postal code 1_01'), 'zip01', ZIP01_LEN, 'n', array('EXIST_CHECK', 'NUM_COUNT_CHECK', 'NUM_CHECK'));
201//        $objFormParam->addParam(t('c_Postal code 2_01'), 'zip02', ZIP02_LEN, 'n', array('EXIST_CHECK', 'NUM_COUNT_CHECK', 'NUM_CHECK'));
202        $objFormParam->addParam(t('c_Postal code_01'), 'zipcode', ZIPCODE_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'));
203
204        // リクエスト値をセット
205//        $arrData['zip01'] = $arrRequest['zip01'];
206//        $arrData['zip02'] = $arrRequest['zip02'];
207        $arrData['zipcode'] = $arrRequest['zipcode'];
208        $objFormParam->setParam($arrData);
209        // エラーチェック
210        $arrErr = $objFormParam->checkError();
211        // 親ウィンドウの戻り値を格納するinputタグのnameのエラーチェック
212        /*
213        if (!$this->lfInputNameCheck($addData['zip01'])) {
214            $arrErr['zip01'] =  t('LC_Page_Mypage_Change_005');
215        }
216        if (!$this->lfInputNameCheck($arrdata['zip02'])) {
217            $arrErr['zip02'] =  t('LC_Page_Mypage_Change_006');
218        }
219        */
220        if (!$this->lfInputNameCheck($arrData['zipcode'])) {
221            $arrErr['zipcode'] =  t('LC_Page_Mypage_Change_005');
222        }
223
224        return $arrErr;
225    }
226
227    /**
228     * エラーチェック.
229     *
230     * @param string $value
231     * @return エラーなし:true エラー:false
232     */
233    function lfInputNameCheck($value) {
234        // 半角英数字と_(アンダーバー), []以外の文字を使用していたらエラー
235        if (strlen($value) > 0 && !preg_match("/^[a-zA-Z0-9_\[\]]+$/", $value)) {
236            return false;
237        }
238
239        return true;
240    }
241}
Note: See TracBrowser for help on using the repository browser.