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

Revision 18069, 10.2 KB checked in by Seasoft, 14 years ago (diff)

merge r17931, r17932, r17933
・取得元: version-2_4
【取得元のログメッセージ】

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