人人商城

Permission.php 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. namespace We7\Table\Users;
  7. class Permission extends \We7Table {
  8. protected $tableName = 'users_permission';
  9. protected $primaryKey = 'id';
  10. protected $field = array(
  11. 'uniacid',
  12. 'uid',
  13. 'type',
  14. 'permission',
  15. 'url',
  16. 'modules',
  17. 'templates',
  18. );
  19. protected $default = array(
  20. 'uniacid' => '',
  21. 'uid' => '',
  22. 'type' => '',
  23. 'permission' => '',
  24. 'url' => '',
  25. 'modules' => '',
  26. 'templates' => '',
  27. );
  28. public function getUserPermissionByType($uid, $uniacid, $type = '') {
  29. $this->query->where('uid', $uid)->where('uniacid', $uniacid);
  30. if (!empty($type)) {
  31. $this->query->where('type', $type);
  32. }
  33. $result = $this->query->get();
  34. if (!empty($result['permission'])) {
  35. $result['permission'] = explode('|', $result['permission']);
  36. }
  37. return $result;
  38. }
  39. public function getAllUserPermission($uid, $uniacid) {
  40. return $this->query->where('uid', $uid)
  41. ->where('uniacid', $uniacid)->getall('type');
  42. }
  43. public function getAllUserModulePermission($uid, $uniacid) {
  44. return $this->query->where('uid', $uid)
  45. ->where('uniacid', $uniacid)
  46. ->where('type !=', array(PERMISSION_ACCOUNT, PERMISSION_WXAPP))->getall('type');
  47. }
  48. public function getUserExtendPermission() {}
  49. public function getClerkPermission($module) {
  50. global $_W;
  51. return $this->query->from('users_permission', 'p')->leftjoin('uni_account_users', 'u')->on(array('u.uid' => 'p.uid', 'u.uniacid' => 'p.uniacid'))->where('u.role', 'clerk')->where('p.type', $module)->where('u.uniacid', $_W['uniacid'])->getall('uid');
  52. }
  53. }