snstrace.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <?php
  2. /**
  3. * SNS动态
  4. ***/
  5. defined('InShopNC') or exit('Access Invalid!');
  6. class snstraceControl extends SystemControl{
  7. public function __construct(){
  8. parent::__construct();
  9. Language::read('snstrace');
  10. }
  11. /**
  12. * 动态列表
  13. */
  14. public function tracelistOp(){
  15. $tracelog_model = Model('sns_tracelog');
  16. $condition = array();
  17. //会员名
  18. if($_GET['search_uname'] !=''){
  19. $condition['trace_membernamelike'] = trim($_GET['search_uname']);
  20. }
  21. //内容
  22. if($_GET['search_content'] !=''){
  23. $condition['trace_contentortitle'] = trim($_GET['search_content']);
  24. }
  25. //状态
  26. if($_GET['search_state'] != ''){
  27. $condition['trace_state'] = "{$_GET['search_state']}";
  28. }
  29. //发表时间
  30. if($_GET['search_stime'] !=''){
  31. $condition['stime'] = strtotime($_GET['search_stime']);
  32. }
  33. if($_GET['search_etime'] !=''){
  34. $condition['etime'] = strtotime($_GET['search_etime']);
  35. }
  36. //分页
  37. $page = new Page();
  38. $page->setEachNum(10);
  39. $page->setStyle('admin');
  40. $tracelist = $tracelog_model->getTracelogList($condition,$page);
  41. if (!empty($tracelist)){
  42. foreach ($tracelist as $k=>$v){
  43. if(!empty($v['trace_title'])){
  44. //替换标题中的siteurl
  45. $v['trace_title'] = str_replace("%siteurl%", SHOP_SITE_URL.DS, $v['trace_title']);
  46. }
  47. if(!empty($v['trace_content'])){
  48. //替换内容中的siteurl
  49. $v['trace_content'] = str_replace("%siteurl%", SHOP_SITE_URL.DS, $v['trace_content']);
  50. //将收藏商品和店铺连接剔除
  51. $v['trace_content'] = str_replace(Language::get('admin_snstrace_collectgoods'), "", $v['trace_content']);
  52. $v['trace_content'] = str_replace(Language::get('admin_snstrace_collectstore'), "", $v['trace_content']);
  53. }
  54. $tracelist[$k] = $v;
  55. }
  56. }
  57. Tpl::output('tracelist',$tracelist);
  58. Tpl::output('show_page',$page->show());
  59. Tpl::showpage('snstrace.index');
  60. }
  61. /**
  62. * 删除动态
  63. */
  64. public function tracedelOp(){
  65. $tid = $_POST['t_id'];
  66. if(empty($tid)){
  67. showMessage(Language::get('admin_snstrace_pleasechoose_del'),'index.php?act=snstrace&op=tracelist','','error');
  68. }
  69. $tid_str = implode("','",$tid);
  70. //删除动态
  71. $tracelog_model = Model('sns_tracelog');
  72. $result = $tracelog_model->delTracelog(array('trace_id_in'=>$tid_str));
  73. if($result){
  74. //判断是否完全删除
  75. $tracelog_list = $tracelog_model->getTracelogList(array('traceid_in'=>"$tid_str"));
  76. if(!empty($tracelog_list)){
  77. foreach($tracelog_list as $k=>$v){
  78. unset($tid[array_search($v['trace_id'],$tid)]);
  79. }
  80. }
  81. $tid_str = implode("','",$tid);
  82. //删除动态下的评论
  83. $comment_model = Model('sns_comment');
  84. $condition = array();
  85. $condition['comment_originalid_in'] = $tid_str;
  86. $condition['comment_originaltype'] = "0";
  87. $comment_model->delComment($condition);
  88. //更新转帖的原帖删除状态为已经删除
  89. $tracelog_model->tracelogEdit(array('trace_originalstate'=>'1'),array('trace_originalid_in'=>"$tid_str"));
  90. $this->log(L('nc_del,admin_snstrace_comment'),1);
  91. showMessage(Language::get('nc_common_del_succ'),'index.php?act=snstrace&op=tracelist','','succ');
  92. }else{
  93. showMessage(Language::get('nc_common_del_fail'),'index.php?act=snstrace&op=tracelist','','error');
  94. }
  95. }
  96. /**
  97. * 编辑动态
  98. */
  99. public function traceeditOp(){
  100. $tid = $_POST['t_id'];
  101. if(empty($tid)){
  102. showMessage(Language::get('admin_snstrace_pleasechoose_edit'),'index.php?act=snstrace&op=tracelist','','error');
  103. }
  104. $tid_str = implode("','",$tid);
  105. $type = $_GET['type'];
  106. //删除动态
  107. $tracelog_model = Model('sns_tracelog');
  108. $update_arr = array();
  109. if($type == 'hide'){
  110. $update_arr['trace_state'] = '1';
  111. }else{
  112. $update_arr['trace_state'] = '0';
  113. }
  114. $result = $tracelog_model->tracelogEdit($update_arr,array('traceid_in'=>"$tid_str"));
  115. unset($update_arr);
  116. if($result){
  117. //判断是否完全修改成功
  118. $condition = array();
  119. $condition['traceid_in'] = "$tid_str";
  120. if($type == 'hide'){
  121. $condition['trace_state'] = '1';
  122. }else{
  123. $condition['trace_state'] = '0';
  124. }
  125. $tracelog_list = $tracelog_model->getTracelogList($condition);
  126. unset($condition);
  127. $tid_new = array();
  128. if(!empty($tracelog_list)){
  129. foreach($tracelog_list as $k=>$v){
  130. $tid_new[] = $v['trace_id'];
  131. }
  132. }
  133. $tid_str = implode("','",$tid_new);
  134. //更新转帖的原帖删除状态为已经删除或者为显示
  135. $update_arr = array();
  136. if($type == 'hide'){
  137. $update_arr['trace_originalstate'] = '1';
  138. }else{
  139. $update_arr['trace_originalstate'] = '0';
  140. }
  141. $tracelog_model->tracelogEdit($update_arr,array('trace_originalid_in'=>"$tid_str"));
  142. $this->log(L('nc_edit,admin_snstrace_comment'),1);
  143. showMessage(Language::get('nc_common_op_succ'),'index.php?act=snstrace&op=tracelist','','succ');
  144. }else{
  145. showMessage(Language::get('nc_common_op_fail'),'index.php?act=snstrace&op=tracelist','','error');
  146. }
  147. }
  148. /**
  149. * 评论列表
  150. */
  151. public function commentlistOp(){
  152. $comment_model = Model('sns_comment');
  153. //查询评论总数
  154. $condition = array();
  155. //会员名
  156. if($_GET['search_uname'] !=''){
  157. $condition['comment_membername_like'] = trim($_GET['search_uname']);
  158. }
  159. //内容
  160. if($_GET['search_content'] !=''){
  161. $condition['comment_content_like'] = trim($_GET['search_content']);
  162. }
  163. //状态
  164. if($_GET['search_state'] != ''){
  165. $condition['comment_state'] = "{$_GET['search_state']}";
  166. }
  167. //发表时间
  168. if($_GET['search_stime'] !=''){
  169. $condition['stime'] = strtotime($_GET['search_stime']);
  170. }
  171. if($_GET['search_etime'] !=''){
  172. $condition['etime'] = strtotime($_GET['search_etime']);
  173. }
  174. if($_GET['tid'] !=''){
  175. $condition['comment_originalid'] = "{$_GET['tid']}";
  176. $condition['comment_originaltype'] = "0";//原帖类型 0表示动态信息 1表示分享商品
  177. }
  178. //评价列表
  179. $page = new Page();
  180. $page->setEachNum(20);
  181. $page->setStyle('admin');
  182. $commentlist = $comment_model->getCommentList($condition,$page);
  183. Tpl::output('commentlist',$commentlist);
  184. Tpl::output('show_page',$page->show());
  185. Tpl::showpage('snscomment.index');
  186. }
  187. /**
  188. * 删除评论
  189. */
  190. public function commentdelOp(){
  191. $cid = $_POST['c_id'];
  192. if(empty($cid)){
  193. showMessage(Language::get('admin_snstrace_pleasechoose_del'),'index.php?act=snstrace&op=commentlist','','error');
  194. }
  195. $cid_str = implode("','",$cid);
  196. //删除评论
  197. $comment_model = Model('sns_comment');
  198. $result = $comment_model->delComment(array('comment_id_in'=>"$cid_str"));
  199. if($result){
  200. $this->log(L('nc_del,admin_snstrace_pl'),1);
  201. showMessage(Language::get('nc_common_del_succ'),'index.php?act=snstrace&op=commentlist','','succ');
  202. }else{
  203. showMessage(Language::get('nc_common_del_fail'),'index.php?act=snstrace&op=commentlist','','error');
  204. }
  205. }
  206. /**
  207. * 编辑评论
  208. */
  209. public function commenteditOp(){
  210. $cid = $_POST['c_id'];
  211. if(empty($cid)){
  212. showMessage(Language::get('admin_snstrace_pleasechoose_edit'),'index.php?act=snstrace&op=commentlist','','error');
  213. }
  214. $cid_str = implode("','",$cid);
  215. $type = $_GET['type'];
  216. //删除动态
  217. $comment_model = Model('sns_comment');
  218. $update_arr = array();
  219. if($type == 'hide'){
  220. $update_arr['comment_state'] = '1';
  221. }else{
  222. $update_arr['comment_state'] = '0';
  223. }
  224. $result = $comment_model->commentEdit($update_arr,array('comment_id_in'=>"$cid_str"));
  225. unset($update_arr);
  226. if($result){
  227. $this->log(L('nc_edit,admin_snstrace_pl'),1);
  228. showMessage(Language::get('nc_common_op_succ'),'index.php?act=snstrace&op=commentlist','','succ');
  229. }else{
  230. showMessage(Language::get('nc_common_op_fail'),'index.php?act=snstrace&op=commentlist','','error');
  231. }
  232. }
  233. }
  234. ?>