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

Revision 22926, 7.3 KB checked in by Seasoft, 11 years ago (diff)

#2287 (環境によりデストラクタが正しく動作しないケースがある)
#2288 (リクエスト単位で実行されるべきログ出力がブロックにも適用されている)
#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.13.0)

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