人人商城

display.ctrl.php 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. $_W['page']['title'] = '用户列表 - 用户管理';
  12. $founders = explode(',', $_W['config']['setting']['founder']);
  13. if ($do == 'display') {
  14. $message_id = intval($_GPC['message_id']);
  15. message_notice_read($message_id);
  16. $user_groups = user_group();
  17. $pindex = max(1, intval($_GPC['page']));
  18. $psize = 20;
  19. $users_table = table('users');
  20. $users_table->searchWithTimelimitStatus(intval($_GPC['expire']));
  21. $type = empty($_GPC['type']) ? 'display' : $_GPC['type'];
  22. if (in_array($type, array('display', 'check', 'recycle', 'clerk'))) {
  23. switch ($type) {
  24. case 'check':
  25. permission_check_account_user('system_user_check');
  26. $users_table->searchWithStatus(USER_STATUS_CHECK);
  27. $users_table->userOrderBy('joindate', 'DESC');
  28. break;
  29. case 'recycle':
  30. permission_check_account_user('system_user_recycle');
  31. $users_table->searchWithStatus(USER_STATUS_BAN);
  32. break;
  33. case 'clerk':
  34. permission_check_account_user('system_user_clerk');
  35. $users_table->searchWithStatus(USER_STATUS_NORMAL);
  36. $users_table->searchWithType(USER_TYPE_CLERK);
  37. break;
  38. default:
  39. permission_check_account_user('system_user');
  40. $users_table->searchWithStatus(USER_STATUS_NORMAL);
  41. $users_table->searchWithType(USER_TYPE_COMMON);
  42. $users_table->searchWithFounder(array(ACCOUNT_MANAGE_GROUP_GENERAL, ACCOUNT_MANAGE_GROUP_FOUNDER));
  43. break;
  44. }
  45. $search = safe_gpc_string($_GPC['search']);
  46. if (!empty($search)) {
  47. $users_table->searchWithNameOrMobile($search);
  48. }
  49. $group_id = intval($_GPC['groupid']);
  50. if (!empty($group_id)) {
  51. $users_table->searchWithGroupId($group_id);
  52. }
  53. if (user_is_vice_founder()) {
  54. $users_table->searchWithOwnerUid($_W['uid']);
  55. }
  56. $users_table->searchWithPage($pindex, $psize);
  57. $users = $users_table->searchUsersList();
  58. $total = $users_table->getLastQueryTotal();
  59. $users = user_list_format($users);
  60. $users = array_values($users);
  61. $pager = pagination($total, $pindex, $psize);
  62. }
  63. template('user/display');
  64. }
  65. if ($do == 'operate') {
  66. if (!$_W['isajax'] || !$_W['ispost']) {
  67. iajax(-1, '非法操作!', referer());
  68. }
  69. $type = safe_gpc_string($_GPC['type']);
  70. $types = array('recycle', 'recycle_delete', 'recycle_restore', 'check_pass');
  71. if (!in_array($type, $types)) {
  72. iajax(-1, '类型错误!', referer());
  73. }
  74. switch ($type) {
  75. case 'check_pass':
  76. permission_check_account_user('system_user_check');
  77. break;
  78. case 'recycle':
  79. case 'recycle_delete':
  80. case 'recycle_restore':
  81. permission_check_account_user('system_user_recycle');
  82. break;
  83. }
  84. $uid = intval($_GPC['uid']);
  85. $uid_user = user_single($uid);
  86. if (in_array($uid, $founders)) {
  87. iajax(-1, '访问错误, 无法操作站长.', url('user/display'));
  88. }
  89. if (empty($uid_user)) {
  90. exit('未指定用户,无法删除.');
  91. }
  92. if ($uid_user['founder_groupid'] != ACCOUNT_MANAGE_GROUP_GENERAL) {
  93. iajax(-1, '非法操作', referer());
  94. }
  95. switch ($type) {
  96. case 'check_pass':
  97. $data = array('status' => USER_STATUS_NORMAL);
  98. pdo_update('users', $data , array('uid' => $uid));
  99. iajax(0, '更新成功', referer());
  100. break;
  101. case 'recycle': user_delete($uid, true);
  102. iajax(0, '更新成功', referer());
  103. break;
  104. case 'recycle_delete': user_delete($uid);
  105. iajax(0, '删除成功', referer());
  106. break;
  107. case 'recycle_restore':
  108. $data = array('status' => USER_STATUS_NORMAL);
  109. pdo_update('users', $data , array('uid' => $uid));
  110. iajax(0, '启用成功', referer());
  111. break;
  112. }
  113. }