source: branches/comu/html/products/review.php @ 12197

Revision 12197, 5.2 KB checked in by adati, 17 years ago (diff)

1.3.0正式版のマージ

Line 
1<?php
2/*
3 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
4 *
5 * http://www.lockon.co.jp/
6 */
7require_once("../require.php");
8
9class LC_Page {
10    function LC_Page() {
11        $this->tpl_mainpage = 'products/review.tpl';
12        global $arrRECOMMEND;
13        $this->arrRECOMMEND = $arrRECOMMEND;
14        global $arrSex;
15        $this->arrSex = $arrSex;
16    }
17}
18
19$objPage = new LC_Page();
20$objView = new SC_SiteView();
21$objQuery = new SC_Query();
22
23//---- ÅÐÏ¿ÍÑ¥«¥é¥àÇÛÎó
24$arrRegistColumn = array(
25                             array(  "column" => "review_id", "convert" => "aKV" ),
26                             array(  "column" => "product_id", "convert" => "aKV" ),
27                             array(  "column" => "reviewer_name", "convert" => "aKV" ),
28                             array(  "column" => "reviewer_url", "convert" => "a"),
29                             array(  "column" => "sex", "convert" => "n" ),
30                             array(  "column" => "email", "convert" => "a" ),
31                             array(  "column" => "recommend_level", "convert" => "n" ),
32                             array(  "column" => "title", "convert" => "aKV" ),
33                             array(  "column" => "comment", "convert" => "aKV" ),
34
35                        );
36switch ($_POST['mode']){
37case 'confirm':
38    $arrForm = lfConvertParam($_POST, $arrRegistColumn);
39    $objPage->arrErr = lfErrorCheck($arrForm);
40    //½ÅÊ£¥á¥Ã¥»¡¼¥¸¤ÎȽÄê
41    $flag = $objQuery->count("dtb_review","product_id = ? AND title = ? ", array($arrForm['product_id'], $arrForm['title']));
42
43    if ($flag > 0){
44        $objPage->arrErr['title'] .= "½ÅÊ£¤·¤¿¥¿¥¤¥È¥ë¤ÏÅÐÏ¿¤Ç¤­¤Þ¤»¤ó¡£";
45    }
46       
47    //¥¨¥é¡¼¥Á¥§¥Ã¥¯
48    if($objPage->arrErr == ""){
49        //½ÅÊ£¥¿¥¤¥È¥ë¤Ç¤Ê¤¤
50        if($flag == 0){
51            //¾¦ÉÊ̾¤Î¼èÆÀ
52            $arrForm['name'] = $objQuery->get("dtb_products", "name", "product_id = ? ", array($arrForm['product_id']));
53            $objPage->arrForm = $arrForm;
54            $objPage->tpl_mainpage = 'products/review_confirm.tpl';
55        }
56    } else {
57        //¾¦ÉÊ̾¤Î¼èÆÀ
58        $arrForm['name'] = $objQuery->get("dtb_products", "name", "product_id = ? ", array($arrForm['product_id']));   
59        $objPage->arrForm = $arrForm;
60    }
61    break;
62
63case 'return':
64    foreach($_POST as $key => $val){
65        $objPage->arrForm[ $key ] = $val;
66    }
67   
68    //¾¦ÉÊ̾¤Î¼èÆÀ
69    $objPage->arrForm['name'] = $objQuery->get("dtb_products", "name", "product_id = ? ", array($objPage->arrForm['product_id']));
70    if(empty($objPage->arrForm['name'])) {
71        sfDispSiteError(PAGE_ERROR);
72    }
73    break;
74
75case 'complete':
76    $arrForm = lfConvertParam($_POST, $arrRegistColumn);
77    $arrErr = lfErrorCheck($arrForm);
78    //½ÅÊ£¥á¥Ã¥»¡¼¥¸¤ÎȽÄê
79    $flag = $objQuery->count("dtb_review","product_id = ? AND title = ? ", array($arrForm['product_id'], $arrForm['title']));
80    //¥¨¥é¡¼¥Á¥§¥Ã¥¯
81    if ($arrErr == ""){
82        //½ÅÊ£¥¿¥¤¥È¥ë¤Ç¤Ê¤¤
83        if($flag == 0) {
84            //ÅÐÏ¿¼Â¹Ô
85            lfRegistRecommendData($arrForm, $arrRegistColumn);
86            //¥ì¥Ó¥å¡¼½ñ¤­¹þ¤ß´°Î»¥Ú¡¼¥¸¤Ø
87            header("Location: " . sfGetCurrentUri() . "/review_complete.php");
88            exit;
89        }
90    } else {
91        if($flag > 0) {
92            sfDispSiteError(PAGE_ERROR);
93        }
94    }
95    break;
96
97default:
98    if(sfIsInt($_GET['product_id'])) {
99        //¾¦ÉʾðÊó¤Î¼èÆÀ
100        $arrForm = $objQuery->select("product_id, name", "dtb_products", "del_flg = 0 AND status = 1 AND product_id=?", array($_GET['product_id']));
101        if(empty($arrForm)) {
102            sfDispSiteError(PAGE_ERROR);
103        }
104        $objPage->arrForm = $arrForm[0];
105    }
106    break;
107
108}
109
110$objView->assignobj($objPage);
111$objView->display($objPage->tpl_mainpage);                 
112
113//-----------------------------------------------------------------------------------------------------------------------------------
114
115
116//¥¨¥é¡¼¥Á¥§¥Ã¥¯
117
118function lfErrorCheck() {
119    $objErr = new SC_CheckError();
120    $objErr->doFunc(array("¾¦ÉÊID", "product_id", INT_LEN), array("EXIST_CHECK", "MAX_LENGTH_CHECK"));         
121    $objErr->doFunc(array("Åê¹Æ¼Ô̾", "reviewer_name", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
122    $objErr->doFunc(array("URL", "reviewer_url", MTEXT_LEN), array("MAX_LENGTH_CHECK", "URL_CHECK"));
123    $objErr->doFunc(array("¤ª¤¹¤¹¤á¥ì¥Ù¥ë", "recommend_level"), array("SELECT_CHECK"));
124    $objErr->doFunc(array("¥¿¥¤¥È¥ë", "title", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
125    $objErr->doFunc(array("¥³¥á¥ó¥È", "comment", LTEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
126
127    return $objErr->arrErr;
128}
129
130//----¡¡¼èÆÀʸ»úÎó¤ÎÊÑ´¹
131function lfConvertParam($array, $arrRegistColumn) {
132    /*
133     *  ʸ»úÎó¤ÎÊÑ´¹
134     *  K :  ¡ÖȾ³Ñ(ŽÊŽÝŽ¶Ž¸)ÊÒ²¾Ì¾¡×¤ò¡ÖÁ´³ÑÊÒ²¾Ì¾¡×¤ËÊÑ´¹
135     *  C :  ¡ÖÁ´³Ñ¤Ò¤é²¾Ì¾¡×¤ò¡ÖÁ´³Ñ¤«¤¿²¾Ì¾¡×¤ËÊÑ´¹
136     *  V :  ÂùÅÀÉÕ¤­¤Îʸ»ú¤ò°ìʸ»ú¤ËÊÑ´¹¡£"K","H"¤È¶¦¤Ë»ÈÍѤ·¤Þ¤¹ 
137     *  n :  ¡ÖÁ´³Ñ¡×¿ô»ú¤ò¡ÖȾ³Ñ(ŽÊŽÝŽ¶Ž¸)¡×¤ËÊÑ´¹
138     *  a :  Á´³Ñ±Ñ¿ô»ú¤òȾ³Ñ±Ñ¿ô»ú¤ËÊÑ´¹¤¹¤ë
139     */
140    // ¥«¥é¥à̾¤È¥³¥ó¥Ð¡¼¥È¾ðÊó
141    foreach ($arrRegistColumn as $data) {
142        $arrConvList[ $data["column"] ] = $data["convert"];
143    }
144    // ʸ»úÊÑ´¹
145    foreach ($arrConvList as $key => $val) {
146        // POST¤µ¤ì¤Æ¤­¤¿ÃͤΤßÊÑ´¹¤¹¤ë¡£
147        if(strlen(($array[$key])) > 0) {
148            $array[$key] = mb_convert_kana($array[$key] ,$val);
149        }
150    }
151    return $array;
152}
153
154//ÅÐÏ¿¼Â¹Ô
155function lfRegistRecommendData ($array, $arrRegistColumn) {
156    global $objQuery;
157   
158    // ²¾ÅÐÏ¿
159    foreach ($arrRegistColumn as $data) {
160        if (strlen($array[ $data["column"] ]) > 0 ) {
161            $arrRegist[ $data["column"] ] = $array[ $data["column"] ];
162        }
163    }
164    $arrRegist['create_date'] = 'now()';
165    $arrRegist['update_date'] = 'now()';
166    $arrRegist['creator_id'] = '0';
167    //-- ÅÐÏ¿¼Â¹Ô
168    $objQuery->begin();
169    $objQuery->insert("dtb_review", $arrRegist);
170    $objQuery->commit();
171}
172
173?>
Note: See TracBrowser for help on using the repository browser.