人人商城

message.ctrl.php 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. load()->model('material');
  8. $dos = array('message_list', 'message_info', 'message_reply', 'message_mark', 'message_del', 'message_reply_del', 'message_switch');
  9. $do = in_array($do , $dos) ? $do : 'message_list';
  10. if ($do == 'message_list') {
  11. $_W['page']['title'] = '留言管理-文章列表';
  12. $pindex = max(1, intval($_GPC['page']));
  13. $psize = 20;
  14. $condition = array('uniacid' => $_W['uniacid'], 'acid' => $_W['acid'], 'status' => 0);
  15. $lists = pdo_getall('mc_mass_record', $condition, array(), '', 'id DESC', 'LIMIT ' . ($pindex-1) * $psize . ',' . $psize);
  16. $pager = pagination($total, $pindex, $psize);
  17. $news_arr = array();
  18. if (is_array($lists) && !empty($lists)) {
  19. foreach ($lists as $key => &$record) {
  20. $material = material_get($record['attach_id']);
  21. if (is_array($material['news']) && !empty($material['news'])) {
  22. foreach ($material['news'] as $news_key => &$news) {
  23. $news['msg_id'] = $record['msg_id'];
  24. $news['msg_data_id'] = $record['msg_data_id'];
  25. $news['index'] = $news_key;
  26. $news_arr[] = $news;
  27. }
  28. } else {
  29. unset($lists[$key]);
  30. }
  31. }
  32. }
  33. template('mc/message_list');
  34. }
  35. if ($do == 'message_info') {
  36. $_W['page']['title'] = '留言管理-留言信息';
  37. $index = empty(intval($_GPC['index'])) ? 0 : intval($_GPC['index']);
  38. $msg_data_id = safe_gpc_string($_GPC['msg_data_id']);
  39. $type = empty(intval($_GPC['type'])) ? 0 : intval($_GPC['type']);
  40. $account_api = WeAccount::createByUniacid();
  41. $res = $account_api->getComment($msg_data_id, $index, $type);
  42. $comments = $res['comment'];
  43. $total = $res['total'];
  44. if(is_array($comments) && !empty($comments)) {
  45. foreach ($comments as $key => &$comment) {
  46. $comment['index'] = $index;
  47. $comment['msg_data_id'] = $msg_data_id;
  48. $comment['create_time'] = date('Y-m-d H:i:s', $comment['create_time']);
  49. $fans_info = pdo_get('mc_mapping_fans', array('openid' => $comment['openid']));
  50. if (is_base64($fans_info['tag'])) {
  51. $fans_info['tag'] = base64_decode($fans_info['tag']);
  52. }
  53. if (!empty($fans_info['tag']) && is_string($fans_info['tag'])) {
  54. if (is_base64($fans_info['tag'])) {
  55. $fans_info['tag'] = base64_decode($fans_info['tag']);
  56. }
  57. if (is_serialized($fans_info['tag'])) {
  58. $fans_info['tag'] = @iunserializer($fans_info['tag']);
  59. }
  60. if (!empty($fans_info['tag']['headimgurl'])) {
  61. $fans_info['avatar'] = tomedia($fans_info['tag']['headimgurl']);
  62. }
  63. if (empty($fans_info['nickname']) && !empty($fans_info['tag']['nickname'])) {
  64. $fans_info['nickname'] = strip_emoji($fans_info['tag']['nickname']);
  65. }
  66. }
  67. $comment['fans_info'] = $fans_info;
  68. }
  69. }
  70. template('mc/message_info');
  71. }
  72. if ($do == 'message_reply') {
  73. $msg_data_id = safe_gpc_string($_GPC['msg_data_id']);
  74. $index = intval($_GPC['index']);
  75. $user_comment_id = intval($_GPC['user_comment_id']);
  76. $content = safe_gpc_string($_GPC['replycontent']);
  77. $account_api = WeAccount::createByUniacid();
  78. $res = $account_api->commentReply($msg_data_id, $user_comment_id, $content, $index);
  79. if (is_error($res)) {
  80. iajax($res['errno'], $res['message']);
  81. } else {
  82. iajax(0, '回复成功!');
  83. }
  84. }
  85. if ($do == 'message_mark') {
  86. $msg_data_id = safe_gpc_string($_GPC['msg_data_id']);
  87. $index = intval($_GPC['index']);
  88. $user_comment_id = intval($_GPC['user_comment_id']);
  89. $comment_type = intval($_GPC['comment_type']);
  90. $account_api = WeAccount::createByUniacid();
  91. $res = $account_api->commentMark($msg_data_id, $user_comment_id, $comment_type, $index);
  92. if (is_error($res)) {
  93. iajax($res['errno'], $res['message']);
  94. } else {
  95. if ($comment_type == 1) {
  96. $message = '取消精选成功!';
  97. } else {
  98. $message = '精选成功!';
  99. }
  100. iajax(0, $message);
  101. }
  102. }
  103. if ($do == 'message_del') {
  104. $msg_data_id = safe_gpc_string($_GPC['msg_data_id']);
  105. $index = intval($_GPC['index']);
  106. $user_comment_id = intval($_GPC['user_comment_id']);
  107. $account_api = WeAccount::createByUniacid();
  108. $res = $account_api->commentDelete($msg_data_id, $user_comment_id, $index);
  109. if (is_error($res)) {
  110. iajax($res['errno'], $res['message']);
  111. } else {
  112. iajax(0, '删除成功!');
  113. }
  114. }
  115. if ($do == 'message_reply_del') {
  116. $msg_data_id = safe_gpc_string($_GPC['msg_data_id']);
  117. $index = intval($_GPC['index']);
  118. $user_comment_id = intval($_GPC['user_comment_id']);
  119. $account_api = WeAccount::createByUniacid();
  120. $res = $account_api->commentReplyDelete($msg_data_id, $user_comment_id, $index);
  121. if (is_error($res)) {
  122. iajax($res['errno'], $res['message']);
  123. } else {
  124. iajax(0, '删除成功!');
  125. }
  126. }
  127. if ($do == 'message_switch') {
  128. $msg_data_id = safe_gpc_string($_GPC['msg_data_id']);
  129. $index = intval($_GPC['index']);
  130. $need_open_comment = intval($_GPC['need_open_comment']);
  131. $attach_id = intval($_GPC['attach_id']);
  132. $title = safe_gpc_string($_GPC['title']);
  133. $account_api = WeAccount::createByUniacid();
  134. $res = $account_api->commentSwitch($msg_data_id, $need_open_comment, $index);
  135. if (is_error($res)) {
  136. iajax($res['errno'], $res['message']);
  137. } else {
  138. $update_message = ",修改数据失败! 文章attach_id : {$attach_id} , 文章标题: {$title}";
  139. if ($need_open_comment == 1) {
  140. $message = '关闭评论';
  141. $res = pdo_update('wechat_news', array('need_open_comment' => 0), array('attach_id' => $attach_id, 'title' => $title));
  142. if(!$res) {
  143. iajax(-1, $message . $update_message);
  144. }
  145. } else {
  146. $message = '打开评论';
  147. $res = pdo_update('wechat_news', array('need_open_comment' => 1), array('attach_id' => $attach_id, 'title' => $title));
  148. if(!$res) {
  149. iajax(-1, $message . $update_message);
  150. }
  151. }
  152. iajax(0, $message . '成功!');
  153. }
  154. }