sns_strace.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <?php
  2. /**
  3. * SNS动态
  4. ***/
  5. defined('InShopNC') or exit('Access Invalid!');
  6. class sns_straceControl extends SystemControl{
  7. public function __construct(){
  8. parent::__construct();
  9. Language::read('snstrace,sns_strace');
  10. }
  11. /**
  12. * 动态列表
  13. */
  14. public function stracelistOp(){
  15. // where条件
  16. $where = array();
  17. if($_GET['search_sname'] != ''){
  18. $where['strace_storename'] = array('like','%'.trim($_GET['search_sname']).'%');
  19. }
  20. if($_GET['search_scontent'] != ''){
  21. $where['search_scontent'] = array('like','%'.trim($_GET['search_scontent']).'%');
  22. }
  23. if($_GET['search_type'] != ''){
  24. $where['strace_type'] = trim($_GET['search_type']);
  25. }
  26. if($_GET['search_stime'] != '' || $_GET['search_etime'] != ''){
  27. $s_time = $_GET['search_stime'] != '' ? strtotime($_GET['search_stime']) : null;
  28. $e_time = $_GET['search_etime'] != '' ? strtotime($_GET['search_etime']) : null;
  29. $where['strace_time'] = array('time',array($s_time, $e_time));
  30. }
  31. // 实例化模型
  32. $model_stracelog = Model('store_sns_tracelog');
  33. $strace_list = Model('store_sns_tracelog')->getStoreSnsTracelogList($where, '*', 'strace_id desc', 0, 10);
  34. if(!empty($strace_list) && is_array($strace_list)){
  35. foreach ($strace_list as $key=>$val){
  36. if($val['strace_content'] == ''){
  37. $data = json_decode($val['strace_goodsdata'],true);
  38. if( CHARSET == 'GBK') {
  39. foreach ((array)$data as $k=>$v){
  40. $data[$k] = Language::getGBK($v);
  41. }
  42. }
  43. $content = $model_stracelog->spellingStyle($val['strace_type'], $data);
  44. $strace_list[$key]['strace_content'] = str_replace("%siteurl%", SHOP_SITE_URL.DS, $content);
  45. }
  46. }
  47. }
  48. Tpl::output('show_page', $model_stracelog->showpage(2));
  49. Tpl::output('strace_list', $strace_list);
  50. Tpl::showpage('sns_strace.index');
  51. }
  52. /**
  53. * 删除动态
  54. */
  55. public function strace_delOp(){
  56. // 验证参数
  57. if(empty($_POST['st_id']) && !is_array($_POST['st_id'])){
  58. showMessage(Language::get('param_error'), '', '', 'error');
  59. }
  60. $st_id = $_POST['st_id'];
  61. // 实例化模型
  62. $model = Model();
  63. // 删除动态
  64. $rs = Model('store_sns_tracelog')->delStoreSnsTracelog(array('strace_id'=>array('in',$st_id)));
  65. if($rs){
  66. // 删除评论
  67. Model('store_sns_comment')->delStoreSnsComment(array('strace_id'=>array('in',$st_id)));
  68. $this->log(L('nc_del,admin_snstrace_comment'),1);
  69. showMessage(Language::get('nc_common_del_succ'));
  70. }else{
  71. showMessage(Language::get('nc_common_del_fail'),'','','error');
  72. }
  73. }
  74. /**
  75. * 编辑动态
  76. */
  77. public function strace_editOp(){
  78. // 验证参数
  79. if(empty($_POST['st_id']) && !is_array($_POST['st_id'])){
  80. showMessage(Language::get('param_error'), '', '', 'error');
  81. }
  82. // where条件
  83. $where = array();
  84. $where['strace_id'] = array('in', $_POST['st_id']);
  85. // update条件
  86. $update = array();
  87. $update['strace_state'] = 1;
  88. if($_GET['type'] == 'hide'){
  89. $update['strace_state'] = 0;
  90. }
  91. // 实例化模型
  92. $rs = Model('store_sns_comment')->editStoreSnsTracelog($update, $where);
  93. if($rs){
  94. $this->log(L('nc_edit,admin_snstrace_comment'),1);
  95. showMessage(Language::get('nc_common_op_succ'));
  96. }else{
  97. showMessage(Language::get('nc_common_op_fail'),'','','error');
  98. }
  99. }
  100. /**
  101. * 评论列表
  102. */
  103. public function scomm_listOp(){
  104. // where 条件
  105. $where = array();
  106. $st_id = intval($_GET['st_id']);
  107. if($st_id > 0){
  108. $where['strace_id'] = $st_id;
  109. }
  110. if($_GET['search_uname'] != ''){
  111. $where['scomm_membername'] = array('like','%'.trim($_GET['search_uname']).'%');
  112. }
  113. if($_GET['search_content'] != ''){
  114. $where['scomm_content'] = array('like','%'.trim($_GET['search_content']).'%');
  115. }
  116. if($_GET['search_state'] != ''){
  117. $where['scomm_state'] = intval($_GET['search_state']);
  118. }
  119. if($_GET['search_stime'] != '' || $_GET['search_etime'] != ''){
  120. $s_time = $_GET['search_stime'] != '' ? strtotime($_GET['search_stime']) : null;
  121. $e_time = $_GET['search_etime'] != '' ? strtotime($_GET['search_etime']) : null;
  122. $where['scomm_time'] = array('time',array($s_time, $e_time));
  123. }
  124. $model_storesnscomment = Model('store_sns_comment');
  125. $scomm_list = $model_storesnscomment->getStoreSnsCommentList($where, '*', 'scomm_id desc', 0, 20);
  126. Tpl::output('show_page', $model_storesnscomment->showpage(2));
  127. Tpl::output('scomm_list', $scomm_list);
  128. Tpl::showpage('sns_scomment.index');
  129. }
  130. /**
  131. * 删除评论
  132. */
  133. public function scomm_delOp(){
  134. if(isset($_GET['sc_id'])){
  135. $sc_id = $_GET['sc_id'];
  136. }
  137. if(isset($_POST['sc_id']) && is_array($_POST['sc_id'])){
  138. $sc_id = $_POST['sc_id'];
  139. }
  140. if(!isset($sc_id)){
  141. showMessage(Language::get('param_error'), '', '', 'error');
  142. }
  143. // 实例化模型
  144. $rs = Model('store_sns_comment')->delStoreSnsComment(array('scomm_id'=>array('in',$sc_id)));
  145. if($rs){
  146. $this->log(L('nc_del,admin_snstrace_pl'),1);
  147. showMessage(Language::get('nc_common_op_succ'));
  148. }else{
  149. showMessage(Language::get('nc_common_del_fail'),'','','error');
  150. }
  151. }
  152. /**
  153. * 评论编辑
  154. */
  155. public function scomm_editOp(){
  156. if(isset($_POST['sc_id']) && is_array($_POST['sc_id'])){
  157. $sc_id = $_POST['sc_id'];
  158. }else{
  159. showMessage(Language::get('param_error'));
  160. }
  161. $scomm_state = 1;
  162. if($_GET['type'] == 'hide'){
  163. $scomm_state = 0;
  164. }
  165. // 实例化模型
  166. $rs = Model('store_sns_comment')->editStoreSnsComment(array('scomm_state'=>$scomm_state), array('scomm_id'=>array('in',$sc_id)));
  167. if($rs){
  168. $this->log(L('nc_edit,admin_snstrace_pl'),1);
  169. showMessage(Language::get('nc_common_op_succ'));
  170. }else{
  171. showMessage(Language::get('nc_common_del_fail'),'','','error');
  172. }
  173. }
  174. }
  175. ?>