Permission.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. );
  17. protected $default = array(
  18. 'uniacid' => '',
  19. 'uid' => '',
  20. 'type' => '',
  21. 'permission' => '',
  22. 'url' => '',
  23. );
  24. public function getUserPermissionByType($uid, $uniacid, $type = '') {
  25. $this->query->where('uid', $uid)->where('uniacid', $uniacid);
  26. if (!empty($type)) {
  27. $this->query->where('type', $type);
  28. }
  29. $result = $this->query->get();
  30. if (!empty($result['permission'])) {
  31. $result['permission'] = explode('|', $result['permission']);
  32. }
  33. return $result;
  34. }
  35. public function getAllUserPermission($uid, $uniacid) {
  36. return $this->query->where('uid', $uid)
  37. ->where('uniacid', $uniacid)->getall('type');
  38. }
  39. public function getAllUserModulePermission($uid, $uniacid) {
  40. return $this->query->where('uid', $uid)
  41. ->where('uniacid', $uniacid)
  42. ->where('type !=', array(PERMISSION_ACCOUNT, PERMISSION_WXAPP, PERMISSION_WEBAPP, PERMISSION_PHONEAPP, PERMISSION_XZAPP, PERMISSION_ALIAPP, PERMISSION_BAIDUAPP, PERMISSION_TOUTIAOAPP, PERMISSION_SYSTEM))->getall('type');
  43. }
  44. public function getUserExtendPermission() {}
  45. public function getClerkPermission($module) {
  46. global $_W;
  47. 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');
  48. }
  49. }