人人商城

manage-account.ctrl.php 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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('module');
  8. load()->model('account');
  9. load()->model('user');
  10. load()->model('cloud');
  11. load()->model('cache');
  12. load()->model('extension');
  13. $dos = array('display', 'setting', 'shortcut', 'enable', 'check_status');
  14. $do = !empty($_GPC['do']) ? $_GPC['do'] : 'display';
  15. $modulelist = uni_modules();
  16. if ($do == 'check_status') {
  17. $modulename = $_GPC['module'];
  18. if (empty($modulename)) {
  19. iajax(0, '', '');
  20. }
  21. $module_status = module_status($modulename);
  22. if (!empty($module_status)) {
  23. isetcookie('module_status:' . $modulename, json_encode($module_status));
  24. }
  25. if ($module_status['ban']) {
  26. iajax(1, '您的站点存在盗版模块, 请删除文件后联系客服');
  27. }
  28. if ($module_status['upgrade']['has_upgrade']) {
  29. iajax(2, $module_status['upgrade']['name'] . '检测最新版为' . $module_status['upgrade']['version'] . ',请尽快更新');
  30. }
  31. iajax(0, '', '');
  32. }
  33. if($do == 'display') {
  34. $_W['page']['title'] = '公众号 - 应用模块 - 更多应用';
  35. $pageindex = max(1, intval($_GPC['page']));
  36. $pagesize = 30;
  37. $modules = $displayorder = array();
  38. if (!empty($modulelist)) {
  39. foreach ($modulelist as $name => $row) {
  40. if (!empty($row['issystem'])) {
  41. continue;
  42. }
  43. if (!empty($_GPC['keyword']) && !strexists($row['title'], $_GPC['keyword'])) {
  44. continue;
  45. }
  46. if (!empty($_GPC['letter']) && $row['title_initial'] != $_GPC['letter']) {
  47. continue;
  48. }
  49. $displayorder[$name] = $row['displayorder'];
  50. $modules[$name] = $row;
  51. }
  52. }
  53. array_multisort($displayorder, SORT_DESC, $modules);
  54. template ('module/manage-account');
  55. } elseif ($do == 'shortcut') {
  56. $status = intval($_GPC['shortcut']);
  57. $modulename = $_GPC['modulename'];
  58. $module_enabled = uni_account_module_shortcut_enabled($modulename, $status);
  59. if (is_error($module_enabled)) {
  60. itoast($module_enabled['message'], referer(), 'error');
  61. }
  62. itoast(($status ? '添加' : '取消') . '添加模块快捷操作成功!', referer(), 'success');
  63. } elseif ($do == 'enable') {
  64. $modulename = $_GPC['modulename'];
  65. if(empty($modulelist[$modulename])) {
  66. itoast('抱歉,你操作的模块不能被访问!', '', '');
  67. }
  68. pdo_update('uni_account_modules', array(
  69. 'enabled' => empty($_GPC['enabled']) ? STATUS_OFF : STATUS_ON,
  70. ), array(
  71. 'module' => $modulename,
  72. 'uniacid' => $_W['uniacid']
  73. ));
  74. cache_build_module_info($modulename);
  75. itoast('模块操作成功!', referer(), 'success');
  76. } elseif ($do == 'top') {
  77. $modulename = $_GPC['modulename'];
  78. $module = $modulelist[$modulename];
  79. if(empty($module)) {
  80. itoast('抱歉,你操作的模块不能被访问!', '', '');
  81. }
  82. $max_displayorder = (int)pdo_getcolumn('uni_account_modules', array('uniacid' => $_W['uniacid']), 'MAX(displayorder)');
  83. $module_profile = pdo_get('uni_account_modules', array('module' => $modulename, 'uniacid' => $_W['uniacid']));
  84. if (!empty($module_profile)) {
  85. pdo_update('uni_account_modules', array('displayorder' => ++$max_displayorder), array('id' => $module_profile['id']));
  86. } else {
  87. pdo_insert('uni_account_modules', array(
  88. 'displayorder' => ++$max_displayorder,
  89. 'module' => $modulename,
  90. 'uniacid' => $_W['uniacid'],
  91. 'enabled' => STATUS_ON,
  92. 'shortcut' => STATUS_OFF,
  93. ));
  94. }
  95. cache_build_module_info($modulename);
  96. cache_build_account_modules($_W['uniacid']);
  97. itoast('模块置顶成功', referer(), 'success');
  98. } elseif ($do == 'setting') {
  99. $modulename = $_GPC['m'];
  100. $module = $_W['current_module'] = $modulelist[$modulename];
  101. if(empty($module)) {
  102. itoast('抱歉,你操作的模块不能被访问!', '', '');
  103. }
  104. if(!permission_check_account_user_module($modulename.'_settings', $modulename)) {
  105. itoast('您没有权限进行该操作', '', '');
  106. }
  107. define('IN_MODULE', $modulename);
  108. define('CRUMBS_NAV', 1);
  109. $config = $module['config'];
  110. if (($module['settings'] == 2) && !is_file(IA_ROOT."/addons/{$module['name']}/developer.cer")) {
  111. if (empty($_W['setting']['site']['key']) || empty($_W['setting']['site']['token'])) {
  112. itoast('站点未注册,请先注册站点。', url('cloud/profile'), 'info');
  113. }
  114. if (empty($config)) {
  115. $config = array();
  116. }
  117. load()->model('cloud');
  118. load()->func('communication');
  119. $pro_attach_url = tomedia('pro_attach_url');
  120. $pro_attach_url = str_replace('pro_attach_url', '', $pro_attach_url);
  121. $module_simple = array_elements(array('name', 'type', 'title', 'version', 'settings'), $module);
  122. $module_simple['pro_attach_url'] = $pro_attach_url;
  123. $iframe = cloud_module_setting_prepare($module_simple, 'setting');
  124. $result = ihttp_post($iframe, array('inherit_setting' => base64_encode(iserializer($config))));
  125. if (is_error($result)) {
  126. itoast($result['message'], '', '');
  127. }
  128. $result = json_decode($result['content'], true);
  129. if (is_error($result)) {
  130. itoast($result['message'], '', '');
  131. }
  132. $module_simple = array_elements(array('name', 'type', 'title', 'version', 'settings'), $module);
  133. $module_simple['pro_attach_url'] = $pro_attach_url;
  134. $iframe = cloud_module_setting_prepare($module_simple, 'setting');
  135. template('module/manage-account-setting');
  136. exit();
  137. }
  138. $obj = WeUtility::createModule($module['name']);
  139. $obj->settingsDisplay($config);
  140. exit();
  141. }