人人商城

recycle.ctrl.php 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. $dos = array('display', 'recover', 'delete');
  8. $do = in_array($do, $dos) ? $do : 'display';
  9. if (!in_array($_W['role'], array(ACCOUNT_MANAGE_NAME_OWNER, ACCOUNT_MANAGE_NAME_FOUNDER, ACCOUNT_MANAGE_NAME_VICE_FOUNDER))) {
  10. itoast('无权限操作!', referer(), 'error');
  11. }
  12. $_W['page']['title'] = $account_typename . '回收站 - ' . $account_typename;
  13. if ($do == 'display') {
  14. $pindex = max(1, $_GPC['page']);
  15. $psize = 20;
  16. $start = ($pindex - 1) * $psize;
  17. $condition = '';
  18. $param = array();
  19. $keyword = trim($_GPC['keyword']);
  20. $type_condition = array(
  21. ACCOUNT_TYPE_APP_NORMAL => array(ACCOUNT_TYPE_APP_NORMAL, ACCOUNT_TYPE_APP_AUTH),
  22. ACCOUNT_TYPE_OFFCIAL_NORMAL => array(ACCOUNT_TYPE_OFFCIAL_NORMAL, ACCOUNT_TYPE_OFFCIAL_AUTH),
  23. ACCOUNT_TYPE_OFFCIAL_AUTH => array(ACCOUNT_TYPE_OFFCIAL_NORMAL, ACCOUNT_TYPE_OFFCIAL_AUTH),
  24. ACCOUNT_TYPE_WEBAPP_NORMAL => array(ACCOUNT_TYPE_WEBAPP_NORMAL),
  25. ACCOUNT_TYPE_PHONEAPP_NORMAL => array(ACCOUNT_TYPE_PHONEAPP_NORMAL),
  26. ACCOUNT_TYPE_XZAPP_NORMAL => array(ACCOUNT_TYPE_XZAPP_NORMAL, ACCOUNT_TYPE_XZAPP_AUTH),
  27. ACCOUNT_TYPE_ALIAPP_NORMAL => array(ACCOUNT_TYPE_ALIAPP_NORMAL),
  28. );
  29. $type_condition_sql = "'".implode("','", $type_condition[ACCOUNT_TYPE])."'";
  30. if (user_is_founder($_W['uid'], true)) {
  31. $condition .= " WHERE a.acid <> 0 AND b.isdeleted = 1 AND b.type IN ($type_condition_sql)";
  32. $order_by = " ORDER BY a.`acid` DESC";
  33. } else {
  34. $condition .= "LEFT JOIN ". tablename('uni_account_users')." as c ON a.uniacid = c.uniacid WHERE a.acid <> 0 AND c.uid = :uid AND b.isdeleted = 1 AND b.type IN ($type_condition_sql)";
  35. $param[':uid'] = $_W['uid'];
  36. $order_by = " ORDER BY c.`rank` DESC, a.`acid` DESC";
  37. }
  38. if(!empty($keyword)) {
  39. $condition .=" AND a.`name` LIKE :name";
  40. $param[':name'] = "%{$keyword}%";
  41. }
  42. $tsql = "SELECT count(*) FROM " .tablename(uni_account_tablename(ACCOUNT_TYPE)) . " AS a LEFT JOIN " . tablename('account') . " AS b ON a.acid = b.acid {$condition} {$order_by}";
  43. $sql = $sql = "SELECT * FROM ". tablename(uni_account_tablename(ACCOUNT_TYPE)). " as a LEFT JOIN ". tablename('account'). " as b ON a.acid = b.acid {$condition} {$order_by}, a.`uniacid` DESC LIMIT {$start}, {$psize}";
  44. $total = pdo_fetchcolumn($tsql, $param);
  45. $del_accounts = pdo_fetchall($sql, $param);
  46. if(!empty($del_accounts)) {
  47. foreach ($del_accounts as &$account) {
  48. $settings = uni_setting($account['uniacid'], array('notify'));
  49. if(!empty($settings['notify'])) {
  50. $account['sms'] = $settings['notify']['sms']['balance'];
  51. }else {
  52. $account['sms'] = 0;
  53. }
  54. $account['thumb'] = tomedia('headimg_'.$account['acid']. '.jpg').'?time='.time();
  55. $account['setmeal'] = uni_setmeal($account['uniacid']);
  56. }
  57. }
  58. $pager = pagination($total, $pindex, $psize);
  59. template('account/recycle');
  60. }
  61. if ($do == 'recover') {
  62. $acid = intval($_GPC['acid']);
  63. $uniacid = intval($_GPC['uniacid']);
  64. $state = permission_account_user_role($_W['uid'], $uniacid);
  65. if (!in_array($state, array(ACCOUNT_MANAGE_NAME_FOUNDER, ACCOUNT_MANAGE_NAME_OWNER, ACCOUNT_MANAGE_NAME_VICE_FOUNDER))) {
  66. itoast('没有权限,请联系该公众号的主管理员或网站创始人进行恢复操作!', referer(), 'error');
  67. }
  68. $account_info = permission_user_account_num();
  69. if ($account_info['uniacid_limit'] <= 0 && $_W['role'] != ACCOUNT_MANAGE_NAME_FOUNDER) {
  70. itoast('您所在用户组可添加的主公号数量已达上限,请停用后再行恢复此公众号!', referer(), 'error');
  71. }
  72. if (!empty($uniacid)) {
  73. pdo_update('account', array('isdeleted' => 0), array('uniacid' => $uniacid));
  74. cache_delete(cache_system_key('uniaccount', array('uniacid' => $uniacid)));
  75. } else {
  76. pdo_update('account', array('isdeleted' => 0), array('acid' => $acid));
  77. }
  78. itoast('恢复成功', referer(), 'success');
  79. }
  80. if($do == 'delete') {
  81. if (empty($_W['isajax']) || empty($_W['ispost'])) {
  82. iajax(0, '非法操作!', referer());
  83. }
  84. $uniacid = intval($_GPC['uniacid']);
  85. $acid = intval($_GPC['acid']);
  86. $state = permission_account_user_role($_W['uid'], $uniacid);
  87. if (!in_array($state, array(ACCOUNT_MANAGE_NAME_OWNER, ACCOUNT_MANAGE_NAME_FOUNDER, ACCOUNT_MANAGE_NAME_VICE_FOUNDER))) {
  88. itoast('没有权限!', referer(), 'error');
  89. }
  90. $jobid = account_delete($acid);
  91. if (user_is_founder($_W['uid'], true)) {
  92. $url = url('system/job/display', array('jobid'=>$jobid));
  93. } else {
  94. $highrole = permission_account_user_role($_W['uid']);
  95. if (in_array($highrole, array(ACCOUNT_MANAGE_NAME_OWNER, ACCOUNT_MANAGE_NAME_VICE_FOUNDER))) {
  96. $url = url('account/recycle', array('account_type' => ACCOUNT_TYPE));
  97. } else {
  98. $url = url('account/manage', array('account_type' => ACCOUNT_TYPE));
  99. }
  100. }
  101. iajax(0, '删除成功!', $url);
  102. }