common.func.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  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('miniapp');
  9. function system_modules() {
  10. return module_system();
  11. }
  12. function url($segment, $params = array()) {
  13. return wurl($segment, $params);
  14. }
  15. function message($msg, $redirect = '', $type = '', $tips = false, $extend = array()) {
  16. global $_W, $_GPC;
  17. if($redirect == 'refresh') {
  18. $redirect = $_W['script_name'] . '?' . $_SERVER['QUERY_STRING'];
  19. }
  20. if($redirect == 'referer') {
  21. $redirect = referer();
  22. }
  23. $redirect = safe_gpc_url($redirect);
  24. if($redirect == '') {
  25. $type = in_array($type, array('success', 'error', 'info', 'warning', 'ajax', 'sql', 'expired')) ? $type : 'info';
  26. } else {
  27. $type = in_array($type, array('success', 'error', 'info', 'warning', 'ajax', 'sql', 'expired')) ? $type : 'success';
  28. }
  29. if ($_W['isajax'] || !empty($_GET['isajax']) || $type == 'ajax') {
  30. if($type != 'ajax' && !empty($_GPC['target'])) {
  31. exit("
  32. <script type=\"text/javascript\">
  33. var url = ".(!empty($redirect) ? 'parent.location.href' : "''").";
  34. var modalobj = util.message('".$msg."', '', '".$type."');
  35. if (url) {
  36. modalobj.on('hide.bs.modal', function(){\$('.modal').each(function(){if(\$(this).attr('id') != 'modal-message') {\$(this).modal('hide');}});top.location.reload()});
  37. }
  38. </script>");
  39. } else {
  40. $vars = array();
  41. $vars['message'] = $msg;
  42. $vars['redirect'] = $redirect;
  43. $vars['type'] = $type;
  44. exit(json_encode($vars));
  45. }
  46. }
  47. if (empty($msg) && !empty($redirect)) {
  48. header('Location: '.$redirect);
  49. exit;
  50. }
  51. $label = $type;
  52. if($type == 'error' || $type == 'expired') {
  53. $label = 'danger';
  54. }
  55. if($type == 'ajax' || $type == 'sql') {
  56. $label = 'warning';
  57. }
  58. if ($tips) {
  59. if (is_array($msg)){
  60. $message_cookie['title'] = 'MYSQL 错误';
  61. $message_cookie['msg'] = 'php echo cutstr(' . $msg['sql'] . ', 300, 1);';
  62. } else{
  63. $message_cookie['title'] = $caption;
  64. $message_cookie['msg'] = $msg;
  65. }
  66. $message_cookie['type'] = $label;
  67. $message_cookie['redirect'] = $redirect ? $redirect : referer();
  68. $message_cookie['msg'] = rawurlencode($message_cookie['msg']);
  69. $extend_button = array();
  70. if (!empty($extend) && is_array($extend)) {
  71. foreach ($extend as $button) {
  72. if (!empty($button['title']) && !empty($button['url'])) {
  73. $button['url'] = safe_gpc_url($button['url'], false);
  74. $button['title'] = rawurlencode($button['title']);
  75. $extend_button[] = $button;
  76. }
  77. }
  78. }
  79. $message_cookie['extend'] = !empty($extend_button) ? $extend_button : '';
  80. isetcookie('message', stripslashes(json_encode($message_cookie, JSON_UNESCAPED_UNICODE)));
  81. header('Location: ' . $message_cookie['redirect']);
  82. } else {
  83. include template('common/message', TEMPLATE_INCLUDEPATH);
  84. }
  85. exit;
  86. }
  87. function iajax($code = 0, $message = '', $redirect = '') {
  88. message(error($code, $message), $redirect, 'ajax', false);
  89. }
  90. function itoast($message, $redirect = '', $type = '', $extend = array()) {
  91. message($message, $redirect, $type, true, $extend);
  92. }
  93. function checklogin() {
  94. global $_W;
  95. if (empty($_W['uid'])) {
  96. if (!empty($_W['setting']['copyright']['showhomepage'])) {
  97. itoast('', url('account/welcome'), 'warning');
  98. } else {
  99. itoast('', url('user/login'), 'warning');
  100. }
  101. }
  102. return true;
  103. }
  104. function buildframes($framename = ''){
  105. global $_W, $_GPC, $top_nav;
  106. load()->model('system');
  107. if (!empty($GLOBALS['frames']) && !empty($_GPC['m'])) {
  108. $frames = array();
  109. $globals_frames = (array)$GLOBALS['frames'];
  110. foreach ($globals_frames as $key => $row) {
  111. if (empty($row)) continue;
  112. $row = (array)$row;
  113. $frames['section']['platform_module_menu'.$key]['title'] = $row['title'];
  114. if (!empty($row['items'])) {
  115. foreach ($row['items'] as $li) {
  116. $frames['section']['platform_module_menu'.$key]['menu']['platform_module_menu'.$li['id']] = array(
  117. 'title' => "<i class='wi wi-appsetting'></i> {$li['title']}",
  118. 'url' => $li['url'],
  119. 'is_display' => 1,
  120. );
  121. }
  122. }
  123. }
  124. return $frames;
  125. }
  126. $frames = system_menu_permission_list();
  127. if (!empty($_W['role']) && (empty($_W['isfounder']) || user_is_vice_founder())) {
  128. $account_info = uni_fetch($_W['uniacid']);
  129. $type_sign = $account_info->typeSign == 'account' ? 'system' : $account_info->typeSign;
  130. $user_permission = permission_account_user($type_sign);
  131. }
  132. if (empty($_W['role']) && empty($_W['uniacid'])) {
  133. $user_permission = permission_account_user('system');
  134. }
  135. if (!empty($user_permission)) {
  136. foreach ($frames as $nav_id => $section) {
  137. if (empty($section['section'])) {
  138. continue;
  139. }
  140. foreach ($section['section'] as $section_id => $secion) {
  141. if ($nav_id == 'account') {
  142. if ($status && !empty($module_permission) && in_array("account*", $user_permission) && $section_id != 'platform_module' && permission_account_user_role($_W['uid'], $_W['uniacid']) != ACCOUNT_MANAGE_NAME_OWNER) {
  143. $frames['account']['section'][$section_id]['is_display'] = false;
  144. continue;
  145. } else {
  146. if (in_array("account*", $user_permission)) {
  147. continue;
  148. }
  149. }
  150. }
  151. if ($nav_id != 'wxapp' && $nav_id != 'store') {
  152. $section_show = false;
  153. $secion['if_fold'] = !empty($_GPC['menu_fold_tag:'.$section_id]) ? 1 : 0;
  154. foreach ($secion['menu'] as $menu_id => $menu) {
  155. if (!in_array($menu['permission_name'], $user_permission) && $section_id != 'platform_module' && $section_id != 'phoneapp_profile') {
  156. $frames[$nav_id]['section'][$section_id]['menu'][$menu_id]['is_display'] = false;
  157. } else {
  158. $section_show = true;
  159. }
  160. }
  161. if (!isset($frames[$nav_id]['section'][$section_id]['is_display'])) {
  162. $frames[$nav_id]['section'][$section_id]['is_display'] = $section_show;
  163. }
  164. }
  165. }
  166. if ($_W['role'] == ACCOUNT_MANAGE_NAME_EXPIRED && ($nav_id != 'store' || $nav_id != 'system')) {
  167. $menu['is_display'] = 0;
  168. }
  169. }
  170. } else {
  171. if (user_is_vice_founder()) {
  172. $frames['system']['section']['article']['is_display'] = false;
  173. $frames['system']['section']['welcome']['is_display'] = false;
  174. $frames['system']['section']['wxplatform']['menu']['system_platform']['is_display'] = false;
  175. $frames['system']['section']['user']['menu']['system_user_founder_group']['is_display'] = false;
  176. }
  177. }
  178. if (defined('FRAME') && (!in_array(FRAME, array('account', 'wxapp')))) {
  179. $frames = frames_top_menu($frames);
  180. return $frames[$framename];
  181. }
  182. if (defined('FRAME') && FRAME == 'account') {
  183. $modules = uni_modules();
  184. $sysmodules = module_system();
  185. $status = permission_account_user_permission_exist($_W['uid'], $_W['uniacid']);
  186. $module_permission = permission_account_user_menu($_W['uid'], $_W['uniacid'], 'modules');
  187. if (!$_W['isfounder'] && $status && $_W['role'] != ACCOUNT_MANAGE_NAME_OWNER && current($module_permission) != 'all') {
  188. if (!is_error($module_permission) && !empty($module_permission)) {
  189. foreach ($module_permission as $module) {
  190. if (!in_array($module['type'], $sysmodules) && $modules[$module['type']][MODULE_SUPPORT_ACCOUNT_NAME] == 2) {
  191. $module = $modules[$module['type']];
  192. if (!empty($module)) {
  193. $frames[FRAME]['section']['platform_module']['menu']['platform_' . $module['name']] = array(
  194. 'title' => $module['title'],
  195. 'icon' => $module['logo'],
  196. 'url' => url('home/welcome/account_ext', array('m' => $module['name'])),
  197. 'is_display' => 1,
  198. );
  199. }
  200. }
  201. }
  202. } else {
  203. $frames[FRAME]['section']['platform_module']['is_display'] = false;
  204. }
  205. } else {
  206. $account_module = pdo_getall('uni_account_modules', array('uniacid' => $_W['uniacid'], 'shortcut' => STATUS_ON), array('module'), '', 'displayorder DESC, id DESC');
  207. if (!empty($account_module)) {
  208. foreach ($account_module as $module) {
  209. if (!in_array($module['module'], $sysmodules)) {
  210. $module = module_fetch($module['module']);
  211. if (!empty($module) && !empty($modules[$module['name']]) && ($module[MODULE_SUPPORT_ACCOUNT_NAME] == 2 || $module['webapp_support'] == 2)) {
  212. $frames[FRAME]['section']['platform_module']['menu']['platform_' . $module['name']] = array(
  213. 'title' => $module['title'],
  214. 'icon' => $module['logo'],
  215. 'url' => url('home/welcome/account_ext', array('m' => $module['name'])),
  216. 'is_display' => 1,
  217. );
  218. }
  219. }
  220. }
  221. } elseif (!empty($modules)) {
  222. $new_modules = array_reverse($modules);
  223. $i = 0;
  224. foreach ($new_modules as $module) {
  225. if (!empty($module['issystem'])) {
  226. continue;
  227. }
  228. if ($i == 5) {
  229. break;
  230. }
  231. $frames[FRAME]['section']['platform_module']['menu']['platform_' . $module['name']] = array(
  232. 'title' => $module['title'],
  233. 'icon' => $module['logo'],
  234. 'url' => url('home/welcome/account_ext', array('m' => $module['name'])),
  235. 'is_display' => 1,
  236. );
  237. $i++;
  238. }
  239. }
  240. if (array_diff(array_keys($modules), $sysmodules)) {
  241. $frames[FRAME]['section']['platform_module']['menu']['platform_module_more'] = array(
  242. 'title' => '更多应用',
  243. 'url' => url('module/manage-account'),
  244. 'is_display' => 1,
  245. );
  246. } else {
  247. $frames[FRAME]['section']['platform_module']['is_display'] = false;
  248. }
  249. }
  250. }
  251. $modulename = trim($_GPC['m']);
  252. $eid = intval($_GPC['eid']);
  253. $version_id = intval($_GPC['version_id']);
  254. if ((!empty($modulename) || !empty($eid)) && !in_array($modulename, module_system())) {
  255. if (!empty($eid)) {
  256. $entry = pdo_get('modules_bindings', array('eid' => $eid));
  257. }
  258. if(empty($modulename)) {
  259. $modulename = $entry['module'];
  260. }
  261. $module = module_fetch($modulename);
  262. if (defined('SYSTEM_WELCOME_MODULE')) {
  263. $entries = module_entries($modulename, array('system_welcome'));
  264. } else {
  265. $entries = module_entries($modulename);
  266. }
  267. if($status) {
  268. $permission = pdo_get('users_permission', array('uniacid' => $_W['uniacid'], 'uid' => $_W['uid'], 'type' => $modulename), array('permission'));
  269. if(!empty($permission)) {
  270. $permission = explode('|', $permission['permission']);
  271. } else {
  272. $permission = array('account*');
  273. }
  274. if($permission[0] != 'all') {
  275. if(!in_array($modulename.'_rule', $permission)) {
  276. unset($module['isrulefields']);
  277. }
  278. if(!in_array($modulename.'_settings', $permission)) {
  279. unset($module['settings']);
  280. }
  281. if(!in_array($modulename.'_permissions', $permission)) {
  282. unset($module['permissions']);
  283. }
  284. if(!in_array($modulename.'_home', $permission)) {
  285. unset($entries['home']);
  286. }
  287. if(!in_array($modulename.'_profile', $permission)) {
  288. unset($entries['profile']);
  289. }
  290. if(!in_array($modulename.'_shortcut', $permission)) {
  291. unset($entries['shortcut']);
  292. }
  293. if(!empty($entries['cover'])) {
  294. foreach($entries['cover'] as $k => $row) {
  295. if(!in_array($modulename.'_cover_'.$row['do'], $permission)) {
  296. unset($entries['cover'][$k]);
  297. }
  298. }
  299. }
  300. if(!empty($entries['menu'])) {
  301. foreach($entries['menu'] as $k => $row) {
  302. if ($row['multilevel']) continue;
  303. if(!in_array($modulename.'_menu_'.$row['do'], $permission)) {
  304. unset($entries['menu'][$k]);
  305. }
  306. }
  307. }
  308. }
  309. }
  310. $frames['account']['section'] = array();
  311. if (!defined('SYSTEM_WELCOME_MODULE')) {
  312. $frames['account']['section']['platform_module_common']['menu']['platform_module_welcome'] = array(
  313. 'title' => '模块首页',
  314. 'icon' => 'wi wi-home',
  315. 'url' => url('module/welcome', array('m' => $modulename, 'uniacid' => $_GPC['uniacid'])),
  316. 'is_display' => empty($module['main_module']) ? true : false,
  317. 'module_welcome_display' => true,
  318. );
  319. }
  320. if($module['isrulefields'] || !empty($entries['cover']) || !empty($entries['mine'])) {
  321. if (!empty($module['isrulefields']) && !empty($_W['account']) && in_array($_W['account']['type'], array(ACCOUNT_TYPE_OFFCIAL_NORMAL, ACCOUNT_TYPE_OFFCIAL_AUTH, ACCOUNT_TYPE_XZAPP_NORMAL, ACCOUNT_TYPE_XZAPP_AUTH))) {
  322. $url = url('platform/reply', array('m' => $modulename, 'version_id' => $version_id));
  323. }
  324. if (empty($url) && !empty($entries['cover'])) {
  325. $url = url('platform/cover', array('eid' => $entries['cover'][0]['eid'], 'version_id' => $version_id));
  326. }
  327. $frames['account']['section']['platform_module_common']['menu']['platform_module_entry'] = array(
  328. 'title' => '应用入口',
  329. 'icon' => 'wi wi-reply',
  330. 'url' => $url,
  331. 'is_display' => 1,
  332. );
  333. }
  334. if($module['settings']) {
  335. $frames['account']['section']['platform_module_common']['menu']['platform_module_settings'] = array(
  336. 'title' => '参数设置',
  337. 'icon' => 'wi wi-parameter-setting',
  338. 'url' => url('module/manage-account/setting', array('m' => $modulename, 'version_id' => $version_id)),
  339. 'is_display' => 1,
  340. );
  341. }
  342. $account_user_role = permission_account_user_role($_W['uid'], $_W['uniacid']); if ($module['permissions'] && ($_W['isfounder'] || $account_user_role == ACCOUNT_MANAGE_NAME_OWNER) && !defined('SYSTEM_WELCOME_MODULE')) {
  343. $frames['account']['section']['platform_module_common']['menu']['platform_module_permissions'] = array(
  344. 'title' => '操作员权限',
  345. 'icon' => 'wi wi-custommenu',
  346. 'url' => url('module/permission', array('m' => $modulename, 'version_id' => $version_id)),
  347. 'is_display' => 1,
  348. );
  349. }
  350. if($entries['home'] && !empty($_W['account']) && in_array($_W['account']['type'], array(ACCOUNT_TYPE_OFFCIAL_NORMAL, ACCOUNT_TYPE_OFFCIAL_AUTH))) {
  351. $frames['account']['section']['platform_module_common']['menu']['platform_module_home'] = array(
  352. 'title' => '微站首页导航',
  353. 'icon' => 'wi wi-crontab',
  354. 'url' => url('site/nav/home', array('m' => $modulename, 'version_id' => $version_id)),
  355. 'is_display' => 1,
  356. );
  357. }
  358. if($entries['profile'] && !empty($_W['account']) && in_array($_W['account']['type'], array(ACCOUNT_TYPE_OFFCIAL_NORMAL, ACCOUNT_TYPE_OFFCIAL_AUTH))) {
  359. $frames['account']['section']['platform_module_common']['menu']['platform_module_profile'] = array(
  360. 'title' => '个人中心导航',
  361. 'icon' => 'wi wi-user',
  362. 'url' => url('site/nav/profile', array('m' => $modulename, 'version_id' => $version_id)),
  363. 'is_display' => 1,
  364. );
  365. }
  366. if($entries['shortcut'] && !empty($_W['account']) && in_array($_W['account']['type'], array(ACCOUNT_TYPE_OFFCIAL_NORMAL, ACCOUNT_TYPE_OFFCIAL_AUTH))) {
  367. $frames['account']['section']['platform_module_common']['menu']['platform_module_shortcut'] = array(
  368. 'title' => '快捷菜单',
  369. 'icon' => 'wi wi-plane',
  370. 'url' => url('site/nav/shortcut', array('m' => $modulename, 'version_id' => $version_id)),
  371. 'is_display' => 1,
  372. );
  373. }
  374. if (!empty($entries['cover'])) {
  375. foreach ($entries['cover'] as $key => $menu) {
  376. $frames['account']['section']['platform_module_common']['menu']['platform_module_cover'][] = array(
  377. 'title' => "{$menu['title']}",
  378. 'url' => url('platform/cover', array('eid' => $menu['eid'], 'version_id' => $version_id)),
  379. 'is_display' => 0,
  380. );
  381. }
  382. }
  383. $version_modules = array();
  384. if ($_W['account']->supportVersion) {
  385. $version_modules = miniapp_version($version_id);
  386. $version_modules = $version_modules['modules'];
  387. }
  388. if (!empty($module['plugin_list']) || !empty($module['main_module'])) {
  389. $modules = uni_modules();
  390. if (!empty($module['main_module'])) {
  391. $main_module = module_fetch($module['main_module']);
  392. $plugin_list = $main_module['plugin_list'];
  393. } else {
  394. $plugin_list = $module['plugin_list'];
  395. }
  396. $plugin_list = array_intersect($plugin_list, array_keys($modules));
  397. }
  398. if (!empty($module['plugin_list']) && empty($module['main_module'])) {
  399. $frames['account']['section']['platform_module_plugin']['title'] = '常用插件';
  400. $module_menu_plugin_list = table('core_menu_shortcut')->getCurrentModuleMenuPluginList($module['name']);
  401. if (!empty($module_menu_plugin_list)) {
  402. $plugin_list = array_keys($module_menu_plugin_list);
  403. }
  404. if (!empty($plugin_list)) {
  405. $i = 0;
  406. foreach ($plugin_list as $plugin_module) {
  407. $plugin_module_info = module_fetch($plugin_module);
  408. if ($i == 3 && empty($module_menu_plugin_list)) {
  409. break;
  410. }
  411. $frames['account']['section']['platform_module_plugin']['menu']['platform_' . $plugin_module_info['name']] = array(
  412. 'main_module' => $plugin_module_info['main_module'],
  413. 'title' => $plugin_module_info['title'],
  414. 'icon' => $plugin_module_info['logo'],
  415. 'url' => url('home/welcome/ext', array('m' => $plugin_module_info['name'], 'uniacid' => $_W['uniacid'], 'version_id' => $version_id)),
  416. 'is_display' => 1,
  417. );
  418. $i++;
  419. }
  420. }
  421. if ($module['main_module']) {
  422. $platform_module_plugin_more_url = url('module/plugin', array('m' => $module['main_module'], 'uniacid' => $_W['uniacid']));
  423. } else {
  424. $platform_module_plugin_more_url = url('module/plugin', array('m' => $module['name'], 'uniacid' => $_W['uniacid']));
  425. }
  426. if (!empty($plugin_list)) {
  427. $frames['account']['section']['platform_module_plugin']['menu']['platform_module_plugin_more'] = array(
  428. 'title' => '更多插件',
  429. 'url' => $platform_module_plugin_more_url,
  430. 'is_display' => empty($module['main_module']) ? 1 : 0,
  431. );
  432. } else {
  433. $frames['account']['section']['platform_module_plugin']['is_display'] = false;
  434. }
  435. }
  436. if (!empty($entries['menu'])) {
  437. $frames['account']['section']['platform_module_menu']['title'] = '业务菜单';
  438. foreach($entries['menu'] as $key => $row) {
  439. if (empty($row)) continue;
  440. if (!empty($row['parent']) && !empty($frames['account']['section']['platform_module_menu']['menu']['platform_module_menu' . $row['parent']])) {
  441. $frames['account']['section']['platform_module_menu']['menu']['platform_module_menu'.$row['parent']]['childs'][] = array(
  442. 'title' => $row['title'],
  443. 'url' => $row['url'] . '&version_id=' . $version_id,
  444. 'icon' => empty($row['icon']) ? 'wi wi-appsetting' : $row['icon'],
  445. 'is_display' => 1,
  446. );
  447. continue;
  448. }
  449. if (!empty($row['from']) && $row['from'] == 'call') {
  450. $frames['account']['section']['platform_module_menu']['menu']['platform_module_menu'.$row['eid']] = array(
  451. 'title' => $row['title'],
  452. 'url' => $row['url'] . '&version_id=' . $version_id,
  453. 'icon' => empty($row['icon']) ? 'wi wi-appsetting' : $row['icon'],
  454. 'is_display' => 1,
  455. );
  456. } else {
  457. $frames['account']['section']['platform_module_menu']['menu']['platform_module_menu'.$row['do']] = array(
  458. 'title' => $row['title'],
  459. 'url' => $row['url'] . '&version_id=' . $version_id,
  460. 'icon' => empty($row['icon']) ? 'wi wi-appsetting' : $row['icon'],
  461. 'is_display' => 1,
  462. 'multilevel' => $row['multilevel'],
  463. );
  464. }
  465. }
  466. foreach ($frames['account']['section']['platform_module_menu']['menu'] as $key => $row) {
  467. if (!empty($row['multilevel']) && empty($row['childs'])) {
  468. unset($frames['account']['section']['platform_module_menu']['menu'][$key]);
  469. }
  470. }
  471. }
  472. if (!empty($module['plugin_list']) || !empty($module['main_module'])) {
  473. if (!empty($plugin_list)) {
  474. $frames['account']['section']['platform_module_menu']['plugin_menu'] = array(
  475. 'main_module' => !empty($main_module) ? $main_module['name'] : $module['name'],
  476. 'title' => !empty($main_module) ? $main_module['title'] : $module['title'],
  477. 'icon' => !empty($main_module) ? $main_module['logo'] : $module['logo'],
  478. 'menu' => array()
  479. );
  480. foreach ($plugin_list as $plugin) {
  481. if (!$modules[$plugin]['module_shortcut'] === 0) {
  482. continue;
  483. }
  484. $frames['account']['section']['platform_module_menu']['plugin_menu']['menu'][$modules[$plugin]['name']] = array(
  485. 'title' => $modules[$plugin]['title'],
  486. 'icon' => $modules[$plugin]['logo'],
  487. 'url' => url('home/welcome/ext', array('m' => $plugin, 'version_id' => $version_id)),
  488. );
  489. }
  490. }
  491. }
  492. if (!empty($entries['system_welcome']) && $_W['isfounder']) {
  493. $frames['account']['section']['platform_module_welcome']['title'] = '';
  494. foreach ($entries['system_welcome'] as $key => $row) {
  495. if (empty($row)) continue;
  496. $frames['account']['section']['platform_module_welcome']['menu']['platform_module_welcome' . $row['eid']] = array (
  497. 'title' => "<i class='wi wi-appsetting'></i> {$row['title']}",
  498. 'url' => $row['url'],
  499. 'is_display' => 1,
  500. );
  501. }
  502. }
  503. }
  504. if (defined('FRAME') && FRAME == 'wxapp') {
  505. load()->model('miniapp');
  506. $version_id = intval($_GPC['version_id']);
  507. $wxapp_version = miniapp_version($version_id);
  508. if (!empty($wxapp_version['last_modules']) && is_array($wxapp_version['last_modules'])) {
  509. $last_modules = current($wxapp_version['last_modules']);
  510. }
  511. if (!empty($wxapp_version['modules'])) {
  512. foreach ($wxapp_version['modules'] as $module) {
  513. $wxapp_module_permission = permission_account_user_menu($_W['uid'], $_W['uniacid'], $module['name']);
  514. if (empty($wxapp_module_permission)) {
  515. $frames['wxapp']['section']['platform_module']['is_display'] = false;
  516. break;
  517. }
  518. $need_upload = !empty($last_modules) && ($module['version'] != $last_modules['version']);
  519. $frames['wxapp']['section']['platform_module']['menu']['module_menu'.$module['mid']] = array(
  520. 'icon' => $module['logo'],
  521. 'title' => $module['title'],
  522. 'url' => url('home/welcome/account_ext', array('m' => $module['name'], 'version_id' => $version_id)),
  523. 'is_display' => 1,
  524. );
  525. }
  526. } else {
  527. $frames['wxapp']['section']['platform_module']['is_display'] = false;
  528. }
  529. if (!empty($frames['wxapp']['section']['wxapp_profile']['menu']['front_download'])) {
  530. $frames['wxapp']['section']['wxapp_profile']['menu']['front_download']['need_upload'] = empty($need_upload) ? 0 : 1;
  531. }
  532. if (!empty($frames['wxapp']['section'])) {
  533. $wxapp_permission = permission_account_user('wxapp');
  534. foreach ($frames['wxapp']['section'] as $wxapp_section_id => $wxapp_section) {
  535. if ($status && !empty($wxapp_permission) && in_array("wxapp*", $wxapp_permission) && $wxapp_section_id != 'platform_module' && $role != ACCOUNT_MANAGE_NAME_OWNER) {
  536. $frames['wxapp']['section'][$wxapp_section_id]['is_display'] = false;
  537. continue;
  538. }
  539. if (!empty($wxapp_section['menu']) && $wxapp_section_id != 'platform_module') {
  540. foreach ($wxapp_section['menu'] as $wxapp_menu_id => $wxapp_menu) {
  541. if (in_array($wxapp_section_id, array('wxapp_profile', 'wxapp_entrance', 'statistics', 'mc'))) {
  542. $frames['wxapp']['section'][$wxapp_section_id]['menu'][$wxapp_menu_id]['url'] .= 'version_id=' . $version_id;
  543. }
  544. if (!in_array('wxapp*', $wxapp_permission) && !in_array($wxapp_menu['permission_name'], $wxapp_permission)) {
  545. $frames['wxapp']['section'][$wxapp_section_id]['menu'][$wxapp_menu_id]['is_display'] = false;
  546. }
  547. }
  548. }
  549. }
  550. }
  551. }
  552. $frames = frames_top_menu($frames);
  553. return !empty($framename) ? ($framename == 'system_welcome' ? $frames['account'] : $frames[$framename]) : $frames;
  554. }
  555. function frames_top_menu($frames) {
  556. global $_W, $top_nav;
  557. if (empty($frames)) {
  558. return array();
  559. }
  560. $is_vice_founder = user_is_vice_founder();
  561. $founders = explode(',', $_W['config']['setting']['founder']);
  562. foreach ($frames as $menuid => $menu) {
  563. if ((!empty($menu['founder']) || in_array($menuid, array('module_manage', 'site', 'advertisement', 'appmarket'))) && !in_array($_W['uid'], $founders) ||
  564. $_W['highest_role'] == ACCOUNT_MANAGE_NAME_CLERK && in_array($menuid, array('account', 'wxapp', 'system', 'platform', 'welcome', 'account_manage')) ||
  565. !$is_vice_founder && !in_array($_W['uid'], $founders) && in_array($menuid, array('user_manage', 'permission')) ||
  566. $menuid == 'myself' && in_array($_W['uid'], $founders) ||
  567. !$menu['is_display']) {
  568. continue;
  569. }
  570. if (is_array($_W['setting']['store']['blacklist']) && in_array($_W['username'], $_W['setting']['store']['blacklist']) && !empty($_W['setting']['store']['permission_status']) && $_W['setting']['store']['permission_status']['blacklist'] && $menuid == 'store' ||
  571. is_array($_W['setting']['store']['whitelist']) && !in_array($_W['username'], $_W['setting']['store']['whitelist']) && !empty($_W['setting']['store']['permission_status']) && $_W['setting']['store']['permission_status']['whitelist'] && !($_W['isfounder'] && !$is_vice_founder) && $menuid == 'store' ||
  572. $_W['setting']['store']['status'] == 1 && $menuid == 'store' && !in_array($_W['uid'], $founders)) {
  573. continue;
  574. }
  575. $top_nav[] = array(
  576. 'title' => $menu['title'],
  577. 'name' => $menuid,
  578. 'url' => $menu['url'],
  579. 'blank' => $menu['blank'],
  580. 'icon' => $menu['icon'],
  581. 'is_display' => $menu['is_display'],
  582. );
  583. }
  584. return $frames;
  585. }
  586. function filter_url($params) {
  587. global $_W;
  588. if(empty($params)) {
  589. return '';
  590. }
  591. $query_arr = array();
  592. $parse = parse_url($_W['siteurl']);
  593. if(!empty($parse['query'])) {
  594. $query = $parse['query'];
  595. parse_str($query, $query_arr);
  596. }
  597. $params = explode(',', $params);
  598. foreach($params as $val) {
  599. if(!empty($val)) {
  600. $data = explode(':', $val);
  601. $query_arr[$data[0]] = trim($data[1]);
  602. }
  603. }
  604. $query_arr['page'] = 1;
  605. $query = http_build_query($query_arr);
  606. return './index.php?' . $query;
  607. }
  608. function url_params($url) {
  609. $result = array();
  610. if (empty($url)) {
  611. return $result;
  612. }
  613. $components = parse_url($url);
  614. $params = explode('&',$components['query']);
  615. foreach ($params as $param) {
  616. if (!empty($param)) {
  617. $param_array = explode('=',$param);
  618. $result[$param_array[0]] = $param_array[1];
  619. }
  620. }
  621. return $result;
  622. }
  623. function frames_menu_append() {
  624. $system_menu_default_permission = array(
  625. 'founder' => array(),
  626. 'vice_founder' => array(
  627. 'system_setting_updatecache',
  628. ),
  629. 'owner' => array(
  630. 'system_setting_updatecache',
  631. ),
  632. 'manager' => array(
  633. 'system_setting_updatecache',
  634. ),
  635. 'operator' => array(
  636. 'system_setting_updatecache',
  637. ),
  638. 'clerk' => array(),
  639. 'expired' => array(
  640. 'system_setting_updatecache',
  641. )
  642. );
  643. return $system_menu_default_permission;
  644. }
  645. function site_profile_perfect_tips(){
  646. global $_W;
  647. if ($_W['isfounder'] && (empty($_W['setting']['site']) || empty($_W['setting']['site']['profile_perfect']))) {
  648. if (!defined('SITE_PROFILE_PERFECT_TIPS')) {
  649. $url = url('cloud/profile');
  650. return <<<EOF
  651. $(function() {
  652. var html =
  653. '<div class="we7-body-alert">'+
  654. '<div class="container">'+
  655. '<div class="alert alert-info">'+
  656. '<i class="wi wi-info-sign"></i>'+
  657. '<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true" class="wi wi-error-sign"></span><span class="sr-only">Close</span></button>'+
  658. // '<a href="{$url}" target="_blank">请尽快完善您在微擎云服务平台的站点注册信息。</a>'+
  659. '</div>'+
  660. '</div>'+
  661. '</div>';
  662. $('body').prepend(html);
  663. });
  664. EOF;
  665. define('SITE_PROFILE_PERFECT_TIPS', true);
  666. }
  667. }
  668. return '';
  669. }