人人商城

module.ctrl.php 5.2KB

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