public function actionPlayerAdd() { if ($this->_isPost()) { if ($this->_modelPlayerFaq->add($_POST)) { $this->_modelPlayerKindFaq->update(array('count' => 'count+1'), "Id={$_POST['kind_id']}"); //数量加1 $this->_utilMsg->showMsg(false); } else { $this->_utilMsg->showMsg('增加失败', -2); } } else { $gameTypes = $this->_faqKind; $kindList = $this->_modelPlayerKindFaq->findById($_GET['kind_id']); $this->_view->assign('gameType', array('Id' => $_GET['game_type_id'], 'name' => $gameTypes[$_GET['game_type_id']])); $this->_view->assign('kindList', $kindList); $this->_view->assign('js', $this->_view->get_curJs()); $this->_utilMsg->createNavBar(); $this->_view->display(); } }
/** * 从整一个FAQ类型复制FAQ */ private function _faqCopyFromFaqType() { $this->_lang = $this->_getGlobalData('lang'); //多语言 $kindId = intval($_REQUEST['Id']); $lang_id = intval($_REQUEST['lang']); $is_syn = intval($_REQUEST['is_syn']); if ($this->_isPost()) { if (!$lang_id) { $this->_utilMsg->showMsg('语言必须', -1); } if (!$kindId) { $this->_utilMsg->showMsg('类型不能为空', -1); } //不能由其他语言复制至简体中文 if ($lang_id == 1) { $this->_utilMsg->showMsg('不允许复制至此简体中文!', -1); } $checkLangId = $this->_modelPlayerKindFaq->findLangIdByKindId($kindId); if ($lang_id == $checkLangId) { $this->_utilMsg->showMsg('不允许复制至本语言!', -1); } if ($is_syn && $lang_id != 6) { $this->_utilMsg->showMsg('暂时只允许同步繁体中文!', -1); } $translateTo = intval($_REQUEST['translateTo']) ? array('field' => 'Utf8_F2S') : array('field' => 'Utf8_S2F'); $typeData = $this->_modelPlayerKindFaq->findTableData($kindId); $typeKeyValue = array('lang_id' => $lang_id, 'name' => $translateTo, 'copy_from' => array('field' => 'Id'), 'Id' => NULL); $newTypeData = $this->_changeDataVal($typeData, $typeKeyValue); $newTypeData = array_shift($newTypeData); $ExistData = $this->_modelPlayerKindFaq->findCopyKind($newTypeData['copy_from'], $lang_id); if (!$ExistData) { $this->_modelPlayerKindFaq->add($newTypeData); $CopyKindId = $this->_modelPlayerKindFaq->findLastId(); } else { $CopyKindId = $ExistData['Id']; if ($is_syn) { $this->_modelPlayerKindFaq->update($newTypeData, "Id={$CopyKindId}"); //同步 } } $faqKeyValue = array('check_user_id' => null, 'kind_id' => $CopyKindId, 'lang_id' => $lang_id, 'question' => $translateTo, 'answer_g' => $translateTo, 'answer_s' => $translateTo, 'copy_from' => array('field' => 'Id'), 'Id' => null); $faqData = $this->_modelPlayerFaq->findByKindId($kindId); $ExistFaqIds = $this->_modelPlayerFaq->findExistCopyFaqIds($faqData, $lang_id); $ExistFaqForSyn = array(); //用于更新 foreach ($faqData as $key => $faqDatasub) { if (in_array($faqDatasub['Id'], $ExistFaqIds)) { $ExistFaqForSyn[] = $faqData[$key]; unset($faqData[$key]); } } $newFaqData = $this->_changeDataVal($faqData, $faqKeyValue); foreach ($newFaqData as $subNewFaqData) { $this->_modelPlayerFaq->add($subNewFaqData); } if ($is_syn) { $ExistFaqForSyn = $this->_changeDataVal($ExistFaqForSyn, $faqKeyValue); foreach ($ExistFaqForSyn as $sub) { $this->_modelPlayerFaq->update($sub, "copy_from = {$sub['copy_from']} and lang_id = {$lang_id}"); } } //更新复制后FAQ类型的数量 $KindAmount = $this->_modelPlayerFaq->findCount("lang_id={$lang_id} and kind_id={$CopyKindId}"); $this->_modelPlayerKindFaq->update(array('count' => $KindAmount), "Id={$CopyKindId}"); $locationHref = Tools::url(CONTROL, 'PlayerKind', array('lang' => $lang_id)); $this->_utilMsg->showMsg(Tools::getLang('OPERATION_SUCCESS', 'Common'), 1, $locationHref); } $this->_view->assign('lang', $this->_lang); $this->_utilMsg->createNavBar(); $this->_view->display(); }