人人商城

group.ctrl.php 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. $dos = array('display', 'post', 'del');
  9. $do = !empty($_GPC['do']) ? $_GPC['do'] : 'display';
  10. if ($do == 'display') {
  11. $_W['page']['title'] = '用户组列表 - 用户组 - 用户管理';
  12. $pageindex = max(1, intval($_GPC['page']));
  13. $pagesize = 10;
  14. $condition = '' ;
  15. $params = array();
  16. $name = safe_gpc_string($_GPC['name']);
  17. if (!empty($name)) {
  18. $condition .= "WHERE name LIKE :name";
  19. $params[':name'] = "%{$name}%";
  20. }
  21. if (user_is_vice_founder()) {
  22. $condition .= "WHERE owner_uid = :owner_uid";
  23. $params[':owner_uid'] = $_W['uid'];
  24. }
  25. $lists = pdo_fetchall("SELECT * FROM " . tablename('users_group') . $condition . " LIMIT " . ($pageindex - 1) * $pagesize . "," . $pagesize, $params);
  26. $lists = user_group_format($lists);
  27. $total = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename('users_group') . $condition, $params);
  28. $pager = pagination($total, $pageindex, $pagesize);
  29. template('user/group-display');
  30. }
  31. if ($do == 'post') {
  32. $id = intval($_GPC['id']);
  33. $_W['page']['title'] = $id ? '编辑用户组 - 用户组 - 用户管理' : '添加用户组 - 用户组 - 用户管理';
  34. if (!empty($id)) {
  35. $group_info = pdo_get('users_group', array('id' => $id));
  36. $group_info['package'] = iunserializer($group_info['package']);
  37. if (!empty($group_info['package']) && in_array(-1, $group_info['package'])) {
  38. $group_info['check_all'] = true;
  39. } else {
  40. $checked_groups = pdo_getall('uni_group', array('uniacid' => 0, 'id' => $group_info['package']), array('id', 'name'), '', array('id DESC'));
  41. }
  42. }
  43. $packages = uni_groups();
  44. if (!empty($packages)) {
  45. foreach ($packages as $key => &$package_val) {
  46. if (!empty($group_info['package']) && in_array($key, $group_info['package'])) {
  47. $package_val['checked'] = true;
  48. } else {
  49. $package_val['checked'] = false;
  50. }
  51. if ($package_val['id'] == -1) {
  52. unset($packages[$key]);
  53. }
  54. }
  55. unset($package_val);
  56. $packages = array_values($packages);
  57. }
  58. $pagesize = 15;
  59. $pager = pagination(count($packages), 1, $pagesize, '', array('ajaxcallback' => true, 'callbackfuncname' => 'loadMore'));
  60. if (checksubmit('submit')) {
  61. $user_group = array(
  62. 'id' => intval($_GPC['id']),
  63. 'name' => $_GPC['name'],
  64. 'package' => $_GPC['package'],
  65. 'maxaccount' => intval($_GPC['maxaccount']),
  66. 'maxwxapp' => intval($_GPC['maxwxapp']),
  67. 'maxwebapp' => intval($_GPC['maxwebapp']),
  68. 'maxphoneapp' => intval($_GPC['maxphoneapp']),
  69. 'maxxzapp' => intval($_GPC['maxxzapp']),
  70. 'maxaliapp' => intval($_GPC['maxaliapp']),
  71. 'timelimit' => intval($_GPC['timelimit'])
  72. );
  73. $user_group_info = user_save_group($user_group);
  74. if (is_error($user_group_info)) {
  75. itoast($user_group_info['message'], '', '');
  76. }
  77. cache_clean(cache_system_key('user_modules'));
  78. itoast('用户组更新成功!', url('user/group/display'), 'success');
  79. }
  80. template('user/group-post');
  81. }
  82. if ($do == 'del') {
  83. $id = intval($_GPC['id']);
  84. $result = pdo_delete('users_group', array('id' => $id));
  85. if(!empty($result)){
  86. itoast('删除成功!', url('user/group/display'), 'success');
  87. }else {
  88. itoast('删除失败!请稍候重试!', url('user/group'), 'error');
  89. }
  90. exit;
  91. }