circle_inform.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. /**
  3. * Circle Inform
  4. *
  5. *
  6. *
  7. ***/
  8. defined('InShopNC') or exit('Access Invalid!');
  9. class circle_informControl extends SystemControl{
  10. public function __construct(){
  11. parent::__construct();
  12. Language::read('circle_inform');
  13. }
  14. /**
  15. * inform list
  16. */
  17. public function inform_listOp(){
  18. $model = Model();
  19. if(chksubmit()){
  20. if(empty($_POST['i_id'])){
  21. showMessage(L('wrong_argument'), '', '', 'error');
  22. }
  23. // check
  24. foreach ($_POST['i_id'] as $key=>$val){
  25. if (!is_numeric($val)) unset($_POST[$key]);
  26. }
  27. $rs = $model->table('circle_inform')->where(array('inform_id'=>array('in', $_POST['i_id'])))->delete();
  28. if($rs){
  29. showMessage(L('nc_common_op_succ'));
  30. }else{
  31. showMessage(L('nc_common_op_fail'), '', '', 'error');
  32. }
  33. }
  34. $where = array();
  35. if($_GET['searchname'] != ''){
  36. $where['member_name'] = array('like', '%'.$_GET['searchname'].'%');
  37. }
  38. if($_GET['circlename'] != ''){
  39. $where['circle_name'] = array('like', '%'.$_GET['circlename'].'%');
  40. }
  41. if($_GET['searchstate'] != ''){
  42. $where['inform_state'] = intval($_GET['searchstate']);
  43. }
  44. $inform_list = $model->table('circle_inform')->where($where)->page(10)->order('inform_id desc')->select();
  45. // tidy
  46. if(!empty($inform_list)){
  47. foreach ($inform_list as $key=>$val){
  48. $inform_list[$key]['url'] = $this->spellInformUrl($val);
  49. $inform_list[$key]['title'] = L('circle_theme,nc_quote1').$val['theme_name'].L('nc_quote2');
  50. $inform_list[$key]['state'] = $this->informStatr(intval($val['inform_state']));
  51. if($val['reply_id'] != 0)
  52. $inform_list[$key]['title'] .= L('circle_inform_reply_title');
  53. }
  54. }
  55. Tpl::output('inform_list', $inform_list);
  56. Tpl::output('show_page', $model->showpage(2));
  57. Tpl::showpage('circle_inform');
  58. }
  59. /**
  60. * Inform delete
  61. */
  62. public function inform_delOp(){
  63. $i_id = intval($_GET['i_id']);
  64. if($i_id <= 0){
  65. showMessage(L('wrong_argument'), '', '', 'error');
  66. }
  67. $rs = Model()->table('circle_inform')->delete($i_id);
  68. if($rs){
  69. showMessage(L('nc_common_op_succ'));
  70. }else{
  71. showMessage(L('nc_common_op_fail'), '', '', 'error');
  72. }
  73. }
  74. /**
  75. * Inform Url link
  76. */
  77. public function spellInformUrl($param){
  78. if($param['reply_id'] == 0) return $url = 'index.php?act=theme&op=theme_detail&c_id='.$param['circle_id'].'&t_id='.$param['theme_id'];
  79. $where = array();
  80. $where['circle_id'] = $param['circle_id'];
  81. $where['theme_id'] = $param['theme_id'];
  82. $where['reply_id'] = array('elt', $param['reply_id']);
  83. $count = Model()->table('circle_threply')->where($where)->count();
  84. $page = ceil($count/15);
  85. return $url = 'index.php?act=theme&op=theme_detail&c_id='.$param['circle_id'].'&t_id='.$param['theme_id'].'&curpage='.$page.'#f'.$param['reply_id'];
  86. }
  87. /**
  88. * Inform state
  89. */
  90. private function informStatr($state){
  91. switch ($state){
  92. case 0:
  93. return L('circle_inform_untreated');
  94. break;
  95. case 1:
  96. return L('circle_inform_treated');
  97. break;
  98. }
  99. }
  100. }