manage.ctrl.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. defined('IN_IA') or exit('Access Denied');
  3. load()->model('phoneapp');
  4. $account_info = permission_user_account_num();
  5. $dos = array('create_display', 'save');
  6. $do = in_array($do, $dos) ? $do : 'create_display';
  7. $uniacid = intval($_GPC['uniacid']);
  8. $acid = intval($_GPC['acid']);
  9. if (!empty($uniacid)) {
  10. $state = permission_account_user_role($_W['uid'], $uniacid);
  11. $role_permission = in_array($state, array(ACCOUNT_MANAGE_NAME_OWNER, ACCOUNT_MANAGE_NAME_FOUNDER, ACCOUNT_MANAGE_NAME_MANAGER, ACCOUNT_MANAGE_NAME_VICE_FOUNDER));
  12. if (!$role_permission) {
  13. itoast('无权限操作!', referer(), 'error');
  14. }
  15. }
  16. if ($do == 'save') {
  17. $version_id = intval($_GPC['version_id']);
  18. if (empty($uniacid) && empty($account_info['phoneapp_limit']) && !user_is_founder($_W['uid'])) {
  19. iajax(-1, '创建APP个数已满');
  20. }
  21. if (empty($_GPC['name']) && empty($_GPC['uniacid'])) {
  22. iajax(1, '请填写APP名称');
  23. }
  24. if (!preg_match('/^[0-9]{1,2}\.[0-9]{1,2}(\.[0-9]{1,2})?$/', trim($_GPC['version']))) {
  25. iajax('-1', '版本号错误,只能是数字、点,数字最多2位,例如 1.1.1 或1.2');
  26. }
  27. $modulename = safe_gpc_string(trim($_GPC['module'][0]['name']));
  28. $version = safe_gpc_string(trim($_GPC['module'][0]['version']));
  29. $version_data = array(
  30. 'uniacid' => $uniacid,
  31. 'description' => safe_gpc_string($_GPC['description']),
  32. 'version' => safe_gpc_string($_GPC['version']),
  33. 'modules' => iserializer(array($modulename => array('name' => $modulename, 'version' => $version))),
  34. );
  35. if (empty($uniacid) && empty($version_id)) {
  36. } elseif (!empty($version_id)) {
  37. $version_exist = phoneapp_version($version_id);
  38. if(empty($version_exist)) {
  39. iajax(1, '版本不存在或已删除!');
  40. }
  41. $result = pdo_update('phoneapp_versions', $version_data, array('id' => $version_id));
  42. if (!empty($result)) {
  43. table('uni_link_uniacid')->searchWithUniacidModulenameVersionid($uniacid, $modulename, $version_id)->delete();
  44. }
  45. } else {
  46. $result = pdo_insert('phoneapp_versions', $version_data);
  47. $version_id = pdo_insertid();
  48. }
  49. if (!empty($result)) {
  50. cache_delete(cache_system_key('user_accounts', array('type' => 'phoneapp', 'uid' => $_W['uid'])));
  51. iajax(0, '创建成功', url('account/display/switch', array('uniacid' => $uniacid, 'version_id' => $version_id)));
  52. }
  53. iajax(-1, '创建失败', url('phoneapp/manage/create_display'));
  54. }
  55. if($do == 'create_display') {
  56. $version_id = intval($_GPC['version_id']);
  57. $version_info = phoneapp_version($version_id);
  58. $modules = phoneapp_support_modules();
  59. template('phoneapp/create');
  60. }