welcome.ctrl.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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('reply');
  9. load()->model('miniapp');
  10. load()->model('welcome');
  11. load()->model('cache');
  12. $dos = array('display', 'welcome_display', 'get_module_info', 'get_module_replies', 'get_module_accounts', 'get_module_covers', 'change_enter_status');
  13. $do = !empty($_GPC['do']) ? $_GPC['do'] : 'display';
  14. $module_name = trim($_GPC['m']);
  15. $uniacid = intval($_GPC['uniacid']);
  16. $module = $_W['current_module'] = module_fetch($module_name);
  17. if(empty($module)) {
  18. cache_build_account_modules($uniacid);
  19. itoast('抱歉,你操作的模块不能被访问!');
  20. }
  21. if ($do == 'display') {
  22. $notices = welcome_notices_get();
  23. template('module/welcome');
  24. }
  25. if ($do == 'welcome_display') {
  26. $site = WeUtility::createModule($module_name);
  27. if (!is_error($site)) {
  28. $method = 'welcomeDisplay';
  29. if(method_exists($site, $method)){
  30. define('FRAME', 'module_welcome');
  31. $entries = module_entries($module_name, array('menu', 'home', 'profile', 'shortcut', 'cover', 'mine'));
  32. $site->$method($entries);
  33. exit;
  34. }
  35. }
  36. }
  37. if ($do == 'get_module_info') {
  38. $uni_modules_talbe = table('uni_modules');
  39. $uni_modules_talbe->searchWithModuleName($module_name);
  40. $module_info = $uni_modules_talbe->getModulesByUid($_W['uid'], $uniacid);
  41. $module_info = current($module_info['modules']);
  42. $site = WeUtility::createModule($module_name);
  43. if (!is_error($site) && method_exists($site, 'welcomeDisplay')) {
  44. $module_info['welcome_display'] = true;
  45. $module_info['direct_enter_status'] = module_get_direct_enter_status($module_name);
  46. }
  47. $data = array(
  48. 'module_info' => $module_info,
  49. );
  50. iajax(0, $data);
  51. }
  52. if ($do == 'get_module_replies') {
  53. $condition = "uniacid = :uniacid AND module != 'cover' AND module != 'userapi'";
  54. $condition .= " AND `module` = :type";
  55. $params[':type'] = $module_name;
  56. $params[':uniacid'] = $uniacid;
  57. $replies = reply_search($condition, $params);
  58. if (!empty($replies)) {
  59. foreach ($replies as &$item) {
  60. $condition = '`rid`=:rid';
  61. $params = array();
  62. $params[':rid'] = $item['id'];
  63. $item['keywords'] = reply_keywords_search($condition, $params);
  64. $item['allreply'] = reply_contnet_search($item['id']);
  65. $entries = module_entries($item['module'], array('rule'),$item['id']);
  66. if (!empty($entries)) {
  67. $item['options'] = $entries['rule'];
  68. }
  69. if (!in_array($item['module'], array("basic", "news", "images", "voice", "video", "music", "wxcard", "reply"))) {
  70. $item['module_info'] = module_fetch($item['module']);
  71. }
  72. }
  73. unset($item);
  74. }
  75. iajax(0, $replies);
  76. }
  77. if ($do == 'get_module_accounts') {
  78. $account_info = uni_fetch($uniacid);
  79. $sub_account_uniacids = table('uni_link_uniacid')->getSubUniacids($uniacid, $module_name);
  80. $link_accounts = array();
  81. if (!empty($sub_account_uniacids)) {
  82. foreach($sub_account_uniacids as $sub_uniacid) {
  83. $link_accounts[] = uni_fetch($sub_uniacid);
  84. }
  85. }
  86. $data = array('account_info' => $account_info, 'link_accounts' => $link_accounts);
  87. iajax(0, $data);
  88. }
  89. if ($do == 'get_module_covers') {
  90. $entries = module_entries($module_name);
  91. if (!empty($entries['cover'])) {
  92. $covers = $entries['cover'];
  93. $cover_eid = current($covers);
  94. $cover_eid = $cover_eid['eid'];
  95. }
  96. iajax(0, array('covers' => $covers, 'cover_eid' => $cover_eid));
  97. }
  98. if ($do == 'change_enter_status') {
  99. $result = module_change_direct_enter_status($module_name);
  100. if ($result) {
  101. iajax(0, true);
  102. } else {
  103. iajax(-1, '修改失败!');
  104. }
  105. }