edit.ctrl.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. load()->func('file');
  9. $dos = array('edit_base', 'edit_modules_tpl', 'edit_account');
  10. $do = in_array($do, $dos) ? $do: 'edit_base';
  11. $uid = intval($_GPC['uid']);
  12. $user = user_single($uid);
  13. if (empty($user)) {
  14. itoast('访问错误, 未找到该操作员.', url('user/display'), 'error');
  15. } else {
  16. if ($user['status'] == 1) itoast('访问错误,该用户未审核通过,请先审核通过再修改!', url('user/display/check_display'), 'error');
  17. if ($user['status'] == 3) itoast('访问错误,该用户已被禁用,请先启用再修改!', url('user/display/recycle_display'), 'error');
  18. }
  19. $founders = explode(',', $_W['config']['setting']['founder']);
  20. $profile = pdo_get('users_profile', array('uid' => $uid));
  21. if (!empty($profile)) $profile['avatar'] = tomedia($profile['avatar']);
  22. if ($do == 'edit_base') {
  23. $account_num = permission_user_account_num($uid);
  24. $user['last_visit'] = date('Y-m-d H:i:s', $user['lastvisit']);
  25. $user['joindate'] = date('Y-m-d', $user['joindate']);
  26. $user['end'] = $user['endtime'] == 0 ? '永久' : date('Y-m-d', $user['endtime']);
  27. $user['endtype'] = $user['endtime'] == 0 ? 1 : 2;
  28. $user['url'] = user_invite_register_url($uid);
  29. $profile = user_detail_formate($profile);
  30. template('user/edit-base');
  31. }
  32. if ($do == 'edit_modules_tpl') {
  33. if ($_W['isajax'] && $_W['ispost']) {
  34. if (intval($_GPC['groupid']) == $user['groupid']){
  35. iajax(2, '未做更改!');
  36. }
  37. if (!empty($_GPC['type']) && !empty($_GPC['groupid'])) {
  38. $data['uid'] = $uid;
  39. $data[$_GPC['type']] = intval($_GPC['groupid']);
  40. if (user_update($data)) {
  41. $group_info = user_founder_group_detail_info($_GPC['groupid']);
  42. iajax(0, $group_info, '');
  43. } else {
  44. iajax(1, '更改失败!', '');
  45. }
  46. } else {
  47. iajax(-1, '参数错误!', '');
  48. }
  49. }
  50. $modules = user_modules($_W['uid']);
  51. $templates = pdo_getall('site_templates', array(), array('id', 'name', 'title'));
  52. $groups = user_founder_group();
  53. $group_info = user_founder_group_detail_info($user['groupid']);
  54. $extend = array();
  55. $users_extra_template_table = table('users_extra_templates');
  56. $user_extend_templates_ids = array_keys($users_extra_template_table->getExtraTemplatesIdsByUid($_GPC['uid']));
  57. if (!empty($user_extend_templates_ids)) {
  58. $extend['templates'] = pdo_getall('site_templates', array('id' => $user_extend_templates_ids), array('id', 'name', 'title'));
  59. }
  60. if (!empty($templates) && !empty($user_extend_templates_ids)) {
  61. foreach($templates as $template_key => $template_val) {
  62. if (in_array($template_val['id'], $user_extend_templates_ids)) {
  63. $templates[$template_key]['checked'] = 1;
  64. }
  65. }
  66. }
  67. $uni_groups = uni_groups();
  68. $users_extra_group_table = table('users_extra_group');
  69. $user_extra_groups = $users_extra_group_table->getUniGroupsByUid($uid);
  70. $user_extra_groups = !empty($user_extra_groups) ? uni_groups(array_keys($user_extra_groups)) : array();
  71. if (!empty($uni_groups)) {
  72. foreach ($uni_groups as $module_group_key => &$module_group_val) {
  73. if (!empty($user_extra_groups[$module_group_key])) {
  74. $module_group_val['checked'] = 1;
  75. } else {
  76. $module_group_val['checked'] = 0;
  77. }
  78. unset($module_group_val);
  79. }
  80. }
  81. $users_extra_modules_table = table('users_extra_modules');
  82. $user_extend_modules = $users_extra_modules_table->where('uid', $uid)->getall('id');
  83. $extra_module_types = array();
  84. if (!empty($user_extend_modules)) {
  85. foreach($user_extend_modules as $extend_module_info) {
  86. $module_info = module_fetch($extend_module_info['module_name']);
  87. $module_info['support'] = $extend_module_info['support'];
  88. if (!empty($module_info)) {
  89. $extend['modules'][] = $module_info;
  90. $extra_module_types[] = $extend_module_info['module_name'] . $module_info['support'];
  91. }
  92. }
  93. }
  94. $module_support_type = module_support_type();
  95. if (!empty($modules)) {
  96. foreach ($modules as $item) {
  97. if ($item['issystem'] != 0) {
  98. continue;
  99. }
  100. foreach ($module_support_type as $module_support_type_key => $module_support_type_val) {
  101. if ($item[$module_support_type_key] == $module_support_type_val['support']) {
  102. $item['support'] = $module_support_type_key;
  103. $item['checked'] = 0;
  104. $user_modules['modules'][] = $item;
  105. }
  106. }
  107. }
  108. }
  109. foreach ($user_modules['modules'] as &$user_module_info) {
  110. if (in_array($user_module_info['name'] . $user_module_info['support'], $extra_module_types)) {
  111. $user_module_info['checked'] = 1;
  112. }
  113. unset($user_module_info);
  114. }
  115. template('user/edit-modules-tpl');
  116. }
  117. if ($do == 'edit_account') {
  118. $account_detail = user_account_detail_info($uid);
  119. $account_list = array();
  120. if (!empty($account_detail)) {
  121. foreach($account_detail as $account_type => $accounts) {
  122. if (empty($accounts) || !is_array($accounts)) {
  123. continue;
  124. }
  125. foreach ($accounts as $uniacid => $account) {
  126. $account['type_name'] = $account_type == 'wechats' ? 'account' : $account_type;
  127. $account_list[$uniacid] = $account;
  128. }
  129. }
  130. }
  131. template('user/edit-account');
  132. }