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

Revision 17509, 10.1 KB checked in by Seasoft, 16 years ago (diff)

パラメータ設定により、在庫無し商品を一覧に非表示しないように設定可能とする。
※ カテゴリ別おすすめ商品( SC_Utils::sfGetBestProducts() )はテスト方法が分からず、未テスト。
※ dtb_maker_count の更新は未対応。

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