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

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