create-group.ctrl.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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', 'delete', 'post', 'save');
  8. $do = !empty($_GPC['do']) ? $_GPC['do'] : 'display';
  9. $account_group_table = table('users_create_group');
  10. if ($do == 'display') {
  11. $pageindex = max(1, intval($_GPC['page']));
  12. $pagesize = 10;
  13. $condition = '';
  14. $params = array();
  15. $group_name = safe_gpc_string($_GPC['group_name']);
  16. if (!empty($group_name)) {
  17. $account_group_table->searchLikeGroupName($group_name);
  18. }
  19. $account_group_table->searchWithPage($pageindex, $pagesize);
  20. $lists = $account_group_table->getCreateGroupList();
  21. $total = $account_group_table->getLastQueryTotal();
  22. $pager = pagination($total, $pageindex, $pagesize);
  23. if (user_is_vice_founder()) {
  24. $table = table('users_founder_own_create_groups');
  25. $create_groups = $table->getGroupsByFounderUid($_W['uid'], $pageindex, $pagesize);
  26. $create_groups['pager'] = pagination($create_groups['total'], $pageindex, $pagesize, '', array('ajaxcallback' => true, 'callbackfuncname' => 'changePage'));
  27. $lists = $create_groups['groups'];
  28. $total = $create_groups['total'];
  29. $page = $create_groups['pager'];
  30. }
  31. template('user/create-group-display');
  32. }
  33. if ($do == 'post') {
  34. $id = intval($_GPC['id']);
  35. if (!empty($id)) {
  36. $account_group_info = $account_group_table->getCreateGroupInfoById($id);
  37. }
  38. $account_all_type = uni_account_type();
  39. $account_all_type_sign = array_keys(uni_account_type_sign());
  40. if (checksubmit('submit')) {
  41. $user_account_group = array(
  42. 'id' => intval($_GPC['id']),
  43. 'group_name' => safe_gpc_string($_GPC['group_name']),
  44. );
  45. $max_type_all = 0;
  46. foreach ($account_all_type_sign as $account_type) {
  47. $maxtype = 'max' . $account_type;
  48. $user_account_group[$maxtype] = intval($_GPC[$maxtype]);
  49. $max_type_all += $_GPC[$maxtype];
  50. }
  51. if ($max_type_all <= 0) {
  52. itoast('至少能创建一个账号!', '', '');
  53. }
  54. $res = user_save_create_group($user_account_group);
  55. if (is_error($res)) {
  56. itoast($res['message'], '', '');
  57. }
  58. itoast('操作成功!', url('user/create-group/display'), '');
  59. }
  60. template('user/create-group-post');
  61. }
  62. if ($do == 'del') {
  63. $id = intval($_GPC['id']);
  64. $res = $account_group_table->deleteById($id);
  65. table('users_founder_own_create_groups')->where('create_group_id', $id)->delete();
  66. $url = url('user/create-group/display');
  67. $msg = $res ? '成功' : '失败';
  68. itoast('操作' . $msg, $url);
  69. }