source: branches/comu/html/admin/products/review_edit.php @ 2

Revision 2, 4.7 KB checked in by root, 17 years ago (diff)

new import

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