manage.ctrl.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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()->func('file');
  8. load()->model('user');
  9. load()->model('message');
  10. load()->model('miniapp');
  11. $dos = array('display', 'delete', 'account_detailinfo', 'account_create_info');
  12. $do = in_array($_GPC['do'], $dos) ? $do : 'display';
  13. if ($do == 'display') {
  14. $message_id = intval($_GPC['message_id']);
  15. message_notice_read($message_id);
  16. $pindex = max(1, intval($_GPC['page']));
  17. $psize = 20;
  18. $account_table = table('account');
  19. $account_type = $_GPC['account_type'];
  20. if (!empty($account_type) && in_array($account_type, array_keys($account_all_type_sign))) {
  21. $account_type = $account_all_type_sign[$account_type]['contain_type'];
  22. $account_table->searchWithType($account_type);
  23. }
  24. $order = safe_gpc_string($_GPC['order']);
  25. $account_table->accountUniacidOrder($order);
  26. $keyword = safe_gpc_string($_GPC['keyword']);
  27. if (!empty($keyword)) {
  28. $account_table->searchWithKeyword($keyword);
  29. }
  30. $account_table->searchWithPage($pindex, $psize);
  31. if (in_array(safe_gpc_string($_GPC['type']), array('expire', 'unexpire'))) {
  32. $expire_type = safe_gpc_string($_GPC['type']);
  33. }
  34. $list = $account_table->searchAccountList($expire_type);
  35. foreach ($account_all_type_sign as $type_sign => $type_value) {
  36. $type = $type_sign == 'account' ? 'app' : $type_sign;
  37. $type_accounts = uni_user_accounts($_W['uid'], $type);
  38. if (!empty($type_accounts)) {
  39. $account_all_type_sign[$type_sign]['account_num'] = count($type_accounts);
  40. }
  41. }
  42. $list = array_values($list);
  43. $total = $account_table->getLastQueryTotal();
  44. $pager = pagination($total, $pindex, $psize);
  45. template('account/manage-display');
  46. }
  47. if ($do == 'account_create_info') {
  48. $account_create_info = permission_user_account_num();
  49. foreach ($account_all_type_sign as $sign => &$sign_info) {
  50. $sign_limit = $sign . '_limit';
  51. $founder_sign_limit = 'founder_' . $sign . '_limit';
  52. if (!empty($account_create_info[$sign_limit]) && (!empty($account_create_info[$founder_sign_limit]) && $_W['user']['owner_uid'] || empty($_W['user']['owner_uid'])) || $_W['isfounder'] && !user_is_vice_founder()) {
  53. $sign_info['can_create'] = true;
  54. } else {
  55. $sign_info['can_create'] = false;
  56. }
  57. }
  58. iajax(0, $account_all_type_sign);
  59. }
  60. if ($do == 'account_detailinfo') {
  61. $uniacids = safe_gpc_array($_GPC['uniacids']);
  62. if (empty($uniacids)) {
  63. return array();
  64. }
  65. $account_detailinfo = array();
  66. foreach ($uniacids as $uniacid_value) {
  67. $uniacid = intval($uniacid_value['uniacid']);
  68. if ($uniacid <= 0) {
  69. continue;
  70. }
  71. $account = uni_fetch($uniacid);
  72. $account['owner_name'] = $account->owner['username'];
  73. $account['support_version'] = $account->supportVersion;
  74. $account['sms_num'] = !empty($account['setting']['notify']) ? $account['setting']['notify']['sms']['balance'] : 0;
  75. $account['end'] = $account['endtime'] == USER_ENDTIME_GROUP_EMPTY_TYPE || $account['endtime'] == USER_ENDTIME_GROUP_UNLIMIT_TYPE ? '永久' : date('Y-m-d', $account['endtime']);
  76. $account['manage_premission'] = in_array($account['current_user_role'], array(ACCOUNT_MANAGE_NAME_FOUNDER, ACCOUNT_MANAGE_NAME_VICE_FOUNDER, ACCOUNT_MANAGE_NAME_OWNER, ACCOUNT_MANAGE_NAME_MANAGER));
  77. if ($account['support_version']) {
  78. $account['versions'] = miniapp_get_some_lastversions($uniacid);
  79. if (!empty($account['versions'])) {
  80. foreach ($account['versions'] as $version) {
  81. if (!empty($version['current'])) {
  82. $account['current_version'] = $version;
  83. }
  84. }
  85. }
  86. }
  87. $account_detailinfo[] = $account;
  88. }
  89. iajax(0, $account_detailinfo);
  90. }
  91. if ($do == 'delete') {
  92. $uniacids = empty($_GPC['uniacids']) && !empty($_GPC['uniacid']) ? array($_GPC['uniacid']) : $_GPC['uniacids'];
  93. if (!empty($uniacids)) {
  94. foreach ($uniacids as $uniacid) {
  95. $uniacid = intval($uniacid);
  96. $state = permission_account_user_role($_W['uid'], $uniacid);
  97. if (!in_array($state, array(ACCOUNT_MANAGE_NAME_OWNER, ACCOUNT_MANAGE_NAME_FOUNDER, ACCOUNT_MANAGE_NAME_VICE_FOUNDER))) {
  98. continue;
  99. }
  100. if (!empty($uniacid)) {
  101. $account = pdo_get('uni_account', array('uniacid' => $uniacid));
  102. if (empty($account)) {
  103. continue;
  104. }
  105. pdo_update('account', array('isdeleted' => 1), array('uniacid' => $uniacid));
  106. pdo_delete('uni_modules', array('uniacid' => $uniacid));
  107. pdo_delete('users_lastuse', array('uniacid' => $uniacid));
  108. pdo_delete('core_menu_shortcut', array('uniacid' => $uniacid));
  109. if($uniacid == $_W['uniacid']) {
  110. cache_delete(cache_system_key('last_account', array('switch' => $_GPC['__switch'], 'uid' => $_W['uid'])));
  111. isetcookie('__uniacid', '');
  112. }
  113. cache_delete(cache_system_key('uniaccount', array('uniacid' => $uniacid)));
  114. }
  115. }
  116. }
  117. if (!$_W['isajax'] || !$_W['ispost']) {
  118. itoast('停用成功!,您可以在回收站中恢复', url('account/manage'));
  119. }
  120. iajax(0, '停用成功!,您可以在回收站中恢复', url('account/manage'));
  121. }