人人商城

manage.ctrl.php 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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');
  12. $do = in_array($_GPC['do'], $dos)? $do : 'display';
  13. $_W['page']['title'] = $account_typename . '列表 - ' . $account_typename;
  14. $account_info = permission_user_account_num();
  15. $role_type = in_array($_W['role'], array(ACCOUNT_MANAGE_NAME_FOUNDER, ACCOUNT_MANAGE_NAME_VICE_FOUNDER, ACCOUNT_MANAGE_NAME_OWNER, ACCOUNT_MANAGE_NAME_MANAGER));
  16. if ($do == 'display') {
  17. $message_id = intval($_GPC['message_id']);
  18. message_notice_read($message_id);
  19. $pindex = max(1, intval($_GPC['page']));
  20. $psize = 20;
  21. $account_table = table('account');
  22. $type_condition = array(
  23. ACCOUNT_TYPE_APP_NORMAL => array(ACCOUNT_TYPE_APP_NORMAL, ACCOUNT_TYPE_APP_AUTH),
  24. ACCOUNT_TYPE_WEBAPP_NORMAL => array(ACCOUNT_TYPE_WEBAPP_NORMAL),
  25. ACCOUNT_TYPE_OFFCIAL_NORMAL => array(ACCOUNT_TYPE_OFFCIAL_NORMAL, ACCOUNT_TYPE_OFFCIAL_AUTH),
  26. ACCOUNT_TYPE_PHONEAPP_NORMAL => array(ACCOUNT_TYPE_PHONEAPP_NORMAL),
  27. ACCOUNT_TYPE_XZAPP_NORMAL => array(ACCOUNT_TYPE_XZAPP_NORMAL, ACCOUNT_TYPE_XZAPP_AUTH),
  28. ACCOUNT_TYPE_ALIAPP_NORMAL => array(ACCOUNT_TYPE_ALIAPP_NORMAL),
  29. );
  30. $account_table->searchWithType($type_condition[ACCOUNT_TYPE]);
  31. $keyword = trim($_GPC['keyword']);
  32. if (!empty($keyword)) {
  33. $account_table->searchWithKeyword($keyword);
  34. }
  35. if(isset($_GPC['letter']) && strlen($_GPC['letter']) == 1) {
  36. $account_table->searchWithLetter($_GPC['letter']);
  37. }
  38. $order = trim($_GPC['order']);
  39. $account_table->accountUniacidOrder($order);
  40. $type = trim($_GPC['type']);
  41. if ($type == 'noconnect') {
  42. $account_table->searchWithNoconnect();
  43. }
  44. $account_table->searchWithPage($pindex, $psize);
  45. if ($type == 'expire') {
  46. $list = $account_table->searchAccountList(true);
  47. } else {
  48. $list = $account_table->searchAccountList();
  49. }
  50. foreach($list as &$account) {
  51. $account = uni_fetch($account['uniacid']);
  52. $account['end'] = $account['endtime'] == 0 ? '永久' : date('Y-m-d', $account['endtime']);
  53. $account['role'] = permission_account_user_role($_W['uid'], $account['uniacid']);
  54. $account['versions'] = miniapp_get_some_lastversions($account['uniacid']);
  55. if (!empty($account['versions'])) {
  56. foreach ($account['versions'] as $version) {
  57. if (!empty($version['current'])) {
  58. $account['current_version'] = $version;
  59. }
  60. }
  61. }
  62. }
  63. $list = array_values($list);
  64. $total = $account_table->getLastQueryTotal();
  65. $pager = pagination($total, $pindex, $psize);
  66. template('account/manage-display' . ACCOUNT_TYPE_TEMPLATE);
  67. }
  68. if ($do == 'delete') {
  69. $uniacid = intval($_GPC['uniacid']);
  70. $acid = intval($_GPC['acid']);
  71. $uid = $_W['uid'];
  72. $type = intval($_GPC['type']);
  73. $state = permission_account_user_role($uid, $uniacid);
  74. if (!in_array($state, array(ACCOUNT_MANAGE_NAME_OWNER, ACCOUNT_MANAGE_NAME_FOUNDER, ACCOUNT_MANAGE_NAME_VICE_FOUNDER))) {
  75. itoast('无权限操作!', url('account/manage'), 'error');
  76. }
  77. if (!empty($acid) && empty($uniacid)) {
  78. $account = account_fetch($acid);
  79. if (empty($account)) {
  80. itoast('子公众号不存在或是已经被删除', '', '');
  81. }
  82. $uniaccount = uni_fetch($account['uniacid']);
  83. if ($uniaccount['default_acid'] == $acid) {
  84. itoast('默认子公众号不能删除', '', '');
  85. }
  86. pdo_update('account', array('isdeleted' => 1), array('acid' => $acid));
  87. itoast('删除子公众号成功!您可以在回收站中回复公众号', referer(), 'success');
  88. }
  89. if (!empty($uniacid)) {
  90. $account = pdo_get('uni_account', array('uniacid' => $uniacid));
  91. if (empty($account)) {
  92. itoast('抱歉,帐号不存在或是已经被删除', url('account/manage', array('account_type' => ACCOUNT_TYPE)), 'error');
  93. }
  94. $state = permission_account_user_role($uid, $uniacid);
  95. if (!in_array($state, array(ACCOUNT_MANAGE_NAME_OWNER, ACCOUNT_MANAGE_NAME_FOUNDER, ACCOUNT_MANAGE_NAME_VICE_FOUNDER))) {
  96. itoast('没有该'. ACCOUNT_TYPE_NAME . '操作权限!', url('account/manage', array('account_type' => ACCOUNT_TYPE)), 'error');
  97. }
  98. pdo_update('account', array('isdeleted' => 1), array('uniacid' => $uniacid));
  99. if($_GPC['uniacid'] == $_W['uniacid']) {
  100. cache_delete(cache_system_key('last_account', array('switch' => $_GPC['__switch'])));
  101. isetcookie('__uniacid', '');
  102. }
  103. cache_delete(cache_system_key('uniaccount', array('uniacid' => $uniacid)));
  104. }
  105. itoast('停用成功!,您可以在回收站中恢复', url('account/manage', array('account_type' => ACCOUNT_TYPE)), 'success');
  106. }