manage_inform.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. /**
  3. * 圈子首页
  4. *
  5. *
  6. *********************************/
  7. defined('InShopNC') or exit('Access Invalid!');
  8. class manage_informControl extends BaseCircleManageControl{
  9. public function __construct(){
  10. parent::__construct();
  11. Language::read('manage_inform');
  12. $this->circleSEO();
  13. }
  14. /**
  15. * Inform
  16. */
  17. public function informOp(){
  18. // Circle information
  19. $this->circleInfo();
  20. // Membership information
  21. $this->circleMemberInfo();
  22. // Members to join the circle list
  23. $this->memberJoinCircle();
  24. $model = Model();
  25. if (chksubmit()){
  26. if(empty($_POST['i_id']))
  27. showDialog(L('wrong_argument'));
  28. foreach ($_POST['i_id'] as $val){
  29. $i_rewards = intval($_POST['i_rewards'][$val]);
  30. $update = array();
  31. $update['inform_id'] = $val;
  32. $update['inform_state'] = 1;
  33. $update['inform_opid'] = $_SESSION['member_id'];
  34. $update['inform_opname']= $_SESSION['member_name'];
  35. $update['inform_opexp'] = $i_rewards;
  36. $update['inform_opresult'] = $_POST['i_result'][$val] == ''? L('nc_nothing') : $_POST['i_result'][$val];
  37. $rs = $model->table('circle_inform')->update($update);
  38. // Experience increase or decrease
  39. if($rs && $i_rewards != 0){
  40. $inform_info = $model->table('circle_inform')->field('circle_id,member_id,member_name')->find($val);
  41. if(!empty($inform_info)){
  42. $param = array();
  43. $param['circle_id'] = $inform_info['circle_id'];
  44. $param['member_id'] = $inform_info['member_id'];
  45. $param['member_name'] = $inform_info['member_name'];
  46. $param['type'] = 'master';
  47. $param['exp'] = $i_rewards;
  48. $param['desc'] = L('circle_exp_inform');
  49. $param['itemid'] = 0;
  50. Model('circle_exp')->saveExp($param);
  51. }
  52. }
  53. }
  54. // Update the inform number
  55. $count = $model->table('circle_inform')->where(array('circle_id'=>$this->c_id, 'inform_state'=>0))->count();
  56. $model->table('circle')->update(array('circle_id'=>$this->c_id, 'new_informcount'=>$count));
  57. showDialog(L('nc_common_op_succ'),'reload','succ');
  58. }
  59. $where = array();
  60. $where['circle_id'] = $this->c_id;
  61. $where['inform_state'] = $_GET['type'] == 'treated' ? 1 : 0;
  62. $inform_list = $model->table('circle_inform')->where($where)->page(10)->order('inform_id desc')->select();
  63. // tidy
  64. if(!empty($inform_list)){
  65. foreach ($inform_list as $key=>$val){
  66. $inform_list[$key]['url'] = spellInformUrl($val);
  67. $inform_list[$key]['title'] = L('circle_theme,nc_quote1').$val['theme_name'].L('nc_quote2');
  68. if($val['reply_id'] != 0)
  69. $inform_list[$key]['title'] .= L('circle_inform_reply_title');
  70. }
  71. }
  72. Tpl::output('inform_list', $inform_list);
  73. Tpl::output('show_page', $model->showpage(2));
  74. $type = $_GET['type'] == 'treated' ? 'treated' : 'untreated';
  75. $this->sidebar_menu('inform', $type);
  76. $_GET['type'] == 'treated' ? Tpl::showpage('group_manage_inform.treated') : Tpl::showpage('group_manage_inform.untreated');
  77. }
  78. /**
  79. * Delete Inform
  80. */
  81. public function delinformOp(){
  82. // Authentication
  83. $rs = $this->checkIdentity('c');
  84. if(!empty($rs)){
  85. showDialog($rs);
  86. }
  87. $inform_id = explode(',', $_GET['i_id']);
  88. if(empty($inform_id)){
  89. echo 'false';exit;
  90. }
  91. $where = array();
  92. $where['circle_id'] = $this->c_id;
  93. $where['inform_id'] = array('in', $inform_id);
  94. Model()->table('circle_inform')->where($where)->delete();
  95. showDialog(L('nc_common_del_succ'), 'reload', 'succ');
  96. }
  97. }