group.ctrl.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. $pageindex = max(1, intval($_GPC['page']));
  12. $pagesize = 10;
  13. $condition = '' ;
  14. $params = array();
  15. $name = safe_gpc_string($_GPC['name']);
  16. if (!empty($name)) {
  17. $condition .= "WHERE name LIKE :name";
  18. $params[':name'] = "%{$name}%";
  19. }
  20. $lists = pdo_fetchall("SELECT * FROM " . tablename('users_founder_group') . $condition . " LIMIT " . ($pageindex - 1) * $pagesize . "," . $pagesize, $params);
  21. $lists = user_group_format($lists);
  22. $total = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename('users_founder_group') . $condition, $params);
  23. $pager = pagination($total, $pageindex, $pagesize);
  24. template('founder/group');
  25. }
  26. if ($do == 'post') {
  27. $id = intval($_GPC['id']);
  28. if (!empty($id)) {
  29. $group_info = pdo_get('users_founder_group', array('id' => $id));
  30. $group_info['package'] = iunserializer($group_info['package']);
  31. if (!empty($group_info['package']) && in_array(-1, $group_info['package'])) {
  32. $group_info['check_all'] = true;
  33. }
  34. }
  35. $packages = uni_groups();
  36. if (!empty($packages)) {
  37. foreach ($packages as $uni_group_id => &$package_info) {
  38. if (!empty($group_info['package']) && in_array($uni_group_id, $group_info['package'])) {
  39. $package_info['checked'] = true;
  40. } else {
  41. $package_info['checked'] = false;
  42. }
  43. }
  44. unset($package_info);
  45. }
  46. if (checksubmit('submit')) {
  47. $account_all_type = uni_account_type();
  48. $account_all_type_sign = array_keys(uni_account_type_sign());
  49. $founder_user_group = array(
  50. 'id' => intval($_GPC['id']),
  51. 'name' => safe_gpc_string($_GPC['name']),
  52. 'package' => safe_gpc_array($_GPC['package']),
  53. 'timelimit' => intval($_GPC['timelimit'])
  54. );
  55. foreach ($account_all_type_sign as $account_type) {
  56. $maxtype = 'max' . $account_type;
  57. $founder_user_group[$maxtype] = intval($_GPC[$maxtype]);
  58. }
  59. $user_group = user_save_founder_group($founder_user_group);
  60. if (is_error($user_group)) {
  61. itoast($user_group['message'], '', '');
  62. }
  63. cache_clean(cache_system_key('user_modules'));
  64. itoast('用户组更新成功!', url('founder/group'), 'success');
  65. }
  66. template('founder/group-post');
  67. }
  68. if ($do == 'del') {
  69. $id = intval($_GPC['id']);
  70. $result = pdo_delete('users_founder_group', array('id' => $id));
  71. if(!empty($result)){
  72. itoast('删除成功!', url('founder/group/'), 'success');
  73. }else {
  74. itoast('删除失败!请稍候重试!', url('founder/group'), 'error');
  75. }
  76. exit;
  77. }