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

Revision 21683, 8.8 KB checked in by Seasoft, 12 years ago (diff)

#1613 (typo修正・ソース整形・ソースコメントの改善)

  • 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-2011 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 = '会員登録内容変更(入力ページ)';
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        $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
80        $objPlugin->doAction('lc_page_mypage_change_action_start', array($this));
81
82        $objCustomer = new SC_Customer_Ex();
83        $customer_id = $objCustomer->getValue('customer_id');
84
85        // mobile用(戻るボタンでの遷移かどうかを判定)
86        if (!empty($_POST['return'])) {
87            $_POST['mode'] = 'return';
88        }
89
90        // パラメーター管理クラス,パラメーター情報の初期化
91        $objFormParam = new SC_FormParam_Ex();
92        SC_Helper_Customer_Ex::sfCustomerMypageParam($objFormParam);
93        $objFormParam->setParam($_POST);    // POST値の取得
94
95        switch ($this->getMode()) {
96            // 確認
97            case 'confirm':
98                if (isset($_POST['submit_address'])) {
99                    // 入力エラーチェック
100                    $this->arrErr = $this->fnErrorCheck($_POST);
101                    // 入力エラーの場合は終了
102                    if (count($this->arrErr) == 0) {
103                        // 郵便番号検索文作成
104                        $zipcode = $_POST['zip01'] . $_POST['zip02'];
105
106                        // 郵便番号検索
107                        $arrAdsList = SC_Utils_Ex::sfGetAddress($zipcode);
108
109                        // 郵便番号が発見された場合
110                        if (!empty($arrAdsList)) {
111                            $data['pref'] = $arrAdsList[0]['state'];
112                            $data['addr01'] = $arrAdsList[0]['city']. $arrAdsList[0]['town'];
113                            $objFormParam->setParam($data);
114
115                        }
116                        // 該当無し
117                        else {
118                            $this->arrErr['zip01'] = '※該当する住所が見つかりませんでした。<br>';
119                        }
120                    }
121                    $this->arrForm  = $objFormParam->getHashArray();
122                    break;
123                }
124                $this->arrErr = SC_Helper_Customer_Ex::sfCustomerMypageErrorCheck($objFormParam);
125                $this->arrForm = $objFormParam->getHashArray();
126
127                // 入力エラーなし
128                if (empty($this->arrErr)) {
129                    //パスワード表示
130                    $this->passlen      = SC_Utils_Ex::sfPassLen(strlen($this->arrForm['password']));
131
132                    $this->tpl_mainpage = 'mypage/change_confirm.tpl';
133                    $this->tpl_title    = '会員登録(確認ページ)';
134                    $this->tpl_subtitle = '会員登録内容変更(確認ページ)';
135                }
136                break;
137            // 会員登録と完了画面
138            case 'complete':
139                $this->arrErr = SC_Helper_Customer_Ex::sfCustomerMypageErrorCheck($objFormParam);
140                $this->arrForm = $objFormParam->getHashArray();
141
142                // 入力エラーなし
143                if (empty($this->arrErr)) {
144                    // 会員情報の登録
145                    $this->lfRegistCustomerData($objFormParam, $customer_id);
146
147                    // フックポイント.
148                    $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
149                    $objPlugin->doAction('lc_page_mypage_change_action_complete', array($this));
150
151                    // 完了ページに移動させる。
152                    SC_Response_Ex::sendRedirect('change_complete.php');
153                }
154                break;
155            // 確認ページからの戻り
156            case 'return':
157                $this->arrForm = $objFormParam->getHashArray();
158                break;
159            default:
160                $this->arrForm = SC_Helper_Customer_Ex::sfGetCustomerData($customer_id);
161                break;
162        }
163        // フックポイント.
164        $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
165        $objPlugin->doAction('lc_page_mypage_change_action_end', array($this));
166    }
167
168    /**
169     * デストラクタ.
170     *
171     * @return void
172     */
173    function destroy() {
174        parent::destroy();
175    }
176
177    /**
178     *  会員情報を登録する
179     *
180     * @param mixed $objFormParam
181     * @param mixed $customer_id
182     * @access private
183     * @return void
184     */
185    function lfRegistCustomerData(&$objFormParam, $customer_id) {
186        $arrRet             = $objFormParam->getHashArray();
187        $sqlval             = $objFormParam->getDbArray();
188        $sqlval['birth']    = SC_Utils_Ex::sfGetTimestamp($arrRet['year'], $arrRet['month'], $arrRet['day']);
189
190        SC_Helper_Customer_Ex::sfEditCustomerData($sqlval, $customer_id);
191    }
192
193    /**
194     * 入力エラーのチェック.
195     *
196     * @param array $arrRequest リクエスト値($_GET)
197     * @return array $arrErr エラーメッセージ配列
198     */
199    function fnErrorCheck($arrRequest) {
200        // パラメーター管理クラス
201        $objFormParam = new SC_FormParam_Ex();
202        // パラメーター情報の初期化
203        $objFormParam->addParam('郵便番号1', 'zip01', ZIP01_LEN, 'n', array('EXIST_CHECK', 'NUM_COUNT_CHECK', 'NUM_CHECK'));
204        $objFormParam->addParam('郵便番号2', 'zip02', ZIP02_LEN, 'n', array('EXIST_CHECK', 'NUM_COUNT_CHECK', 'NUM_CHECK'));
205        // // リクエスト値をセット
206        $arrData['zip01'] = $arrRequest['zip01'];
207        $arrData['zip02'] = $arrRequest['zip02'];
208        $objFormParam->setParam($arrData);
209        // エラーチェック
210        $arrErr = $objFormParam->checkError();
211        // 親ウィンドウの戻り値を格納するinputタグのnameのエラーチェック
212        if (!$this->lfInputNameCheck($addData['zip01'])) {
213            $arrErr['zip01'] = '※ 入力形式が不正です。<br />';
214        }
215        if (!$this->lfInputNameCheck($arrdata['zip02'])) {
216            $arrErr['zip02'] = '※ 入力形式が不正です。<br />';
217        }
218
219        return $arrErr;
220    }
221
222    /**
223     * エラーチェック.
224     *
225     * @param string $value
226     * @return エラーなし:true エラー:false
227     */
228    function lfInputNameCheck($value) {
229        // 半角英数字と_(アンダーバー), []以外の文字を使用していたらエラー
230        if (strlen($value) > 0 && !preg_match("/^[a-zA-Z0-9_\[\]]+$/", $value)) {
231            return false;
232        }
233
234        return true;
235    }
236}
Note: See TracBrowser for help on using the repository browser.