inform.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. <?php
  2. /**
  3. * 举报管理
  4. *
  5. *
  6. *
  7. ***/
  8. defined('InShopNC') or exit('Access Invalid!');
  9. class informControl extends SystemControl{
  10. public function __construct(){
  11. parent::__construct();
  12. Language::read('inform');
  13. }
  14. /*
  15. * 默认操作列出未处理的举报
  16. */
  17. public function indexOp(){
  18. $this->inform_listOp();
  19. }
  20. /*
  21. * 未处理的举报列表
  22. */
  23. public function inform_listOp(){
  24. $this->get_inform_list(1,'inform.list','inform_list');
  25. }
  26. /*
  27. * 已处理的举报列表
  28. */
  29. public function inform_handled_listOp(){
  30. $this->get_inform_list(2,'inform_handled.list','inform_handled_list');
  31. }
  32. /*
  33. * 获取举报列表
  34. */
  35. private function get_inform_list($type,$template,$op){
  36. //实例化分页
  37. $page = new Page();
  38. $page->setEachNum(10) ;
  39. $page->setStyle('admin') ;
  40. //获得举报列表
  41. $model_inform = Model('inform') ;
  42. //搜索条件
  43. $condition = array();
  44. $condition['inform_goods_name'] = trim($_GET['input_inform_goods_name']);
  45. $condition['inform_member_name'] = trim($_GET['input_inform_member_name']);
  46. $condition['inform_type'] = trim($_GET['input_inform_type']);
  47. $condition['inform_subject'] = trim($_GET['input_inform_subject']);
  48. $condition['inform_datetime_start'] = strtotime($_GET['input_inform_datetime_start']);
  49. $condition['inform_datetime_end'] = strtotime($_GET['input_inform_datetime_end']);
  50. if($type === 1) {
  51. $condition['order'] = 'inform_id asc';
  52. }
  53. else {
  54. $condition['order'] = 'inform_id desc';
  55. }
  56. $condition['inform_state'] = $type;
  57. $inform_list = $model_inform->getInform($condition,$page) ;
  58. $this->show_menu($op);
  59. Tpl::output('list', $inform_list) ;
  60. Tpl::output('show_page',$page->show()) ;
  61. Tpl::showpage($template) ;
  62. }
  63. /*
  64. * 举报类型列表
  65. */
  66. public function inform_subject_type_listOp() {
  67. //实例化分页
  68. $page = new Page();
  69. $page->setEachNum(10) ;
  70. $page->setStyle('admin') ;
  71. //获得有效举报类型列表
  72. $model_inform_subject_type = Model('inform_subject_type') ;
  73. $inform_type_list = $model_inform_subject_type->getActiveInformSubjectType($page) ;
  74. $this->show_menu('inform_subject_type_list');
  75. Tpl::output('list', $inform_type_list) ;
  76. Tpl::output('show_page',$page->show()) ;
  77. Tpl::showpage('inform_subject_type.list') ;
  78. }
  79. /*
  80. * 举报主题列表
  81. */
  82. public function inform_subject_listOp(){
  83. //实例化分页
  84. $page = new Page();
  85. $page->setEachNum(10) ;
  86. $page->setStyle('admin') ;
  87. //获得举报主题列表
  88. $model_inform_subject = Model('inform_subject') ;
  89. //搜索条件
  90. $condition = array();
  91. $condition['order'] = 'inform_subject_id asc';
  92. $condition['inform_subject_type_id'] = trim($_GET['inform_subject_type_id']);
  93. $condition['inform_subject_state'] = 1;
  94. $inform_subject_list = $model_inform_subject->getInformSubject($condition,$page) ;
  95. //获取有效举报类型
  96. $model_inform_subject_type = Model('inform_subject_type');
  97. $type_list= $model_inform_subject_type->getActiveInformSubjectType();
  98. $this->show_menu('inform_subject_list');
  99. Tpl::output('list', $inform_subject_list) ;
  100. Tpl::output('type_list', $type_list) ;
  101. Tpl::output('show_page',$page->show()) ;
  102. Tpl::showpage('inform_subject.list') ;
  103. }
  104. /*
  105. * 添加举报类型页面
  106. */
  107. public function inform_subject_type_addOp(){
  108. $this->show_menu('inform_subject_type_add');
  109. Tpl::showpage('inform_subject_type.add') ;
  110. }
  111. /*
  112. * 保存添加的举报类型
  113. */
  114. public function inform_subject_type_saveOp(){
  115. //获取提交的内容
  116. $input['inform_type_name'] = trim($_POST['inform_type_name']);
  117. $input['inform_type_desc'] = trim($_POST['inform_type_desc']);
  118. //验证提交的内容
  119. $obj_validate = new Validator();
  120. $obj_validate->validateparam = array(
  121. array("input"=>$input['inform_type_name'], "require"=>"true","validator"=>"Length","min"=>"1","max"=>"50","message"=>Language::get('inform_type_null')),
  122. array("input"=>$input['inform_type_desc'], "require"=>"true","validator"=>"Length","min"=>"1","max"=>"100","message"=>Language::get('inform_type_desc_null')),
  123. );
  124. $error = $obj_validate->validate();
  125. if ($error != ''){
  126. showMessage($error);
  127. }
  128. else {
  129. //验证成功保存
  130. $input['inform_type_state'] = 1;
  131. $model_inform_subject_type = Model('inform_subject_type');
  132. $model_inform_subject_type->saveInformSubjectType($input);
  133. $this->log(L('nc_add,inform_type').'['.$_POST['inform_type_name'].']',1);
  134. showMessage(Language::get('nc_common_save_succ'),'index.php?act=inform&op=inform_subject_type_list');
  135. }
  136. }
  137. /*
  138. * 删除举报类型,伪删除只是修改标记
  139. */
  140. public function inform_subject_type_dropOp(){
  141. $inform_type_id = trim($_POST['inform_type_id']);
  142. $inform_type_id = "'".implode("','", explode(',', $inform_type_id))."'";
  143. if(empty($inform_type_id)) {
  144. showMessage(Language::get('param_error'),'index.php?act=inform');
  145. }
  146. //删除分类
  147. $model_inform_subject_type = Model('inform_subject_type');
  148. $update_array = array();
  149. $update_array['inform_type_state'] = 2;
  150. $where_array = array();
  151. $where_array['in_inform_type_id'] = $inform_type_id;
  152. $model_inform_subject_type->updateInformSubjectType($update_array,$where_array);
  153. //删除分类下边的主题
  154. $model_inform_subject= Model('inform_subject');
  155. $update_subject_array = array();
  156. $update_subject_array['inform_subject_state'] = 2;
  157. $where_subject_array = array();
  158. $where_subject_array['in_inform_subject_type_id'] = $inform_type_id;
  159. $model_inform_subject->updateInformSubject($update_subject_array,$where_subject_array);
  160. $this->log(L('nc_del,inform_type').'[ID:'.$_POST['inform_type_id'].']',1);
  161. showMessage(Language::get('nc_common_del_succ'),'index.php?act=inform&op=inform_subject_type_list');
  162. }
  163. /*
  164. * 添加举报主题页面
  165. */
  166. public function inform_subject_addOp(){
  167. //获得可用举报类型列表
  168. $model_inform_subject_type = Model('inform_subject_type');
  169. $inform_type_list = $model_inform_subject_type->getActiveInformSubjectType();
  170. if(empty($inform_type_list)) {
  171. showMessage(Language::get('inform_type_error'));
  172. }
  173. $this->show_menu('inform_subject_add');
  174. Tpl::output('list', $inform_type_list) ;
  175. Tpl::showpage('inform_subject.add') ;
  176. }
  177. /*
  178. * 保存添加的举报主题
  179. */
  180. public function inform_subject_saveOp(){
  181. //获取提交的内容
  182. list($input['inform_subject_type_id'],$input['inform_subject_type_name']) = explode(',',trim($_POST['inform_subject_type']));
  183. $input['inform_subject_content'] = trim($_POST['inform_subject_content']);
  184. //验证提交的内容
  185. $obj_validate = new Validator();
  186. $obj_validate->validateparam = array(
  187. array("input"=>$input['inform_subject_type_name'], "require"=>"true","validator"=>"Length","min"=>"1","max"=>"50","message"=>Language::get('inform_subject_null')),
  188. array("input"=>$input['inform_subject_content'], "require"=>"true","validator"=>"Length","min"=>"1","max"=>"50","message"=>Language::get('inform_content_null')),
  189. array("input"=>$input['inform_subject_type_id'], "require"=>"true","validator"=>"Number","message"=>Language::get('param_error')),
  190. );
  191. $error = $obj_validate->validate();
  192. if ($error != ''){
  193. showMessage($error);
  194. }
  195. else {
  196. //验证成功保存
  197. $input['inform_subject_state'] = 1;
  198. $model_inform_subject = Model('inform_subject');
  199. $model_inform_subject->saveInformSubject($input);
  200. $this->log(L('nc_add,inform_subject').'['.$input['inform_subject_type_name'].']',1);
  201. showMessage(Language::get('nc_common_save_succ'),'index.php?act=inform&op=inform_subject_list');
  202. }
  203. }
  204. /*
  205. * 删除举报主题,伪删除只是修改标记
  206. */
  207. public function inform_subject_dropOp(){
  208. $inform_subject_id = trim($_POST['inform_subject_id']);
  209. if(empty($inform_subject_id)) {
  210. showMessage(Language::get('param_error'),'index.php?act=inform');
  211. }
  212. $model_inform_subject= Model('inform_subject');
  213. $update_array = array();
  214. $update_array['inform_subject_state'] = 2;
  215. $where_array = array();
  216. $where_array['in_inform_subject_id'] = "'".implode("','", explode(',', $inform_subject_id))."'";
  217. $model_inform_subject->updateInformSubject($update_array,$where_array);
  218. $this->log(L('nc_del,inform_subject').'['.$_POST['inform_subject_id'].']',1);
  219. showMessage(Language::get('nc_common_del_succ'),'index.php?act=inform&op=inform_subject_list');
  220. }
  221. /*
  222. * 显示处理举报
  223. */
  224. public function show_handle_pageOp() {
  225. $this->show_menu('inform_list');
  226. $inform_id = intval($_GET['inform_id']);
  227. $inform_goods_name = urldecode($_GET['inform_goods_name']);
  228. if(strtoupper(CHARSET) == 'GBK') {
  229. $inform_goods_name = Language::getGBK($inform_goods_name);
  230. }
  231. TPL::output('inform_id',$inform_id);
  232. TPL::output('inform_goods_name',$inform_goods_name);
  233. Tpl::showpage('inform.handle');
  234. }
  235. /*
  236. * 处理举报
  237. */
  238. public function inform_handleOp(){
  239. $inform_id = intval($_POST['inform_id']);
  240. $inform_handle_type = intval($_POST['inform_handle_type']);
  241. $inform_handle_message = trim($_POST['inform_handle_message']);
  242. if(empty($inform_id)||empty($inform_handle_type)) {
  243. showMessage(Language::get('param_error'),'');
  244. }
  245. //验证输入的数据
  246. $obj_validate = new Validator();
  247. $obj_validate->validateparam = array(
  248. array("input"=>$inform_handle_message, "require"=>"true","validator"=>"Length","min"=>"1","max"=>"100","message"=>Language::get('inform_handle_message_null')),
  249. );
  250. $error = $obj_validate->validate();
  251. if ($error != ''){
  252. showMessage($error);
  253. }
  254. $model_inform = Model('inform');
  255. $inform_info = $model_inform->getoneInform($inform_id);
  256. if(empty($inform_info)||intval($inform_info['inform_state'])===2) {
  257. showMessage(Language::get('param_error'));
  258. }
  259. $update_array = array();
  260. $where_array = array();
  261. //根据选择处理
  262. switch($inform_handle_type) {
  263. case 1:
  264. $where_array['inform_id'] = $inform_id;
  265. break;
  266. case 2:
  267. //恶意举报,清理所有该用户的举报,设置该用户禁止举报
  268. $where_array['inform_member_id'] = $inform_info['inform_member_id'];
  269. $this->denyMemberInform($inform_info['inform_member_id']);
  270. break;
  271. case 3:
  272. //有效举报,商品禁售
  273. $where_array['inform_id'] = $inform_id;
  274. $this->denyGoods($inform_info['inform_goods_id']);
  275. break;
  276. default:
  277. showMessage(Language::get('param_error'));
  278. }
  279. $update_array['inform_state'] = 2;
  280. $update_array['inform_handle_type'] = $inform_handle_type;
  281. $update_array['inform_handle_message'] = $inform_handle_message;
  282. $update_array['inform_handle_datetime'] = time();
  283. $admin_info = $this->getAdminInfo();
  284. $update_array['inform_handle_member_id'] = $admin_info['id'];
  285. $where_array['inform_state'] = 1;
  286. if($model_inform->updateInform($update_array,$where_array)) {
  287. $this->log(L('inform_text_handle,inform').'[ID:'.$inform_id.']',1);
  288. showMessage(Language::get('nc_common_op_succ'),'index.php?act=inform&op=inform_list');
  289. }
  290. else {
  291. showMessage(Language::get('nc_common_op_fail'));
  292. }
  293. }
  294. /*
  295. * 禁止该用户举报
  296. */
  297. private function denyMemberInform($member_id) {
  298. $model_member = Model('member');
  299. $param = array();
  300. $param['inform_allow'] = 2;
  301. return $model_member->editMember(array('member_id'=>$member_id),$param);
  302. }
  303. /*
  304. * 禁止商品销售
  305. */
  306. private function denyGoods($goods_id) {
  307. //修改商品状态
  308. $model_goods = Model('goods');
  309. $goods_info = $model_goods->getGoodsInfoByID($goods_id, 'goods_commonid');
  310. if (empty($goods_info)) {
  311. return true;
  312. }
  313. return Model('goods')->editProducesLockUp(array('goods_stateremark' => '商品被举报,平台禁售'),array('goods_commonid' => $goods_info['goods_commonid']));
  314. }
  315. /**
  316. * 用户中心右边,小导航
  317. *
  318. * @param string $menu_type 导航类型
  319. * @param string $menu_key 当前导航的menu_key
  320. * @param array $array 附加菜单
  321. * @return
  322. */
  323. private function show_menu($menu_key) {
  324. $menu_array = array(
  325. 'inform_list'=>array('menu_type'=>'link','menu_name'=>Language::get('inform_state_unhandle'),'menu_url'=>'index.php?act=inform&op=inform_list'),
  326. 'inform_handled_list'=>array('menu_type'=>'link','menu_name'=>Language::get('inform_state_handled'),'menu_url'=>'index.php?act=inform&op=inform_handled_list'),
  327. 'inform_subject_type_list'=>array('menu_type'=>'link','menu_name'=>Language::get('inform_type'),'menu_url'=>'index.php?act=inform&op=inform_subject_type_list'),
  328. 'inform_subject_type_add'=>array('menu_type'=>'link','menu_name'=>Language::get('inform_type_add'),'menu_url'=>'index.php?act=inform&op=inform_subject_type_add'),
  329. 'inform_subject_list'=>array('menu_type'=>'link','menu_name'=>Language::get('inform_subject'),'menu_url'=>'index.php?act=inform&op=inform_subject_list'),
  330. 'inform_subject_add'=>array('menu_type'=>'link','menu_name'=>Language::get('inform_subject_add'),'menu_url'=>'index.php?act=inform&op=inform_subject_add'),
  331. );
  332. $menu_array[$menu_key]['menu_type'] = 'text';
  333. Tpl::output('menu',$menu_array);
  334. }
  335. }