Exemple #1
0
        ajax_feedback(0, '1202');
    }
    if (!$data['cate_id']) {
        $data['cate_id'] = Model_Table::get('InfoCate')->saveDefaultCate($customer_id, $info_type);
    }
    //关键词过滤
    $keyArray = explode(',', $data['keyword']);
    $keyTable = new Model_KeywordList();
    foreach ($keyArray as $v) {
        $filter['where'] = "customer_id='{$customer_id}' and keyword='{$v}'";
        $nums = $keyTable->count($filter);
        if ($nums > 0 && !$_POST['id']) {
            ajax_feedback(0, '', "关键词 \"" . $v . '" 已存在,请更换');
            die;
        } elseif ($_POST['id']) {
            $num = $keyTable->fetchRow("select * from keyword_list where info_id!='{$_POST['id']}' and keyword='{$v}' and customer_id='{$customer_id}'");
            if ($num == true) {
                ajax_feedback(0, '', "关键词 \"" . $v . '" 已存在,请更换!');
                die;
            }
        }
    }
    //save-infocommon
    $info_id = Model_Table::get('InfoCommon')->upsert($data);
    //save-keywordlist
    $list = array('customer_id' => $customer_id, 'info_id' => $info_id, 'keyword' => $data['keyword'], 'info_type' => $info_type);
    Model_Table::get('KeywordList')->saveForKeywords($list);
    //return
    ajax_feedback(1);
}
//category
Exemple #2
0
 public function getInfo()
 {
     $KeywordlistModel = new Model_KeywordList();
     $keyword = $this->post_data['Keyword'];
     $filter['where'] = " customer_id='{$this->customer_id}' and keyword='{$keyword}' ";
     $filter['order'] = " rand() ";
     $sql = $KeywordlistModel->select($filter, 'info_id,info_type');
     $keywordinfo = $KeywordlistModel->fetchRow($sql);
     $base_infoarray = array('text', 'single', 'multi', 'pic', 'music', 'video');
     if ($keywordinfo['info_type']) {
         if (in_array($keywordinfo['info_type'], $base_infoarray)) {
             $class = 'base_info';
         } else {
             $class = $keywordinfo['info_type'] . '_info';
         }
         $classFile = $class . '.php';
         if (file_exists($classFile)) {
             include "{$classFile}";
             $infoobj = new $class();
             $result['info_id'] = $keywordinfo['info_id'];
             $result['info_type'] = $keywordinfo['info_type'];
             $result['customer_id'] = $this->customer_id;
             $result['fromuser'] = $this->post_data['FromUserName'];
             $result['timesign'] = $this->post_data['timesign'];
             $data = $infoobj->getData($result);
             $xmlcontent = $this->create_xmlcontent($data['msgtype'], $data['content'], $data['title'], $data['description'], $data['picurl'], $data['url'], $data['bodystr']);
             return $xmlcontent;
         }
     } else {
         include "special_info.php";
         $infoobj = new special_info();
         $result['info_id'] = $keywordinfo['info_id'];
         $result['info_type'] = $keywordinfo['info_type'];
         $result['customer_id'] = $this->customer_id;
         $result['fromuser'] = $this->post_data['FromUserName'];
         $result['timesign'] = $this->post_data['timesign'];
         $result['keyword'] = $this->post_data['Keyword'];
         $data = $infoobj->getData($result);
         if ($data['msgtype'] != '') {
             return $this->create_xmlcontent($data['msgtype'], $data['content'], $data['title'], $data['description'], $data['picurl'], $data['url'], $data['bodystr']);
         } else {
             //无匹配回复
             $replyModel = new Model_AutoReply();
             $replyRow = $replyModel->findByCustomerId($this->customer_id, '2');
             if (!$replyRow['id'] or $replyRow['state'] != '1') {
                 return false;
             } else {
                 return $this->create_xmlcontent('text', $replyRow['reply_content']);
             }
         }
     }
 }