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

Revision 18838, 10.1 KB checked in by Ringo, 14 years ago (diff)

#634(new バグ指摘) まずは「お気に入り一覧」にて。。。修正方法に問題なければ、残りにも適用。

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