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

Revision 23124, 7.2 KB checked in by kimoto, 11 years ago (diff)

#2043 typo修正・ソース整形・ソースコメントの改善 for 2.13.0
PHP4的な書き方の修正

  • 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    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',strtotime('now')));
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                        // 該当無し
112                        else {
113                            $this->arrErr['zip01'] = '※該当する住所が見つかりませんでした。<br>';
114                        }
115                    }
116                    break;
117                }
118                $this->arrErr = SC_Helper_Customer_Ex::sfCustomerMypageErrorCheck($objFormParam);
119
120                // 入力エラーなし
121                if (empty($this->arrErr)) {
122                    //パスワード表示
123                    $this->passlen      = SC_Utils_Ex::sfPassLen(strlen($objFormParam->getValue('password')));
124
125                    $this->tpl_mainpage = 'mypage/change_confirm.tpl';
126                    $this->tpl_title    = '会員登録(確認ページ)';
127                    $this->tpl_subtitle = '会員登録内容変更(確認ページ)';
128                }
129                break;
130            // 会員登録と完了画面
131            case 'complete':
132                $this->arrErr = SC_Helper_Customer_Ex::sfCustomerMypageErrorCheck($objFormParam);
133
134                // 入力エラーなし
135                if (empty($this->arrErr)) {
136                    // 会員情報の登録
137                    $this->lfRegistCustomerData($objFormParam, $customer_id);
138
139                    //セッション情報を最新の状態に更新する
140                    $objCustomer->updateSession();
141
142                    // 完了ページに移動させる。
143                    SC_Response_Ex::sendRedirect('change_complete.php');
144                }
145                break;
146            // 確認ページからの戻り
147            case 'return':
148                // quiet.
149                break;
150            default:
151                $objFormParam->setParam(SC_Helper_Customer_Ex::sfGetCustomerData($customer_id));
152                break;
153        }
154        $this->arrForm = $objFormParam->getFormParamList();
155    }
156
157    /**
158     *  会員情報を登録する
159     *
160     * @param mixed $objFormParam
161     * @param mixed $customer_id
162     * @access private
163     * @return void
164     */
165    public function lfRegistCustomerData(&$objFormParam, $customer_id)
166    {
167        $arrRet             = $objFormParam->getHashArray();
168        $sqlval             = $objFormParam->getDbArray();
169        $sqlval['birth']    = SC_Utils_Ex::sfGetTimestamp($arrRet['year'], $arrRet['month'], $arrRet['day']);
170
171        SC_Helper_Customer_Ex::sfEditCustomerData($sqlval, $customer_id);
172    }
173
174    /**
175     * 入力エラーのチェック.
176     *
177     * @param  array $arrRequest リクエスト値($_GET)
178     * @return array $arrErr エラーメッセージ配列
179     */
180    public function lfCheckError($arrRequest)
181    {
182        // パラメーター管理クラス
183        $objFormParam = new SC_FormParam_Ex();
184        // パラメーター情報の初期化
185        $objFormParam->addParam('郵便番号1', 'zip01', ZIP01_LEN, 'n', array('EXIST_CHECK', 'NUM_COUNT_CHECK', 'NUM_CHECK'));
186        $objFormParam->addParam('郵便番号2', 'zip02', ZIP02_LEN, 'n', array('EXIST_CHECK', 'NUM_COUNT_CHECK', 'NUM_CHECK'));
187        // // リクエスト値をセット
188        $arrData['zip01'] = $arrRequest['zip01'];
189        $arrData['zip02'] = $arrRequest['zip02'];
190        $objFormParam->setParam($arrData);
191        // エラーチェック
192        $arrErr = $objFormParam->checkError();
193
194        return $arrErr;
195    }
196}
Note: See TracBrowser for help on using the repository browser.