source: branches/version-2_5-dev/data/class/pages/mypage/LC_Page_Mypage_Favorite.php @ 19788

Revision 19788, 10.4 KB checked in by nanasess, 13 years ago (diff)

#881(冗長な tpl_mainpage の削除)

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • 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-2010 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_PATH . "pages/LC_Page.php");
26
27/**
28 * MyPage のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id: LC_Page_Mypage.php 16582 2007-10-29 03:06:29Z nanasess $
33 */
34class LC_Page_MyPage_Favorite extends LC_Page {
35
36    // {{{ properties
37
38    /** ページナンバー */
39    var $tpl_pageno;
40
41    // }}}
42    // {{{ functions
43
44    /**
45     * Page を初期化する.
46     *
47     * @return void
48     */
49    function init() {
50        parent::init();
51        $this->tpl_title = 'MYページ';
52        $this->tpl_subtitle = 'お気に入り一覧';
53        $this->tpl_navi = TEMPLATE_DIR . 'mypage/navi.tpl';
54        $this->tpl_mainno = 'mypage';
55        $this->tpl_mypageno = 'favorite';
56    }
57
58    /**
59     * Page のプロセス.
60     *
61     * @return void
62     */
63    function process() {
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        //$objView = new SC_SiteView();
77        $objQuery = new SC_Query();
78        $objCustomer = new SC_Customer();
79       
80        // 退会判定用情報の取得
81        $this->tpl_login = $objCustomer->isLoginSuccess();
82
83        // ログインチェック
84        if(!$objCustomer->isLoginSuccess()) {
85            SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
86        }else {
87            // マイページトップ顧客情報表示用
88            $this->CustomerName1 = $objCustomer->getvalue('name01');
89            $this->CustomerName2 = $objCustomer->getvalue('name02');
90            $this->CustomerPoint = $objCustomer->getvalue('point');
91        }
92
93        // お気に入り削除
94        if ($_POST['mode'] == 'delete_favorite') {
95            $customer_id = $objCustomer->getValue('customer_id');
96            $this->lfDeleteFavoriteProduct($customer_id, $_POST['product_id']);
97        }
98
99        // ページ送り用
100        if (isset($_POST['pageno'])) {
101            $this->tpl_pageno = htmlspecialchars($_POST['pageno'], ENT_QUOTES, CHAR_CODE);
102        }
103
104        // FIXME SC_Product クラスを使用した実装
105        $col = "alldtl.*";
106        $from = "dtb_customer_favorite_products AS dcfp LEFT JOIN vw_products_allclass_detail AS alldtl USING(product_id)";
107       
108        $where = "dcfp.customer_id = ? AND alldtl.del_flg = 0 AND alldtl.status = 1";
109        // 在庫無し商品の非表示
110        if (NOSTOCK_HIDDEN === true) {
111            $where .= ' AND (alldtl.stock_max >= 1 OR alldtl.stock_unlimited_max = 1)';
112        }
113        $order = "create_date DESC";
114
115        $arrval = array($objCustomer->getvalue('customer_id'));
116
117        // お気に入りの数を取得
118        $linemax = $objQuery->count($from, $where, $arrval);
119        $this->tpl_linemax = $linemax;
120
121        // ページ送りの取得
122        $objNavi = new SC_PageNavi($this->tpl_pageno, $linemax, SEARCH_PMAX, "fnNaviPage", NAVI_PMAX);
123        $this->tpl_strnavi = $objNavi->strnavi;     // 表示文字列
124        $startno = $objNavi->start_row;
125
126        // 取得範囲の指定(開始行番号、行数のセット)
127        $objQuery->setLimitOffset(SEARCH_PMAX, $startno);
128        // 表示順序
129        $objQuery->setOrder($order);
130
131        // お気に入りの取得
132        $this->arrFavorite = $objQuery->select($col, $from, $where, $arrval);
133
134        // パラメータ管理クラス
135        $this->objFormParam = new SC_FormParam();
136        // POST値の取得
137        $this->objFormParam->setParam($_POST);
138
139        // 入力情報を渡す
140        $this->arrForm = $this->objFormParam->getFormParamList();
141        //$objView->assignobj($this);               //$objpage内の全てのテンプレート変数をsmartyに格納
142        //$objView->display(SITE_FRAME);                //パスとテンプレート変数の呼び出し、実行
143    }
144
145    /**
146     * モバイルページを初期化する.
147     *
148     * @return void
149     */
150    function mobileInit() {
151        $this->init();
152        $this->tpl_mainpage = 'mypage/favorite.tpl';
153        $this->tpl_title = 'MYページ/お気に入り一覧';
154    }
155
156    /**
157     * Page のプロセス(モバイル).
158     *
159     * @return void
160     */
161    function mobileProcess() {
162        parent::mobileProcess();
163        $this->mobileAction();
164        $this->sendResponse();
165    }
166
167    /**
168     * Page のAction(モバイル).
169     *
170     * @return void
171     */
172    function mobileAction() {
173        //$objView = new SC_MobileView();
174        $objQuery = new SC_Query();
175        $objCustomer = new SC_Customer();
176        // クッキー管理クラス
177        $objCookie = new SC_Cookie(COOKIE_EXPIRE);
178        // パラメータ管理クラス
179        $objFormParam = new SC_FormParam();
180        // パラメータ情報の初期化
181        $this->lfInitParamMobile($objFormParam);
182        // POST値の取得
183        $objFormParam->setParam($_POST);
184
185        // 携帯端末IDが一致する会員が存在するかどうかをチェックする。
186        $this->tpl_valid_phone_id = $objCustomer->checkMobilePhoneId();
187
188        if (!isset($_POST['mode'])) $_POST['mode'] = "";
189
190        // ログイン処理
191        if($_POST['mode'] == 'login') {
192            $objFormParam->toLower('login_email');
193            $arrErr = $objFormParam->checkError();
194            $arrForm =  $objFormParam->getHashArray();
195
196            // クッキー保存判定
197            if ($arrForm['login_memory'] == "1" && $arrForm['login_email'] != "") {
198                $objCookie->setCookie('login_email', $_POST['login_email']);
199            } else {
200                $objCookie->setCookie('login_email', '');
201            }
202
203            if (count($arrErr) == 0){
204                if($objCustomer->getCustomerDataFromMobilePhoneIdPass($arrForm['login_pass']) ||
205                   $objCustomer->getCustomerDataFromEmailPass($arrForm['login_pass'], $arrForm['login_email'], true)) {
206                    // ログインが成功した場合は携帯端末IDを保存する。
207                    $objCustomer->updateMobilePhoneId();
208
209                    /*
210                     * email がモバイルドメインでは無く,
211                     * 携帯メールアドレスが登録されていない場合
212                     */
213                    $objMobile = new SC_Helper_Mobile_Ex();
214                    if (!$objMobile->gfIsMobileMailAddress($objCustomer->getValue('email'))) {
215                        if (!$objCustomer->hasValue('email_mobile')) {
216                            $this->objDisplay->redirect($this->getLocation("../entry/email_mobile.php"));
217                        }
218                    }
219                } else {
220                    $objQuery = new SC_Query;
221                    $where = "(email = ? OR email_mobile = ?) AND status = 1 AND del_flg = 0";
222                    $ret = $objQuery->count("dtb_customer", $where, array($arrForm['login_email'], $arrForm['login_email']));
223
224                    if($ret > 0) {
225                        SC_Utils_Ex::sfDispSiteError(TEMP_LOGIN_ERROR);
226                    } else {
227                        SC_Utils_Ex::sfDispSiteError(SITE_LOGIN_ERROR);
228                    }
229                }
230            }
231        }
232
233        // TODO objViewを分けるので、$thisに置き換える TPLの修正が必須かな?
234        /*
235         * ログインチェック
236         * 携帯メールの登録を必須にする場合は isLoginSuccess(false) にする
237         */
238        if(!$objCustomer->isLoginSuccess(true)) {
239            $this->tpl_mainpage = 'mypage/login.tpl';
240            $objView->assignArray($objFormParam->getHashArray());
241            if (empty($arrErr)) $arrErr = array();
242            $objView->assignArray(array("arrErr" => $arrErr));
243        }else {
244            //マイページトップ顧客情報表示用
245            $this->CustomerName1 = $objCustomer->getvalue('name01');
246            $this->CustomerName2 = $objCustomer->getvalue('name02');
247        }
248
249        //$objView->assignobj($this);               //$objpage内の全てのテンプレート変数をsmartyに格納
250        //$objView->display(SITE_FRAME);                //パスとテンプレート変数の呼び出し、実行
251
252    }
253
254    /**
255     * デストラクタ.
256     *
257     * @return void
258     */
259    function destroy() {
260        parent::destroy();
261    }
262
263    //エラーチェック
264
265    function lfErrorCheck() {
266        $objErr = new SC_CheckError();
267        $objErr->doFunc(array("メールアドレス", "login_email", MTEXT_LEN), array("EXIST_CHECK","SPTAB_CHECK","EMAIL_CHECK","MAX_LENGTH_CHECK"));
268        $objErr->dofunc(array("パスワード", "login_password", PASSWORD_LEN2), array("EXIST_CHECK","ALNUM_CHECK"));
269        return $objErr->arrErr;
270    }
271
272    /* パラメータ情報の初期化 */
273    function lfInitParamMobile(&$objFormParam) {
274
275        $objFormParam->addParam("記憶する", "login_memory", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));
276        $objFormParam->addParam("メールアドレス", "login_email", MTEXT_LEN, "a", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
277        $objFormParam->addParam("パスワード", "login_pass", STEXT_LEN, "a", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
278    }
279
280    // お気に入り商品削除
281    function lfDeleteFavoriteProduct($customer_id, $product_id) {
282        $objQuery = new SC_Query();
283        $count = $objQuery->count("dtb_customer_favorite_products", "customer_id = ? AND product_id = ?", array($customer_id, $product_id));
284
285        if ($count > 0) {
286            $objQuery->begin();
287            $objQuery->delete('dtb_customer_favorite_products', "customer_id = ? AND product_id = ?", array($customer_id, $product_id));
288            $objQuery->commit();
289        }
290    }
291
292
293
294}
295?>
Note: See TracBrowser for help on using the repository browser.