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

Revision 22567, 6.4 KB checked in by shutta, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.12.4)
Zend Framework PHP 標準コーディング規約のコーディングスタイルへ準拠。
classおよびfunctionの開始波括弧「{」のスタイルを修正。

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