人人商城

create.ctrl.php 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. $_W['page']['title'] = '添加用户 - 用户管理';
  9. if (checksubmit()) {
  10. if (!empty($_GPC['vice_founder_name'])) {
  11. $vice_founder_name = safe_gpc_string($_GPC['vice_founder_name']);
  12. $vice_founder_info = user_single(array('username' => $vice_founder_name));
  13. if (empty($vice_founder_info)) {
  14. itoast('副创始人不存在!');
  15. }
  16. if (!user_is_vice_founder($vice_founder_info['uid'])) {
  17. itoast('请勿添加非副创始人姓名!');
  18. }
  19. }
  20. $user_founder = array(
  21. 'username' => safe_gpc_string($_GPC['username']),
  22. 'password' => $_GPC['password'],
  23. 'repassword' => $_GPC['repassword'],
  24. 'remark' => safe_gpc_string($_GPC['remark']),
  25. 'groupid' => intval($_GPC['groupid']) ? intval($_GPC['groupid']) : 0,
  26. 'starttime' => TIMESTAMP,
  27. 'endtime' => intval(strtotime($_GPC['endtime'])),
  28. 'owner_uid' => !empty($vice_founder_name) ? $vice_founder_info['uid'] : !user_is_vice_founder($_W['uid']) ? 0 : $_W['uid'],
  29. );
  30. $user_add = user_info_save($user_founder);
  31. if (is_error($user_add)) {
  32. itoast($user_add['message'], '', '');
  33. }
  34. $uid = $user_add['uid'];
  35. if (!empty($_GPC['extra']['modules']) || !empty($_GPC['extra']['templates'])) {
  36. $data = array(
  37. 'modules' => iserializer(array('modules' => $_GPC['extra']['modules'], 'wxapp' => $_GPC['extra']['modules'], 'webapp' => $_GPC['extra']['modules'], 'xzapp' => $_GPC['extra']['modules'], 'phoneapp' => $_GPC['extra']['modules'])),
  38. 'templates' => iserializer($_GPC['extra']['templates']),
  39. 'uid' => $uid,
  40. 'uniacid' => 0,
  41. 'owner_uid' => 0,
  42. 'name' => '',
  43. );
  44. $id = pdo_fetchcolumn("SELECT id FROM " . tablename('uni_group') . " WHERE uid=:uid and uniacid=:uniacid", array(":uniacid" => 0, ":uid" => $uid));
  45. if (empty($id)) {
  46. pdo_insert('uni_group', $data);
  47. } else {
  48. pdo_update('uni_group', $data, array('id' => $id));
  49. }
  50. } else {
  51. pdo_delete('uni_group', array('uid' => $uid, 'uniacid' => 0));
  52. }
  53. itoast($user_add['message'], url('user/edit', array('uid' => $user_add['uid'])), 'success');
  54. }
  55. $groups = user_group();
  56. $modules = user_modules($_W['uid']);
  57. $modules = array_filter($modules, function($module) {
  58. return empty($module['issystem']);
  59. });
  60. $templates = pdo_fetchall("SELECT * FROM " . tablename('site_templates'));
  61. template('user/create');