人人商城

manage.ctrl.php 3.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. define('FRAME', 'system');
  8. load()->model('system');
  9. load()->model('miniapp');
  10. $dos = array('display', 'edit_version', 'del_version');
  11. $do = in_array($do, $dos) ? $do : 'display';
  12. $uniacid = intval($_GPC['uniacid']);
  13. $acid = intval($_GPC['acid']);
  14. if (empty($uniacid)) {
  15. itoast('请选择要编辑的小程序', referer(), 'error');
  16. }
  17. $state = permission_account_user_role($_W['uid'], $uniacid);
  18. $role_permission = in_array($state, array(ACCOUNT_MANAGE_NAME_OWNER, ACCOUNT_MANAGE_NAME_FOUNDER, ACCOUNT_MANAGE_NAME_MANAGER, ACCOUNT_MANAGE_NAME_VICE_FOUNDER));
  19. if (!$role_permission) {
  20. itoast('无权限操作!', referer(), 'error');
  21. }
  22. if ($do == 'display') {
  23. $account = uni_fetch($uniacid);
  24. if (is_error($account)) {
  25. itoast($account['message'], url('account/manage', array('account_type' => ACCOUNT_TYPE_APP_NORMAL)), 'error');
  26. } else {
  27. $miniapp_info = pdo_get('account_aliapp', array('uniacid' => $account['uniacid']));
  28. $version_exist = miniapp_fetch($account['uniacid']);
  29. if (!empty($version_exist)) {
  30. $version_lists = miniapp_version_all($account['uniacid']);
  31. if (!empty($version_lists)) {
  32. foreach ($version_lists as &$row) {
  33. if (!empty($row['modules'])) {
  34. $row['module'] = current($row['modules']);
  35. }
  36. }
  37. unset($row);
  38. }
  39. $miniapp_modules = miniapp_support_uniacid_modules($account['uniacid'], MODULE_SUPPORT_ALIAPP_NAME);
  40. }
  41. }
  42. template('miniapp/manage');
  43. }
  44. if ($do == 'edit_version') {
  45. if (empty($_GPC['name'])) {
  46. iajax(1, '模块名不可为空!');
  47. }
  48. $module_name = safe_gpc_string($_GPC['name']);
  49. $module_info = module_fetch($module_name);
  50. if (empty($module_info)) {
  51. iajax(1, '模块不存在!');
  52. }
  53. $versionid = intval($_GPC['version_id']);
  54. $version_exist = miniapp_fetch($uniacid, $versionid);
  55. if(empty($version_exist)) {
  56. iajax(1, '版本不存在或已删除!');
  57. }
  58. $miniapp_modules = miniapp_support_uniacid_modules($uniacid, MODULE_SUPPORT_ALIAPP_NAME);
  59. $supoort_modulenames = array_keys($miniapp_modules);
  60. $new_module_data = array();
  61. if (!in_array($module_name, $supoort_modulenames)) {
  62. iajax(1, '没有模块:' . $module_info['title'] . '的权限!');
  63. }
  64. $new_module_data[$module_name] = array(
  65. 'name' => $module_name,
  66. 'version' => $module_info['version']
  67. );
  68. pdo_update('wxapp_versions', array('modules' => iserializer($new_module_data)), array('id' => $versionid));
  69. cache_delete(cache_system_key('miniapp_version', array('version_id' => $versionid)));
  70. iajax(0, '修改成功!', referer());
  71. }
  72. if ($do == 'del_version') {
  73. $id = intval($_GPC['versionid']);
  74. if (empty($id)) {
  75. iajax(1, '参数错误!');
  76. }
  77. $version_exist = pdo_get('wxapp_versions', array('id' => $id, 'uniacid' => $uniacid));
  78. if (empty($version_exist)) {
  79. iajax(1, '模块版本不存在!');
  80. }
  81. $result = pdo_delete('wxapp_versions', array('id' => $id, 'uniacid' => $uniacid));
  82. if (!empty($result)) {
  83. iajax(0, '删除成功!', referer());
  84. } else {
  85. iajax(1, '删除失败,请稍候重试!');
  86. }
  87. }