source: branches/comu-ver2/data/class/pages/mypage/LC_Page_Mypage_Favorite.php @ 17955

Revision 17955, 10.2 KB checked in by Seasoft, 15 years ago (diff)

「お気に入り登録機能」の重複表示の修正。
・Linux-user 様の報告。  http://xoops.ec-cube.net/modules/newbb/viewtopic.php?topic_id=3739&forum=1
・使用するビューが誤っていた。

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