人人商城

desk.ctrl.php 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. $dos = array();
  8. $do = in_array($do, $dos) ? $do : 'index';
  9. $_W['page']['title'] = '店员工作台';
  10. if($do == 'index') {
  11. $clerk_p = pdo_fetchall("SELECT * FROM ". tablename('activity_clerk_menu'). " WHERE (uniacid = :uniacid OR system = '1') AND pid = 0", array(':uniacid' => $_W['uniacid']));
  12. $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']));
  13. $permission = array();
  14. foreach ($clerk_p as $p) {
  15. $permission[$p['id']]['id'] = $p['id'];
  16. $permission[$p['id']]['pid'] = $p['id'];
  17. $permission[$p['id']]['title'] = $p['title'];
  18. $permission[$p['id']]['system'] = $p['system'];
  19. }
  20. foreach ($clerk_c as $c) {
  21. if (empty($c['permission'])) {
  22. pdo_update('activity_clerk_menu', array('permission' => 'clerk_'.$c['id']), array('uniacid' => $_W['uniacid'], 'id' => $c['id']));
  23. }
  24. $permission[$c['pid']]['items'][] = $c;
  25. }
  26. $user_permission = uni_user_permission_exist ();
  27. if (is_error ($user_permission)) {
  28. $user_permission = uni_user_permission ('system');
  29. $permission_list = array();
  30. foreach ($user_permission as $value) {
  31. if (!is_numeric($value)) {
  32. continue;
  33. }
  34. $clerk_perm = pdo_get('activity_clerk_menu', array('uniacid' => $_W['uniacid'], 'id' => $value));
  35. $permission_list[] = $clerk_perm['permission'];
  36. }
  37. if (!empty($permission_list)) {
  38. $post = implode('|', $permission_list);
  39. pdo_update('users_permission', array('permission' => $post), array('uniacid' => $_W['uniacid'], 'uid' => $_W['uid'], 'type' => 'system'));
  40. }
  41. foreach ($permission as $key => &$row) {
  42. $has = 0;
  43. foreach ($row['items'] as $key1 => &$row1) {
  44. if (!in_array ($row1['permission'], $user_permission)) {
  45. unset($row['items'][$key1]);
  46. } else {
  47. if (!$has) {
  48. $has = 1;
  49. }
  50. }
  51. }
  52. if (!$has) {
  53. unset($permission[$key]);
  54. }
  55. }
  56. }
  57. }
  58. template('activity/desk');