AccountUsers.php 1.5 KB

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. 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. 'createtime',
  16. );
  17. protected $default = array(
  18. 'uniacid' => '',
  19. 'uid' => '',
  20. 'role' => '',
  21. 'rank' => '0',
  22. 'createtime' => '',
  23. );
  24. public function searchWithUserRole($role) {
  25. return $this->query->where('role', $role);
  26. }
  27. public function getUsableAccountsByUid($uid) {
  28. return $this->query->where('uid', $uid)->getall('uniacid');
  29. }
  30. public function getOwnedAccountsByUid($uid) {
  31. return $this->query->where('uid', $uid)->where('role', ACCOUNT_MANAGE_NAME_OWNER)->getall('uniacid');
  32. }
  33. public function searchWithRole($role) {
  34. return $this->query->where('u.role', $role);
  35. }
  36. public function getCommonUserOwnAccountUniacids($uid) {
  37. return $this->query
  38. ->from('uni_account_users', 'u')
  39. ->select('u.uniacid, a.type')
  40. ->innerjoin('account', 'a')
  41. ->on(array('u.uniacid' => 'a.uniacid'))
  42. ->where('u.uid', $uid)
  43. ->getall('uniacid');
  44. }
  45. public function getAllUserRole($uid) {
  46. return $this->query->where('uid', $uid)->getall('role');
  47. }
  48. public function getUserRoleByUniacid($uid, $uniacid) {
  49. $info = $this->query->where(array('uid' => $uid, 'uniacid' => $uniacid))->get();
  50. return $info['role'];
  51. }
  52. }