users.table.php 5.6 KB

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