source: branches/dev/html/admin/products/review_edit.php @ 303

Revision 303, 5.6 KB checked in by kakinaka, 16 years ago (diff)
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    var $arrSession;
11    function LC_Page() {
12        $this->tpl_mainpage = 'products/review_edit.tpl';
13        $this->tpl_subnavi = 'products/subnavi.tpl';
14        $this->tpl_mainno = 'products';     
15        $this->tpl_subno = 'review';
16        global $arrRECOMMEND;
17        $this->arrRECOMMEND = $arrRECOMMEND;
18        $this->tpl_subtitle = '¥ì¥Ó¥å¡¼´ÉÍý';
19        global $arrSex;
20        $this->arrSex = $arrSex;
21    }
22}
23
24$objPage = new LC_Page();
25$objView = new SC_AdminView();
26$objSess = new SC_Session();
27$objQuery = new SC_Query();
28// ǧ¾Ú²ÄÈݤÎȽÄê
29sfIsSuccess($objSess);
30
31//¸¡º÷¥ï¡¼¥É¤Î°ú·Ñ¤®
32foreach ($_POST as $key => $val){
33    if (ereg("^search_", $key)){
34    $objPage->arrSearchHidden[$key] = $val;
35    }
36}
37
38//¼èÆÀʸ»úÎó¤ÎÊÑ´¹ÍÑ¥«¥é¥à
39$arrRegistColumn = array (     
40                                array( "column" => "update_date"),
41                                array( "column" => "status"),
42                                array( "column" => "recommend_level"),     
43                                array(  "column" => "title","convert" => "KVa"),
44                                array(  "column" => "comment","convert" => "KVa"),
45                                array(  "column" => "reviewer_name","convert" => "KVa"),
46                                array(  "column" => "reviewer_url","convert" => "KVa"),
47                                array(  "column" => "sex","convert" => "n")
48                               
49                            );
50
51//¥ì¥Ó¥å¡¼ID¤òÅϤ¹
52$objPage->tpl_review_id = $_POST['review_id'];
53//¥ì¥Ó¥å¡¼¾ðÊó¤Î¥«¥é¥à¤Î¼èÆÀ
54$objPage->arrReview = lfGetReviewData($_POST['review_id']);
55//ÅÐÏ¿ºÑ¤ß¤Î¥¹¥Æ¡¼¥¿¥¹¤òÅϤ¹
56$objPage->tpl_pre_status = $objPage->arrReview['status'];
57//¾¦Éʤ´¤È¤Î¥ì¥Ó¥å¡¼É½¼¨¿ô¼èÆÀ
58$count = $objQuery->count("dtb_review", "del_flg=0 AND status=1 AND product_id=?", array($objPage->arrReview['product_id']));
59//¥ì¥Ó¥å¡¼É½¼¨¿ô¤¬ÀßÄêÃͰʾå¤Î¾ì¹ç
60if ($count >= REVIEW_REGIST_MAX){
61    //ɽ¼¨¤ÏÁªÂò¤Ç¤­¤Ê¤¤
62    $objPage->tpl_status_change = false;
63}else{
64    //ξÊýÁªÂò²Äǽ
65    $objPage->tpl_status_change = true;
66}
67                   
68switch($_POST['mode']) {
69//ÅÐÏ¿
70case 'complete':
71    //¥Õ¥©¡¼¥àÃͤÎÊÑ´¹
72    $arrReview = lfConvertParam($_POST, $arrRegistColumn);
73    $objPage->arrErr = lfCheckError($arrReview);
74    //Èóɽ¼¨¤«¤éɽ¼¨¤Ë¥¹¥Æ¡¼¥¿¥¹¤òÀÚ¤êÂؤ¨¤Æ¡¢¾¦Éʤ´¤È¤Îɽ¼¨¥ì¥Ó¥å¡¼¿ô¤¬ÀßÄêÃͤòĶ¤¨¤Æ¤¤¤ë¤È¤­
75    if ($arrReview['pre_status'] == '2' && $arrReview['status'] == '1' && $count >= REVIEW_REGIST_MAX){
76        $objPage->arrErr['status'] = '¢¨ ¥ì¥Ó¥å¡¼É½¼¨¿ô¤Ï5·ï¤Þ¤Ç¤Ç¤¹¡£';
77        $objPage->arrReview = $arrReview;
78    } else {
79        //¥¨¥é¡¼Ìµ¤·
80        if (!$objPage->arrErr){
81            //¥ì¥Ó¥å¡¼¾ðÊó¤ÎÊÔ½¸ÅÐÏ¿
82            lfRegistReviewData($arrReview, $arrRegistColumn);
83            $objPage->arrReview = $arrReview;
84            $objPage->tpl_onload = "confirm('ÅÐÏ¿¤¬´°Î»¤·¤Þ¤·¤¿¡£');";
85        }
86    }
87    break;
88default:
89    break;
90}
91
92$objView->assignobj($objPage);
93$objView->display(MAIN_FRAME);
94
95//------------------------------------------------------------------------------------------------------------------------------------
96
97// ÆþÎÏ¥¨¥é¡¼¥Á¥§¥Ã¥¯
98function lfCheckError($array) {
99    $objErr = new SC_CheckError($array);
100    $objErr->doFunc(array("¤ª¤¹¤¹¤á¥ì¥Ù¥ë", "recommend_level"), array("SELECT_CHECK"));
101    $objErr->doFunc(array("¥¿¥¤¥È¥ë", "title", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
102    $objErr->doFunc(array("¥³¥á¥ó¥È", "comment", LTEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
103    $objErr->doFunc(array("Åê¹Æ¼Ô̾", "reviewer_name", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
104    $objErr->doFunc(array("¥Û¡¼¥à¥Ú¡¼¥¸¥¢¥É¥ì¥¹", "reviewer_url", URL_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
105    $objErr->doFunc(array("¥¿¥¤¥È¥ë", "title", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
106    $objErr->doFunc(array("À­ÊÌ", "sex", STEXT_LEN), array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK"));
107    return $objErr->arrErr;
108}
109
110//----¡¡¼èÆÀʸ»úÎó¤ÎÊÑ´¹
111function lfConvertParam($array, $arrRegistColumn) {
112    /*
113     *  ʸ»úÎó¤ÎÊÑ´¹
114     *  K :  ¡ÖȾ³Ñ(ŽÊŽÝŽ¶Ž¸)ÊÒ²¾Ì¾¡×¤ò¡ÖÁ´³ÑÊÒ²¾Ì¾¡×¤ËÊÑ´¹
115     *  C :  ¡ÖÁ´³Ñ¤Ò¤é²¾Ì¾¡×¤ò¡ÖÁ´³Ñ¤«¤¿²¾Ì¾¡×¤ËÊÑ´¹
116     *  V :  ÂùÅÀÉÕ¤­¤Îʸ»ú¤ò°ìʸ»ú¤ËÊÑ´¹¡£"K","H"¤È¶¦¤Ë»ÈÍѤ·¤Þ¤¹ 
117     *  n :  ¡ÖÁ´³Ñ¡×¿ô»ú¤ò¡ÖȾ³Ñ(ŽÊŽÝŽ¶Ž¸)¡×¤ËÊÑ´¹
118     *  a :  Á´³Ñ±Ñ¿ô»ú¤òȾ³Ñ±Ñ¿ô»ú¤ËÊÑ´¹¤¹¤ë
119     */
120    // ¥«¥é¥à̾¤È¥³¥ó¥Ð¡¼¥È¾ðÊó
121    foreach ($arrRegistColumn as $data) {
122        $arrConvList[ $data["column"] ] = $data["convert"];
123    }
124   
125    // ʸ»úÊÑ´¹
126    foreach ($arrConvList as $key => $val) {
127        // POST¤µ¤ì¤Æ¤­¤¿ÃͤΤßÊÑ´¹¤¹¤ë¡£
128        if(strlen(($array[$key])) > 0) {
129            $array[$key] = mb_convert_kana($array[$key] ,$val);
130        }
131    }
132    return $array;
133}
134
135//¥ì¥Ó¥å¡¼¾ðÊó¤Î¼èÆÀ
136function lfGetReviewData($review_id){
137    global $objPage;
138    global $objQuery;
139    $select="review_id, A.product_id, reviewer_name, sex, recommend_level, ";
140    $select.="reviewer_url, title, comment, A.status, A.create_date, A.update_date, name";
141    $from = "dtb_review AS A LEFT JOIN dtb_products AS B ON A.product_id = B.product_id ";
142    $where = "A.del_flg = 0 AND B.del_flg = 0 AND review_id = ? ";
143    $arrReview = $objQuery->select($select, $from, $where, array($review_id));
144    if(!empty($arrReview)) {
145        $objPage->arrReview = $arrReview[0];
146    } else {
147        sfDispError("");
148    }
149    return $objPage->arrReview;
150}
151
152//¥ì¥Ó¥å¡¼¾ðÊó¤ÎÊÔ½¸ÅÐÏ¿
153function lfRegistReviewData($array, $arrRegistColumn){
154    global $objQuery;
155    foreach ($arrRegistColumn as $data) {
156        if (strlen($array[ $data["column"] ]) > 0 ) {
157            $arrRegist[ $data["column"] ] = $array[ $data["column"] ];
158        }
159        if ($data['column'] == 'update_date'){
160            $arrRegist['update_date'] = 'now()';
161        }
162    }
163    //ÅÐÏ¿¼Â¹Ô
164    $objQuery->begin();
165    $objQuery->update("dtb_review", $arrRegist, "review_id='".$_POST['review_id']."'");
166    $objQuery->commit();
167}
168?>
Note: See TracBrowser for help on using the repository browser.