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

Revision 22856, 7.4 KB checked in by Seasoft, 11 years ago (diff)

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

  • 主に空白・空白行の調整。もう少し整えたいが、一旦現状コミット。
  • 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-2013 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
24require_once CLASS_EX_REALDIR . 'page_extends/mypage/LC_Page_AbstractMypage_Ex.php';
25
26/**
27 * 登録内容変更 のページクラス.
28 *
29 * @package Page
30 * @author LOCKON CO.,LTD.
31 * @version $Id$
32 */
33class LC_Page_Mypage_Change extends LC_Page_AbstractMypage_Ex
34{
35    /**
36     * Page を初期化する.
37     *
38     * @return void
39     */
40    function init()
41    {
42        parent::init();
43        $this->tpl_subtitle = '会員登録内容変更(入力ページ)';
44        $this->tpl_mypageno = 'change';
45
46        $masterData         = new SC_DB_MasterData_Ex();
47        $this->arrReminder  = $masterData->getMasterData('mtb_reminder');
48        $this->arrPref      = $masterData->getMasterData('mtb_pref');
49        $this->arrJob       = $masterData->getMasterData('mtb_job');
50        $this->arrMAILMAGATYPE = $masterData->getMasterData('mtb_mail_magazine_type');
51        $this->arrSex       = $masterData->getMasterData('mtb_sex');
52        $this->httpCacheControl('nocache');
53
54        // 生年月日選択肢の取得
55        $objDate            = new SC_Date_Ex(BIRTH_YEAR, date('Y',strtotime('now')));
56        $this->arrYear      = $objDate->getYear('', START_BIRTH_YEAR, '');
57        $this->arrMonth     = $objDate->getMonth(true);
58        $this->arrDay       = $objDate->getDay(true);
59    }
60
61    /**
62     * Page のプロセス.
63     *
64     * @return void
65     */
66    function process()
67    {
68        parent::process();
69    }
70
71    /**
72     * Page のプロセス
73     * @return void
74     */
75    function action()
76    {
77        $objCustomer = new SC_Customer_Ex();
78        $customer_id = $objCustomer->getValue('customer_id');
79
80        // mobile用(戻るボタンでの遷移かどうかを判定)
81        if (!empty($_POST['return'])) {
82            $_POST['mode'] = 'return';
83        }
84
85        // パラメーター管理クラス,パラメーター情報の初期化
86        $objFormParam = new SC_FormParam_Ex();
87        SC_Helper_Customer_Ex::sfCustomerMypageParam($objFormParam);
88        $objFormParam->setParam($_POST);    // POST値の取得
89
90        switch ($this->getMode()) {
91            // 確認
92            case 'confirm':
93                if (isset($_POST['submit_address'])) {
94                    // 入力エラーチェック
95                    $this->arrErr = $this->lfCheckError($_POST);
96                    // 入力エラーの場合は終了
97                    if (count($this->arrErr) == 0) {
98                        // 郵便番号検索文作成
99                        $zipcode = $_POST['zip01'] . $_POST['zip02'];
100
101                        // 郵便番号検索
102                        $arrAdsList = SC_Utils_Ex::sfGetAddress($zipcode);
103
104                        // 郵便番号が発見された場合
105                        if (!empty($arrAdsList)) {
106                            $data['pref'] = $arrAdsList[0]['state'];
107                            $data['addr01'] = $arrAdsList[0]['city']. $arrAdsList[0]['town'];
108                            $objFormParam->setParam($data);
109
110                        }
111                        // 該当無し
112                        else {
113                            $this->arrErr['zip01'] = '※該当する住所が見つかりませんでした。<br>';
114                        }
115                    }
116                    $this->arrForm  = $objFormParam->getHashArray();
117                    break;
118                }
119                $this->arrErr = SC_Helper_Customer_Ex::sfCustomerMypageErrorCheck($objFormParam);
120                $this->arrForm = $objFormParam->getHashArray();
121
122                // 入力エラーなし
123                if (empty($this->arrErr)) {
124                    //パスワード表示
125                    $this->passlen      = SC_Utils_Ex::sfPassLen(strlen($this->arrForm['password']));
126
127                    $this->tpl_mainpage = 'mypage/change_confirm.tpl';
128                    $this->tpl_title    = '会員登録(確認ページ)';
129                    $this->tpl_subtitle = '会員登録内容変更(確認ページ)';
130                }
131                break;
132            // 会員登録と完了画面
133            case 'complete':
134                $this->arrErr = SC_Helper_Customer_Ex::sfCustomerMypageErrorCheck($objFormParam);
135                $this->arrForm = $objFormParam->getHashArray();
136
137                // 入力エラーなし
138                if (empty($this->arrErr)) {
139                    // 会員情報の登録
140                    $this->lfRegistCustomerData($objFormParam, $customer_id);
141
142                    //セッション情報を最新の状態に更新する
143                    $objCustomer->updateSession();
144
145
146                    // 完了ページに移動させる。
147                    SC_Response_Ex::sendRedirect('change_complete.php');
148                }
149                break;
150            // 確認ページからの戻り
151            case 'return':
152                $this->arrForm = $objFormParam->getHashArray();
153                break;
154            default:
155                $this->arrForm = SC_Helper_Customer_Ex::sfGetCustomerData($customer_id);
156                break;
157        }
158
159    }
160
161    /**
162     * デストラクタ.
163     *
164     * @return void
165     */
166    function destroy()
167    {
168        parent::destroy();
169    }
170
171    /**
172     *  会員情報を登録する
173     *
174     * @param mixed $objFormParam
175     * @param mixed $customer_id
176     * @access private
177     * @return void
178     */
179    function lfRegistCustomerData(&$objFormParam, $customer_id)
180    {
181        $arrRet             = $objFormParam->getHashArray();
182        $sqlval             = $objFormParam->getDbArray();
183        $sqlval['birth']    = SC_Utils_Ex::sfGetTimestamp($arrRet['year'], $arrRet['month'], $arrRet['day']);
184
185        SC_Helper_Customer_Ex::sfEditCustomerData($sqlval, $customer_id);
186    }
187
188    /**
189     * 入力エラーのチェック.
190     *
191     * @param array $arrRequest リクエスト値($_GET)
192     * @return array $arrErr エラーメッセージ配列
193     */
194    function lfCheckError($arrRequest)
195    {
196        // パラメーター管理クラス
197        $objFormParam = new SC_FormParam_Ex();
198        // パラメーター情報の初期化
199        $objFormParam->addParam('郵便番号1', 'zip01', ZIP01_LEN, 'n', array('EXIST_CHECK', 'NUM_COUNT_CHECK', 'NUM_CHECK'));
200        $objFormParam->addParam('郵便番号2', 'zip02', ZIP02_LEN, 'n', array('EXIST_CHECK', 'NUM_COUNT_CHECK', 'NUM_CHECK'));
201        // // リクエスト値をセット
202        $arrData['zip01'] = $arrRequest['zip01'];
203        $arrData['zip02'] = $arrRequest['zip02'];
204        $objFormParam->setParam($arrData);
205        // エラーチェック
206        $arrErr = $objFormParam->checkError();
207
208        return $arrErr;
209    }
210}
Note: See TracBrowser for help on using the repository browser.