users.table.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. class UsersTable extends We7Table {
  8. public function searchUsersList() {
  9. global $_W;
  10. $this->query->from('users', 'u')
  11. ->select('u.*, p.avatar as avatar, p.mobile as mobile, p.uid as puid')
  12. ->leftjoin('users_profile', 'p')
  13. ->on(array('u.uid' => 'p.uid'))
  14. ->orderby('u.uid', 'DESC');
  15. if (user_is_vice_founder()) {
  16. $this->query->where('u.owner_uid', $_W['uid']);
  17. }
  18. return $this->query->getall();
  19. }
  20. public function userOwnedAccount($uid) {
  21. $uniacid_list = $this->query->from('uni_account_users')->where('uid', $uid)->getall('uniacid');
  22. return array_keys($uniacid_list);
  23. }
  24. public function userOwnedAccountRole($uid, $uniacid = 0) {
  25. if (empty($uniacid)) {
  26. $role = $this->query->from('uni_account_users')->where('uid', $uid)->getall('role');
  27. return array_keys($role);
  28. } else {
  29. $role = $this->query->from('uni_account_users')->where(array('uid' => $uid, 'uniacid' => $uniacid))->get();
  30. return $role['role'];
  31. }
  32. }
  33. public function userPermission($uid, $uniacid) {
  34. return $this->query->from('users_permission')->where('uid', $uid)->where('uniacid', $uniacid)->getall('type');
  35. }
  36. public function searchWithStatus($status) {
  37. $this->query->where('u.status', $status);
  38. return $this;
  39. }
  40. public function searchWithType($type) {
  41. $this->query->where('u.type', $type);
  42. return $this;
  43. }
  44. public function searchWithFounder($founder_groupids) {
  45. $this->query->where('u.founder_groupid', $founder_groupids);
  46. return $this;
  47. }
  48. public function searchWithEndtime($day) {
  49. $this->query->where('u.endtime !=', 0)->where('u.endtime <', TIMESTAMP + 86400 * $day);
  50. return $this;
  51. }
  52. public function searchWithMobile() {
  53. $this->query->where('p.mobile !=', '');;
  54. return $this;
  55. }
  56. public function searchWithSendStatus() {
  57. $this->query->where('p.send_expire_status', 0);;
  58. return $this;
  59. }
  60. public function searchWithName($user_name) {
  61. $this->query->where('u.username LIKE', "%{$user_name}%");
  62. return $this;
  63. }
  64. public function searchWithOwnerUid($owner_uid) {
  65. $this->query->where('u.owner_uid', $owner_uid);
  66. return $this;
  67. }
  68. public function accountUsersNum($uid) {
  69. return $this->query->from('uni_account_users')->where('uid', $uid)->count();
  70. }
  71. public function usersGroup() {
  72. return $this->query->from('users_group')->getall('id');
  73. }
  74. public function usersGroupInfo($groupid) {
  75. return $this->query->from('users_group')->where('id', $groupid)->get();
  76. }
  77. public function usersInfo($uid) {
  78. return $this->query->from('users')->where('uid', $uid)->get();
  79. }
  80. public function usersFounderGroup() {
  81. return $this->query->from('users_founder_group')->getall('id');
  82. }
  83. public function userPermissionInfo($uid, $uniacid, $type = '') {
  84. $condition = array('uid' => $uid, 'uniacid' => $uniacid);
  85. if (!empty($type)) {
  86. $condition['type'] = $type;
  87. }
  88. return $this->query->from('users_permission')->where($condition)->get();
  89. }
  90. public function userModulesPermission($uid, $uniacid) {
  91. $condition = array(
  92. 'uid'=> $uid,
  93. 'uniacid' => $uniacid,
  94. 'type !=' => array(PERMISSION_ACCOUNT, PERMISSION_WXAPP),
  95. );
  96. return $this->query->from('users_permission')->where($condition)->getall('type');
  97. }
  98. public function userFounderGroupInfo($groupid) {
  99. return $this->query->from('users_founder_group')->where('id', $groupid)->get();
  100. }
  101. public function userProfileMobile($mobile) {
  102. return $this->query->from('users_profile')->where('mobile', $mobile)->get();
  103. }
  104. public function userVerifyCode($receiver, $verifycode) {
  105. return $this->query->from('uni_verifycode')->where('receiver', $receiver)->where('verifycode', $verifycode)->where('uniacid', 0)->get();
  106. }
  107. public function userBindInfo($bind_sign, $third_type) {
  108. return $this->query->from('users_bind')->where('bind_sign', $bind_sign)->where('third_type', $third_type)->get();
  109. }
  110. public function userProfileFields() {
  111. return $this->query->from('profile_fields')->where('available', 1)->where('showinregister', 1)->orderby('displayorder', 'desc')->getall('field');
  112. }
  113. public function userBind() {
  114. return $this->query->from('users_bind')->getall('bind_sign');
  115. }
  116. public function bindSearchWithUser($uid) {
  117. $this->query->where('uid', $uid);
  118. return $this;
  119. }
  120. public function bindSearchWithType($type) {
  121. $this->query->where('third_type', $type);
  122. return $this;
  123. }
  124. public function bindInfo() {
  125. return $this->query->from('users_bind')->get();
  126. }
  127. public function userProfile($uid) {
  128. return $this->query->from('users_profile')->where('uid', $uid)->get();
  129. }
  130. public function userAccountRole($role) {
  131. $this->query->where('role', $role);
  132. return $this;
  133. }
  134. public function userAccountDelete($uid, $is_recycle = false) {
  135. if (!empty($is_recycle)) {
  136. pdo_update('users', array('status' => USER_STATUS_BAN) , array('uid' => $uid));
  137. return true;
  138. }
  139. $user_info = $this->usersInfo($uid);
  140. if ($user_info['founder_groupid'] == ACCOUNT_MANAGE_GROUP_VICE_FOUNDER) {
  141. pdo_update('users', array('owner_uid' => ACCOUNT_NO_OWNER_UID), array('owner_uid' => $uid));
  142. pdo_update('users_group', array('owner_uid' => ACCOUNT_NO_OWNER_UID), array('owner_uid' => $uid));
  143. pdo_update('uni_group', array('owner_uid' => ACCOUNT_NO_OWNER_UID), array('owner_uid' => $uid));
  144. }
  145. pdo_delete('users', array('uid' => $uid));
  146. pdo_delete('uni_account_users', array('uid' => $uid));
  147. pdo_delete('users_profile', array('uid' => $uid));
  148. pdo_delete('users_bind', array('uid' => $uid));
  149. return true;
  150. }
  151. }