人人商城

deskmenu.ctrl.php 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. uni_user_permission_check('profile_deskmenu');
  8. $_W['page']['title'] = '功能选项 - 公众号选项 - 工作台菜单设置';
  9. $dos = array('index', 'addmenu');
  10. $do = in_array($do, $dos) ? $do : 'index';
  11. if($do == 'index') {
  12. $clerk_p = pdo_fetchall("SELECT * FROM ". tablename('activity_clerk_menu'). " WHERE (uniacid = :uniacid OR system = '1') AND pid = 0", array(':uniacid' => $_W['uniacid']));
  13. $clerk_c = pdo_fetchall("SELECT * FROM ". tablename('activity_clerk_menu'). " WHERE (uniacid = :uniacid OR system = '1') AND pid <> 0 ORDER BY displayorder ASC, system DESC", array(':uniacid' => $_W['uniacid']));
  14. $permission = array();
  15. foreach ($clerk_p as $p) {
  16. $permission[$p['id']]['id'] = $p['id'];
  17. $permission[$p['id']]['pid'] = $p['id'];
  18. $permission[$p['id']]['title'] = $p['title'];
  19. $permission[$p['id']]['system'] = $p['system'];
  20. }
  21. foreach ($clerk_c as $c) {
  22. if (empty($c['permission'])) {
  23. pdo_update('activity_clerk_menu', array('permission' => 'clerk_'.$c['id']), array('uniacid' => $_W['uniacid'], 'id' => $c['id']));
  24. }
  25. $permission[$c['pid']]['items'][] = $c;
  26. }
  27. $user_permission = uni_user_permission_exist ();
  28. if (is_error ($user_permission)) {
  29. $user_permission = uni_user_permission ('system');
  30. foreach ($permission as $key => &$row) {
  31. $has = 0;
  32. foreach ($row['items'] as $key1 => &$row1) {
  33. if (!in_array ($row1['id'], $user_permission)) {
  34. unset($row['items'][$key1]);
  35. } else {
  36. if (!$has) {
  37. $has = 1;
  38. }
  39. }
  40. }
  41. if (!$has) {
  42. unset($permission[$key]);
  43. }
  44. }
  45. }
  46. }
  47. if ($_W['isajax']) {
  48. $post = array();
  49. $post['title'] = trim($_GPC['title']);
  50. $post['displayorder'] = intval($_GPC['displayorder']);
  51. $post['icon'] = trim($_GPC['icon']) == '' ? 'glyphicon glyphicon-th' : trim($_GPC['icon']);
  52. $post['url'] = trim($_GPC['url']);
  53. $op = $_GPC['op'];
  54. if ($op == 'edit') {
  55. if (!empty($_GPC['permission'])) {
  56. $post['permission'] = trim($_GPC['permission']);
  57. }
  58. if (pdo_update('activity_clerk_menu', $post, array('uniacid' => $_W['uniacid'], 'id' => $_GPC['id']))) {
  59. message(error(1, '编辑成功'), '', 'ajax');
  60. } else {
  61. message(error(0, '编辑失败'), '', 'ajax');
  62. }
  63. }
  64. if ($op == 'editmain') {
  65. $post = array();
  66. $post['title'] = $_GPC['title'];
  67. if (pdo_update('activity_clerk_menu', $post, array('uniacid' => $_W['uniacid'], 'id' => $_GPC['id']))) {
  68. message(error(1, '编辑成功'), '', 'ajax');
  69. }
  70. }
  71. if ($op == 'add') {
  72. if (!empty($_GPC['permission'])) {
  73. $post['permission'] = trim($_GPC['permission']);
  74. }
  75. $post['system'] = 0;
  76. $post['pid'] = $_GPC['pid'];
  77. $post['uniacid'] = $_W['uniacid'];
  78. $post['type'] = 'url';
  79. if (pdo_insert('activity_clerk_menu', $post)) {
  80. message(error(1, '添加子菜单成功'), '', 'ajax');
  81. } else {
  82. message(error(0, '添加子菜单失败'), '', 'ajax');
  83. }
  84. }
  85. if ($op == 'addmain') {
  86. $post = array();
  87. $post['system'] = 0;
  88. $post['title'] = $_GPC['main_title'];
  89. $post['uniacid'] = $_W['uniacid'];
  90. if (pdo_insert('activity_clerk_menu', $post)) {
  91. message(error(1, '添加主菜单成功'), '', 'ajax');
  92. } else {
  93. message(error(0, '添加主菜单失败'), '', 'ajax');
  94. }
  95. }
  96. if ($op == 'delete') {
  97. $id = $_GPC['id'];
  98. $type = $_GPC['type'];
  99. if (empty($type)) {
  100. if (pdo_delete('activity_clerk_menu', array('id' => $id, 'uniacid' => $_W['uniacid']))) {
  101. message(error('1', '删除成功'), '' , 'ajax');
  102. }
  103. else {
  104. message(error('0', '删除失败'), '' , 'ajax');
  105. }
  106. } else {
  107. $result = pdo_delete('activity_clerk_menu', array('id' => $id, 'uniacid' => $_W['uniacid']));
  108. $resultall = pdo_delete('activity_clerk_menu', array('pid' => $id, 'uniacid' => $_W['uniacid']));
  109. if ($result && $resultall) {
  110. message(error('1', '删除成功'), '' , 'ajax');
  111. } else {
  112. message(error('0', '删除失败'), '' , 'ajax');
  113. }
  114. }
  115. }
  116. }
  117. template('profile/deskmenu');