display.ctrl.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. load()->model('user');
  8. load()->model('message');
  9. $dos = array('display', 'operate');
  10. $do = in_array($do, $dos) ? $do: 'display';
  11. $founders = explode(',', $_W['config']['setting']['founder']);
  12. if ($do == 'display') {
  13. $message_id = intval($_GPC['message_id']);
  14. message_notice_read($message_id);
  15. $user_groups = user_group();
  16. $pindex = max(1, intval($_GPC['page']));
  17. $psize = 20;
  18. $users_table = table('users');
  19. $users_table->searchWithTimelimitStatus(intval($_GPC['expire']));
  20. if (!empty($_GPC['user_type'])) {
  21. $user_type = $_GPC['user_type'] == USER_TYPE_COMMON ? USER_TYPE_COMMON : USER_TYPE_CLERK;
  22. if ($user_type == USER_TYPE_CLERK) {
  23. $users_table->searchWithType(USER_TYPE_CLERK);
  24. } else {
  25. $users_table->searchWithType(USER_TYPE_COMMON);
  26. }
  27. }
  28. $type = empty($_GPC['type']) ? 'display' : $_GPC['type'];
  29. if (in_array($type, array('display', 'check', 'recycle'))) {
  30. switch ($type) {
  31. case 'check':
  32. permission_check_account_user('system_user_check');
  33. $users_table->searchWithStatus(USER_STATUS_CHECK);
  34. $users_table->userOrderBy('joindate', 'DESC');
  35. break;
  36. case 'recycle':
  37. permission_check_account_user('system_user_recycle');
  38. $users_table->searchWithStatus(USER_STATUS_BAN);
  39. break;
  40. default:
  41. permission_check_account_user('system_user');
  42. $users_table->searchWithStatus(USER_STATUS_NORMAL);
  43. $users_table->searchWithFounder(array(ACCOUNT_MANAGE_GROUP_GENERAL, ACCOUNT_MANAGE_GROUP_FOUNDER));
  44. break;
  45. }
  46. $search = safe_gpc_string($_GPC['search']);
  47. if (!empty($search)) {
  48. $users_table->searchWithNameOrMobile($search);
  49. }
  50. $group_id = intval($_GPC['groupid']);
  51. if (!empty($group_id)) {
  52. $users_table->searchWithGroupId($group_id);
  53. }
  54. if (user_is_vice_founder()) {
  55. $users_table->searchFounderOwnUsers($_W['uid']);
  56. }
  57. $users_table->searchWithoutFounder();
  58. $users_table->searchWithPage($pindex, $psize);
  59. $users = $users_table->getUsersList();
  60. $total = $users_table->getLastQueryTotal();
  61. $users = user_list_format($users);
  62. $users = array_values($users);
  63. $pager = pagination($total, $pindex, $psize);
  64. }
  65. template('user/display');
  66. }
  67. if ($do == 'operate') {
  68. if (!$_W['isajax'] || !$_W['ispost']) {
  69. iajax(-1, '非法操作!', referer());
  70. }
  71. $type = safe_gpc_string($_GPC['type']);
  72. $types = array('recycle', 'recycle_delete', 'recycle_restore', 'check_pass');
  73. if (!in_array($type, $types)) {
  74. iajax(-1, '类型错误!', referer());
  75. }
  76. switch ($type) {
  77. case 'check_pass':
  78. permission_check_account_user('system_user_check');
  79. break;
  80. case 'recycle':
  81. case 'recycle_delete':
  82. case 'recycle_restore':
  83. permission_check_account_user('system_user_recycle');
  84. break;
  85. }
  86. $uid = intval($_GPC['uid']);
  87. $uid_user = user_single($uid);
  88. if (in_array($uid, $founders)) {
  89. iajax(-1, '访问错误, 无法操作站长.', url('user/display'));
  90. }
  91. if (empty($uid_user)) {
  92. exit('未指定用户,无法删除.');
  93. }
  94. if ($uid_user['founder_groupid'] != ACCOUNT_MANAGE_GROUP_GENERAL) {
  95. iajax(-1, '非法操作', referer());
  96. }
  97. switch ($type) {
  98. case 'check_pass':
  99. $data = array('status' => USER_STATUS_NORMAL);
  100. pdo_update('users', $data , array('uid' => $uid));
  101. iajax(0, '更新成功', referer());
  102. break;
  103. case 'recycle': user_delete($uid, true);
  104. iajax(0, '更新成功', referer());
  105. break;
  106. case 'recycle_delete': user_delete($uid);
  107. iajax(0, '删除成功', referer());
  108. break;
  109. case 'recycle_restore':
  110. $data = array('status' => USER_STATUS_NORMAL);
  111. pdo_update('users', $data , array('uid' => $uid));
  112. iajax(0, '启用成功', referer());
  113. break;
  114. }
  115. }