Ticket #792: download.patch

File download.patch, 8.5 KB (added by nanasess, 10 years ago)
  • data/class/db/SC_DB_DBFactory.php

    === modified file 'data/class/db/SC_DB_DBFactory.php'
     
    122122    function getSendHistoryWhereStartdateSql() { return null; } 
    123123 
    124124    /** 
     125     * ダウンロード販売の検索条件の SQL を返す. 
     126     * 
     127     * @param string $dtb_order_alias 
     128     * @return string 検索条件の SQL 
     129     */ 
     130    function getDownloadableDaysWhereSql($dtb_order_alias) { return null; } 
     131 
     132    /** 
    125133     * 文字列連結を行う. 
    126134     * 
    127135     * @param array $columns 連結を行うカラム名 
  • data/class/db/dbfactory/SC_DB_DBFactory_MYSQL.php

    === modified file 'data/class/db/dbfactory/SC_DB_DBFactory_MYSQL.php'
     
    136136    } 
    137137 
    138138    /** 
     139     * ダウンロード販売の検索条件の SQL を返す. 
     140     * 
     141     * @param string $dtb_order_alias 
     142     * @return string 検索条件の SQL 
     143     */ 
     144    function getDownloadableDaysWhereSql($dtb_order_alias) { 
     145        return "(SELECT IF((SELECT d1.downloadable_days_unlimited FROM dtb_baseinfo d1)=1, 1, DATE(NOW()) <= DATE(DATE_ADD(" . $dtb_order_alias . ".commit_date, INTERVAL (SELECT downloadable_days FROM dtb_baseinfo) DAY))))"; 
     146    } 
     147 
     148    /** 
    139149     * 文字列連結を行う. 
    140150     * 
    141151     * @param array $columns 連結を行うカラム名 
  • data/class/db/dbfactory/SC_DB_DBFactory_PGSQL.php

    === modified file 'data/class/db/dbfactory/SC_DB_DBFactory_PGSQL.php'
     
    116116    } 
    117117 
    118118    /** 
     119     * ダウンロード販売の検索条件の SQL を返す. 
     120     * 
     121     * @param string $dtb_order_alias 
     122     * @return string 検索条件の SQL 
     123     */ 
     124    function getDownloadableDaysWhereSql($dtb_order_alias) { 
     125        $baseinfo = SC_Helper_DB_Ex::sf_getBasisData(); 
     126        return "(SELECT CASE WHEN (SELECT d1.downloadable_days_unlimited FROM dtb_baseinfo d1) = 1 THEN 1 WHEN DATE(NOW()) <= DATE(" . $dtb_order_alias . ".commit_date + '". $baseinfo['downloadable_days'] ." days') THEN 1 ELSE 0 END)"; 
     127    } 
     128 
     129    /** 
    119130     * 文字列連結を行う. 
    120131     * 
    121132     * @param array $columns 連結を行うカラム名 
  • data/class/pages/mypage/LC_Page_Mypage_DownLoad.php

    === modified file 'data/class/pages/mypage/LC_Page_Mypage_DownLoad.php'
     
    5353     */ 
    5454    function process() { 
    5555        ob_end_clean(); 
     56 
     57        $customer_id = $_SESSION['customer']['customer_id']; 
     58        $order_id = $_GET['order_id']; 
     59        $product_id = $_GET['product_id']; 
     60 
     61        // ID の数値チェック 
     62        // TODO SC_FormParam でチェックした方が良い? 
     63        if (!is_numeric($customer_id) 
     64            || !is_numeric($order_id) 
     65            || !is_numeric($product_id)) { 
     66            SC_Utils_Ex::sfDispSiteError(""); 
     67        } 
     68 
     69 
    5670        $objCustomer = new SC_Customer(); 
    5771        //ログインしていない場合 
    5872        if (!$objCustomer->isLoginSuccess()){ 
     
    6074        } else { 
    6175        //ログインしている場合 
    6276            //DBから商品情報の読込 
    63             $arrForm = $this->lfGetRealFileName($_GET['product_id']); 
     77 
     78            $arrForm = $this->lfGetRealFileName($customer_id, $order_id, $product_id); 
    6479 
    6580            //ステータスが支払済み以上である事 
    6681            if ($arrForm["status"] < ORDER_DELIV){ 
     
    100115        } 
    101116    } 
    102117 
    103     /* 商品情報の読み込み */ 
    104     function lfGetRealFileName($product_id) { 
     118    /** 
     119     * 商品情報の読み込みを行う. 
     120     * 
     121     * @param integer $customer_id 顧客ID 
     122     * @param integer $order_id 受注ID 
     123     * @param integer $product_id 商品ID 
     124     * @return array 商品情報の配列 
     125     */ 
     126    function lfGetRealFileName($customer_id, $order_id, $product_id) { 
    105127        $objQuery = new SC_Query(); 
    106128        $col = "*"; 
    107129        $table = "vw_download_class AS T1"; 
    108         // FIXME order_id, product_id の妥当性をチェックすべき. 
    109         if (DB_TYPE == "mysql"){ 
    110             $where = "T1.customer_id = " . (int)$_SESSION['customer']['customer_id'] . " AND T1.order_id = " . (int)$_GET['order_id'] . " AND T1.product_id = " . (int)$_GET['product_id'] . 
    111                 " AND (SELECT IF((SELECT d1.downloadable_days_unlimited FROM dtb_baseinfo d1)=1, 1, DATE(NOW()) <= DATE(DATE_ADD(T1.commit_date, INTERVAL (SELECT downloadable_days FROM dtb_baseinfo) DAY)))) = 1;"; 
    112         }else{ 
    113             $baseinfo = SC_Helper_DB_Ex::sf_getBasisData(); 
    114             $where = "T1.customer_id = " . (int)$_SESSION['customer']['customer_id'] . " AND T1.order_id = " . (int)$_GET['order_id'] . " AND T1.product_id = " . (int)$_GET['product_id'] . 
    115                 " AND (SELECT CASE WHEN (SELECT d1.downloadable_days_unlimited FROM dtb_baseinfo d1) = 1 THEN 1 WHEN DATE(NOW()) <= DATE(T1.commit_date + '". $baseinfo['downloadable_days'] ." days') THEN 1 ELSE 0 END) = 1;"; 
    116         } 
    117         $arrRet = $objQuery->select($col, $table, $where); 
     130        $dbFactory = SC_DB_DBFactory_Ex::getInstance(); 
     131        $where = "T1.customer_id = ? AND T1.order_id = ? AND T1.product_id = ?"; 
     132        $where .= " AND " . $dbFactory->getDownloadableDaysWhereSql("T1"); 
     133        $where .= " = 1"; 
     134        $arrRet = $objQuery->select($col, $table, $where, 
     135                                    array($customer_id, $order_id, $product_id)); 
    118136        return $arrRet[0]; 
    119137    } 
    120138 
  • data/class/pages/mypage/LC_Page_Mypage_History.php

    === modified file 'data/class/pages/mypage/LC_Page_Mypage_History.php'
     
    221221     */ 
    222222    function lfGetOrderDetail($orderId) { 
    223223        $objQuery = new SC_Query(); 
    224         if (DB_TYPE == "mysql"){ 
    225             $col = "od.product_id AS product_id, od.product_code AS product_code, od.product_name AS product_name, od.classcategory_name1 AS classcategory_name1,"; 
    226             $col .= "od.classcategory_name2 AS classcategory_name2, od.price AS price, od.quantity AS quantity, od.point_rate AS point_rate"; 
    227             $col .= ",CASE WHEN EXISTS(SELECT * FROM dtb_products WHERE product_id = od.product_id AND del_flg = 0 AND status = 1) THEN '1' ELSE '0' END AS enable"; 
    228             $col .= ",o.status AS status, p.down AS down, (SELECT IF((SELECT d1.downloadable_days_unlimited FROM dtb_baseinfo d1)=1, 1, DATE(NOW()),"; 
    229             $col .= "<= DATE(DATE_ADD(o.commit_date, INTERVAL (SELECT downloadable_days FROM dtb_baseinfo) DAY)))) AS effective"; 
    230         }else{ 
    231             $baseinfo = SC_Helper_DB_Ex::sf_getBasisData(); 
    232             $col = "od.product_id AS product_id, od.product_code AS product_code, od.product_name AS product_name, od.classcategory_name1 AS classcategory_name1,"; 
    233             $col .= "od.classcategory_name2 AS classcategory_name2, od.price AS price, od.quantity AS quantity, od.point_rate AS point_rate"; 
    234             $col .= ",CASE WHEN EXISTS(SELECT * FROM dtb_products WHERE product_id = od.product_id AND del_flg = 0 AND status = 1) THEN '1' ELSE '0' END AS enable"; 
    235             $col .= ",o.status AS status, p.down AS down, (SELECT CASE WHEN (SELECT d1.downloadable_days_unlimited FROM dtb_baseinfo d1) = 1 THEN 1 WHEN DATE(NOW())"; 
    236             $col .= "<= DATE(o.commit_date + '". $baseinfo['downloadable_days'] ." days') THEN 1 ELSE 0 END) AS effective"; 
    237         } 
     224        $dbFactory = SC_DB_DBFactory_Ex::getInstance(); 
     225 
     226        $col = "od.product_id AS product_id, od.product_code AS product_code, od.product_name AS product_name, od.classcategory_name1 AS classcategory_name1,"; 
     227        $col .= "od.classcategory_name2 AS classcategory_name2, od.price AS price, od.quantity AS quantity, od.point_rate AS point_rate"; 
     228        $col .= ",CASE WHEN EXISTS(SELECT * FROM dtb_products WHERE product_id = od.product_id AND del_flg = 0 AND status = 1) THEN '1' ELSE '0' END AS enable"; 
     229        $col .= ",o.status AS status, p.down AS down, "; 
     230        $col .= $dbFactory->getDownloadableDaysWhereSql("o"); 
     231        $col .= " AS effective"; 
     232 
    238233        $where = "p.product_id = od.product_id AND od.order_id = o.order_id AND od.order_id = ?"; 
    239234        $objQuery->setOrder("classcategory_id1, classcategory_id2"); 
    240235        $arrRet = $objQuery->select($col, "dtb_products p, dtb_order_detail od, dtb_order o", $where, array($orderId));