Page
[ class tree: Page ] [ index: Page ] [ all elements ]

Source for file LC_Page_Mypage_Favorite.php

Documentation is available at LC_Page_Mypage_Favorite.php

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

Documentation generated on Fri, 24 Feb 2012 13:59:36 +0900 by Seasoft