AccountUsers.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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\Uni;
  7. class AccountUsers extends \We7Table {
  8. protected $tableName = 'uni_account_users';
  9. protected $primaryKey = 'id';
  10. protected $field = array(
  11. 'uniacid',
  12. 'uid',
  13. 'role',
  14. 'rank',
  15. );
  16. protected $default = array(
  17. 'uniacid' => '',
  18. 'uid' => '',
  19. 'role' => '',
  20. 'rank' => '0',
  21. );
  22. public function searchWithUserRole($role) {
  23. return $this->query->where('role', $role);
  24. }
  25. public function getUsableAccountsByUid($uid) {
  26. return $this->query->where('uid', $uid)->where('role !=', ACCOUNT_MANAGE_NAME_CLERK)->getall('uniacid');
  27. }
  28. public function getOwnedAccountsByUid($uid) {
  29. return $this->query->where('uid', $uid)->where('role', ACCOUNT_MANAGE_NAME_OWNER)->getall('uniacid');
  30. }
  31. public function searchWithRole($role) {
  32. return $this->query->where('u.role', $role);
  33. }
  34. public function getCommonUserOwnAccountUniacids($uid) {
  35. return $this->query
  36. ->from('uni_account_users', 'u')
  37. ->select('u.uniacid, a.type')
  38. ->innerjoin('account', 'a')
  39. ->on(array('u.uniacid' => 'a.uniacid'))
  40. ->where('u.uid', $uid)
  41. ->getall('uniacid');
  42. }
  43. public function getAllUserRole($uid) {
  44. return $this->query->where('uid', $uid)->getall('role');
  45. }
  46. public function getUserRoleByUniacid($uid, $uniacid) {
  47. $info = $this->query->where(array('uid' => $uid, 'uniacid' => $uniacid))->get();
  48. return $info['role'];
  49. }
  50. public function getUidByUniacidAndRole($uniacid, $role) {
  51. $data = $this->where('uniacid', $uniacid)->where('role', $role)->get();
  52. return empty($data['uid']) ? 0 : $data['uid'];
  53. }
  54. public function searchWithUsers() {
  55. return $this->query->from($this->tableName, 'a')
  56. ->leftjoin('users', 'b')
  57. ->on('a.uid', 'b.uid');
  58. }
  59. }