manage_mapply.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. /**
  3. * 圈子首页
  4. *
  5. *
  6. *********************************/
  7. defined('InShopNC') or exit('Access Invalid!');
  8. class manage_mapplyControl extends BaseCircleManageControl{
  9. public function __construct(){
  10. parent::__construct();
  11. Language::read('circle');
  12. $this->circleSEO();
  13. }
  14. /**
  15. * Apply to be a management
  16. */
  17. public function indexOp(){
  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. $mapply_list = $model->table('circle_mapply')->where(array('circle_id'=>$this->c_id))->page(10)->order('mapply_id desc')->select();
  26. if(!empty($mapply_list)){
  27. $memberid_array = array();
  28. $mapply_array = array();
  29. foreach ($mapply_list as $val){
  30. $memberid_array[] = $val['member_id'];
  31. $mapply_array[$val['member_id']] = $val;
  32. }
  33. $member_list = $model->table('circle_member')->field('cm_level,cm_levelname,member_id,member_name')->where(array('circle_id'=>$this->c_id, 'member_id'=>array('in', $memberid_array)))->select();
  34. $mapply_list = array();
  35. if (!empty($member_list)){
  36. foreach ($member_list as $val){
  37. $mapply_list[$val['member_id']] = array_merge($val, $mapply_array[$val['member_id']]);
  38. }
  39. }
  40. Tpl::output('mapply_list', $mapply_list);
  41. Tpl::output('show_page', $model->showpage(2));
  42. }
  43. $this->sidebar_menu('managerapply');
  44. Tpl::showpage('group_manage_mapply');
  45. }
  46. /**
  47. * Management application approved
  48. */
  49. public function mapply_passOp(){
  50. // Verify the identity
  51. $rs = $this->checkIdentity('c');
  52. if(!empty($rs)){
  53. showDialog($rs);
  54. }
  55. $cmid_array = explode(',', $_GET['cm_id']);
  56. foreach ($cmid_array as $key=>$val){
  57. if(!is_numeric($val)) unset($cmid_array[$key]);
  58. }
  59. if(empty($cmid_array)){
  60. showDialog(L('wrong_argument'));
  61. }
  62. $model = Model();
  63. // Calculate number allows you to add administrator
  64. $manage_count = $model->table('circle_member')->where(array('circle_id'=>$this->c_id, 'is_identity'=>2))->count();
  65. $i = intval(C('circle_managesum')) - intval($manage_count);
  66. $cmid_array = array_slice($cmid_array, 0, $i);
  67. // conditions
  68. $where = array();
  69. $where['member_id'] = array('in', $cmid_array);
  70. $where['circle_id'] = $this->c_id;
  71. // Update the data
  72. $update = array();
  73. $update['is_identity'] = 2;
  74. $model->table('circle_member')->where($where)->update($update);
  75. // Delete already through application information
  76. $model->table('circle_mapply')->where($where)->delete();
  77. // Update the application for membership
  78. $count = $model->table('circle_mapply')->where(array('circle_id'=>$this->c_id))->count();
  79. $model->table('circle')->update(array('circle_id'=>$this->c_id, 'new_mapplycount'=>$count));
  80. showDialog(L('nc_common_op_succ'), 'reload', 'succ');
  81. }
  82. /**
  83. * Management application to delete
  84. */
  85. public function delOp(){
  86. // Verify the identity
  87. $rs = $this->checkIdentity('c');
  88. if(!empty($rs)){
  89. showDialog($rs);
  90. }
  91. $cmid_array = explode(',', $_GET['cm_id']);
  92. foreach ($cmid_array as $key=>$val){
  93. if(!is_numeric($val)) unset($cmid_array[$key]);
  94. }
  95. if(empty($cmid_array)){
  96. showDialog(L('wrong_argument'));
  97. }
  98. $model = Model();
  99. // conditions
  100. $where = array();
  101. $where['circle_id'] = $this->c_id;
  102. $where['member_id'] = array('in', $cmid_array);
  103. // Delete the information
  104. $model->table('circle_mapply')->where($where)->delete();
  105. // Update the application for membership
  106. $count = $model->table('circle_mapply')->where(array('circle_id'=>$this->c_id))->count();
  107. $model->table('circle')->update(array('circle_id'=>$this->c_id, 'new_mapplycount'=>$count));
  108. showDialog(L('nc_common_op_succ'), 'reload', 'succ');
  109. }
  110. }