plugin.ctrl.php 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. $dos = array('display', 'rank', 'module_shortcut');
  9. $do = !empty($_GPC['do']) ? $_GPC['do'] : 'display';
  10. $module_name = trim($_GPC['m']);
  11. $uniacid = intval($_GPC['uniacid']);
  12. $modulelist = uni_modules();
  13. $module = $_W['current_module'] = $modulelist[$module_name];
  14. if ($do == 'display') {
  15. $modules_plugin_rank_table = table('modules_plugin_rank');
  16. $modules_plugin_rank_table->searchWithUid($_W['uid']);
  17. $plugin_list = $modules_plugin_rank_table->getPluginRankList($module_name, $uniacid);
  18. if (!empty($module['plugin_list'])) {
  19. foreach ($module['plugin_list'] as $plugin_name) {
  20. $plugin_rank_exists = $modules_plugin_rank_table->getByPluginNameAndUniacid($plugin_name, $uniacid);
  21. if (empty($plugin_rank_exists)) {
  22. $modules_plugin_rank_table->fill(array('uniacid' => $uniacid, 'uid' => $_W['uid'], 'rank' => 0, 'plugin_name' => $plugin_name, 'main_module_name' => $module_name))->save();
  23. }
  24. }
  25. }
  26. $module_menu_plugin_list = table('core_menu_shortcut')->getCurrentModuleMenuPluginList($module_name);
  27. if (!empty($plugin_list)) {
  28. foreach ($plugin_list as $plugin_key => &$plugin_val) {
  29. if (!empty($plugin_val['uid']) && $plugin_val['uid'] != $_W['uid']) {
  30. unset($plugin_list[$plugin_key]);
  31. continue;
  32. }
  33. $plugin_val['plugin_info'] = module_fetch($plugin_val['name']);
  34. if (empty($plugin_val['plugin_info'])) {
  35. unset($plugin_list[$plugin_key]);
  36. }
  37. if (in_array($plugin_val['name'], array_keys($module_menu_plugin_list))) {
  38. $plugin_val['module_shortcut'] = 1;
  39. }
  40. }
  41. }
  42. template('module/plugin');
  43. }
  44. if ($do == 'rank') {
  45. $plugin_name = trim($_GPC['plugin_name']);
  46. $main_module_name = trim($_GPC['main_module_name']);
  47. $uniacid = intval($_GPC['uniacid']);
  48. $exist = module_fetch($plugin_name, $uniacid);
  49. if (empty($exist)) {
  50. iajax(1, '模块不存在', '');
  51. }
  52. table('modules_plugin_rank')->setTop($plugin_name, $main_module_name, $uniacid);
  53. itoast('更新成功!', referer(), 'success');
  54. }
  55. if ($do == 'module_shortcut') {
  56. global $_W;
  57. $status = intval($_GPC['module_shortcut']);
  58. $plugin_name = $_GPC['plugin_name'];
  59. $module_info = module_fetch($plugin_name);
  60. if (empty($module_info)) {
  61. itoast('模块不能被访问!', referer(), 'error');
  62. }
  63. $main_module_name = $module_info['main_module'];
  64. $position = 'module_' . $main_module_name . '_menu_plugin_shortcut';
  65. $plugin_shortcut = pdo_get('core_menu_shortcut', array('position' => $position, 'modulename' => $plugin_name, 'uniacid' => $_W['uniacid'], 'uid' => $_W['uid']));
  66. if (empty($plugin_shortcut)) {
  67. $data = array(
  68. 'uid' => $_W['uid'],
  69. 'uniacid' => $_W['uniacid'],
  70. 'modulename' => $plugin_name,
  71. 'position' => $position,
  72. );
  73. pdo_insert('core_menu_shortcut', $data);
  74. } else {
  75. pdo_delete('core_menu_shortcut', array('id' => $plugin_shortcut['id']));
  76. }
  77. cache_build_module_info($module_name);
  78. itoast('设置成功!', referer(), 'success');
  79. }