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

Revision 23647, 7.2 KB checked in by Seasoft, 10 years ago (diff)

#2635 (無駄な処理を改善する for 2.13.4)

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