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

Revision 22926, 6.2 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 
[16093]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.
[16093]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.
[16093]22 */
23
[20534]24require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';
[16093]25
26/**
27 * お届け先追加 のページクラス.
28 *
29 * @package Page
30 * @author LOCKON CO.,LTD.
31 * @version $Id$
32 */
[22856]33class LC_Page_Mypage_DeliveryAddr extends LC_Page_Ex
[22567]34{
[16093]35    /**
36     * Page を初期化する.
37     *
38     * @return void
39     */
[22567]40    function init()
41    {
[16093]42        parent::init();
[21514]43        $this->tpl_title    = 'お届け先の追加・変更';
[20156]44        $masterData         = new SC_DB_MasterData_Ex();
45        $this->arrPref      = $masterData->getMasterData('mtb_pref');
[18187]46        $this->httpCacheControl('nocache');
[20580]47        $this->validUrl = array(MYPAGE_DELIVADDR_URLPATH,
48                                DELIV_URLPATH,
49                                MULTIPLE_URLPATH);
[16093]50    }
51
52    /**
53     * Page のプロセス.
54     *
55     * @return void
56     */
[22567]57    function process()
58    {
[19661]59        parent::process();
60        $this->action();
61        $this->sendResponse();
62    }
63
64    /**
65     * Page のAction.
66     *
67     * @return void
68     */
[22567]69    function action()
70    {
[20490]71        $objCustomer = new SC_Customer_Ex();
[22065]72        $objAddress  = new SC_Helper_Address_Ex();
[20156]73        $ParentPage  = MYPAGE_DELIVADDR_URLPATH;
[16093]74
75        // GETでページを指定されている場合には指定ページに戻す
76        if (isset($_GET['page'])) {
[20156]77            $ParentPage = htmlspecialchars($_GET['page'], ENT_QUOTES);
78        } else if (isset($_POST['ParentPage'])) {
79            $ParentPage = htmlspecialchars($_POST['ParentPage'], ENT_QUOTES);
[16093]80        }
81        $this->ParentPage = $ParentPage;
[20041]82
[19872]83        /*
84         * ログイン判定 及び 退会判定
85         * 未ログインでも, 複数配送設定ページからのアクセスの場合は表示する
[20156]86         *
87         * TODO 購入遷移とMyPageで別クラスにすべき
[19872]88         */
[21441]89        if (!$objCustomer->isLoginSuccess(true) && $ParentPage != MULTIPLE_URLPATH) {
[18845]90            $this->tpl_onload = "fnUpdateParent('". $this->getLocation($_POST['ParentPage']) ."'); window.close();";
[16093]91        }
92
[21012]93        // other_deliv_id のあるなしで追加か編集か判定しているらしい
94        $_SESSION['other_deliv_id'] = $_REQUEST['other_deliv_id'];
[16093]95
[20970]96        // パラメーター管理クラス,パラメーター情報の初期化
[20501]97        $objFormParam   = new SC_FormParam_Ex();
[22065]98        $objAddress->setFormParam($objFormParam);
[20156]99        $objFormParam->setParam($_POST);
100        $this->arrForm  = $objFormParam->getHashArray();
[16093]101
[20041]102        switch ($this->getMode()) {
[20156]103            // 入力は必ずedit
[17302]104            case 'edit':
[22065]105                $this->arrErr = $objAddress->errorCheck($objFormParam);
[20156]106                // 入力エラーなし
[21441]107                if (empty($this->arrErr)) {
[20156]108                    // TODO ここでやるべきではない
[20580]109                    if (in_array($_POST['ParentPage'], $this->validUrl)) {
[17758]110                        $this->tpl_onload = "fnUpdateParent('". $this->getLocation($_POST['ParentPage']) ."'); window.close();";
111                    } else {
[17905]112                        SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
[17302]113                    }
[20041]114
[19991]115                    if ($objCustomer->isLoginSuccess(true)) {
[22065]116                        $this->lfRegistData($objAddress, $objFormParam, $objCustomer->getValue('customer_id'));
[19872]117                    } else {
[20156]118                        $this->lfRegistDataNonMember($objFormParam);
[19872]119                    }
[19891]120
[21441]121                    if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_MOBILE) {
[19891]122                        // モバイルの場合、元のページに遷移
123                        SC_Response_Ex::sendRedirect($this->getLocation($_POST['ParentPage']));
[21743]124                        SC_Response_Ex::actionExit();
[19891]125                    }
[17302]126                }
127                break;
[20156]128            case 'multiple':
[20697]129                // 複数配送先用
[20156]130                break;
131            default :
132
[21514]133                if ($_GET['other_deliv_id'] != '') {
[22546]134                    $arrOtherDeliv = $objAddress->getAddress($_SESSION['other_deliv_id']);
[20324]135
[20156]136                    //不正アクセス判定
[22065]137                    if (!$objCustomer->isLoginSuccess(true) || !$arrOtherDeliv) {
[20156]138                        SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
139                    }
140
141                    //別のお届け先情報取得
[22065]142                    $this->arrForm = $arrOtherDeliv;
[20156]143                }
144                break;
[17302]145        }
[20156]146
[20484]147        if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_MOBILE) {
[19961]148            $this->tpl_mainpage = 'mypage/delivery_addr.tpl';
149        } else {
150            $this->setTemplate('mypage/delivery_addr.tpl');
151        }
[21743]152
[16093]153    }
154
[20156]155    /* 登録実行 */
[22567]156    function lfRegistData($objAddress, $objFormParam, $customer_id)
157    {
[20156]158        $arrRet     = $objFormParam->getHashArray();
159        $sqlval     = $objFormParam->getDbArray();
[16093]160
[22069]161        $sqlval['other_deliv_id'] = $arrRet['other_deliv_id'];
[20156]162        $sqlval['customer_id'] = $customer_id;
[16093]163
[22546]164        $objAddress->registAddress($sqlval);
[16093]165    }
166
[22567]167    function lfRegistDataNonMember($objFormParam)
168    {
[20156]169        $arrRegistColumn = $objFormParam->getDbArray();
[20697]170        foreach ($arrRegistColumn as $key => $val) {
171            $arrRegist['shipping_' . $key ] = $val;
[19872]172        }
[20697]173        if (count($_SESSION['shipping']) >= DELIV_ADDR_MAX) {
[21514]174            SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, '', false, '別のお届け先最大登録数に達しています。');
[19872]175        } else {
176            $_SESSION['shipping'][] = $arrRegist;
177        }
178    }
[16093]179}
Note: See TracBrowser for help on using the repository browser.