人人商城

manage.ctrl.php 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. defined('IN_IA') or exit('Access Denied');
  3. load()->model('phoneapp');
  4. $account_info = permission_user_account_num();
  5. $do = safe_gpc_belong($do, array('create_display', 'save', 'display', 'del_version'), 'display');
  6. $uniacid = intval($_GPC['uniacid']);
  7. $acid = intval($_GPC['acid']);
  8. if (!empty($uniacid)) {
  9. $state = permission_account_user_role($_W['uid'], $uniacid);
  10. $role_permission = in_array($state, array(ACCOUNT_MANAGE_NAME_OWNER, ACCOUNT_MANAGE_NAME_FOUNDER, ACCOUNT_MANAGE_NAME_MANAGER, ACCOUNT_MANAGE_NAME_VICE_FOUNDER));
  11. if (!$role_permission) {
  12. itoast('无权限操作!', referer(), 'error');
  13. }
  14. }
  15. if ($do == 'save') {
  16. $version_id = intval($_GPC['version_id']);
  17. if (empty($uniacid) && empty($account_info['phoneapp_limit']) && !user_is_founder($_W['uid'])) {
  18. iajax(-1, '创建APP个数已满', url('account/display', array('type' => PHONEAPP_TYPE_SIGN)));
  19. }
  20. $data = array(
  21. 'uniacid' => $uniacid,
  22. 'name' => safe_gpc_string($_GPC['name']),
  23. 'description' => safe_gpc_string($_GPC['description']),
  24. 'version' => safe_gpc_string($_GPC['version']),
  25. 'modules' => iserializer(safe_gpc_array($_GPC['module'])),
  26. 'createtime' => TIMESTAMP
  27. );
  28. if (empty($uniacid) && empty($version_id)) {
  29. $phoneapp_table = table('phoneapp');
  30. $result = $phoneapp_table->createPhoneApp($data);
  31. } else if (!empty($version_id)) {
  32. unset($data['name']);
  33. $result = pdo_update('phoneapp_versions', $data, array('id' => $version_id, 'uniacid' => $uniacid));
  34. iajax(0, '修改成功', url('account/display', array('type' => PHONEAPP_TYPE_SIGN)), array('uniacid' => $uniacid));
  35. } else {
  36. unset($data['name']);
  37. $result = pdo_insert('phoneapp_versions', $data);
  38. }
  39. if (!empty($result)) {
  40. iajax(0, '创建成功', url('account/display', array('type' => PHONEAPP_TYPE_SIGN)));
  41. }
  42. iajax(-1, '创建失败', url('phoneapp/manage/create_display'));
  43. }
  44. if($do == 'create_display') {
  45. $version_id = intval($_GPC['version_id']);
  46. $version_info = phoneapp_version($version_id);
  47. $modules = phoneapp_support_modules();
  48. template('phoneapp/create');
  49. }
  50. if ($do == 'display') {
  51. $account = uni_fetch($uniacid);
  52. if (is_error($account)) {
  53. itoast($account['message'], url('account/manage', array('account_type' => ACCOUNT_TYPE_PHONEAPP_NORMAL)), 'error');
  54. } else {
  55. $phoneapp_table = table('phoneapp');
  56. $phoneapp_info = $phoneapp_table->phoneappAccountInfo($account['uniacid']);
  57. $version_exist = phoneapp_fetch($account['uniacid']);
  58. if (!empty($version_exist)) {
  59. $phoneapp_version_lists = phoneapp_version_all($account['uniacid']);
  60. $phoneapp_modules = phoneapp_support_modules();
  61. }
  62. }
  63. template('phoneapp/manage');
  64. }
  65. if ($do == 'del_version') {
  66. $id = intval($_GPC['version_id']);
  67. if (empty($id)) {
  68. iajax(1, '参数错误!');
  69. }
  70. $version_exist = pdo_get('phoneapp_versions', array('id' => $id, 'uniacid' => $uniacid));
  71. if (empty($version_exist)) {
  72. iajax(1, '模块版本不存在!');
  73. }
  74. $result = pdo_delete('phoneapp_versions', array('id' => $id, 'uniacid' => $uniacid));
  75. if (!empty($result)) {
  76. iajax(0, '删除成功!', referer());
  77. } else {
  78. iajax(1, '删除失败,请稍候重试!');
  79. }
  80. }