人人商城

common.func.php 26KB

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