123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- <?php
- /**
- * [WeEngine System] Copyright (c) 2014 WE7.CC
- * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
- */
- namespace We7\Table\Users;
- class Users extends \We7Table {
- protected $tableName = 'users';
- protected $primaryKey = 'uid';
- protected $field = array(
- 'owner_uid',
- 'groupid',
- 'username',
- 'password',
- 'salt',
- 'type',
- 'status',
- 'joindate',
- 'joinip',
- 'lastvisit',
- 'lastip',
- 'remark',
- 'starttime',
- 'endtime',
- 'founder_groupid',
- 'register_type',
- 'openid',
- 'welcome_link',
- 'notice_setting',
- );
- protected $default = array(
- 'owner_uid' => '0',
- 'groupid' => '0',
- 'username' => '',
- 'password' => '',
- 'salt' => '',
- 'type' => '1',
- 'status' => '2',
- 'joindate' => '0',
- 'joinip' => '',
- 'lastvisit' => '0',
- 'lastip' => '',
- 'remark' => '',
- 'starttime' => '0',
- 'endtime' => '0',
- 'founder_groupid' => '0',
- 'register_type' => '0',
- 'openid' => '0',
- 'welcome_link' => '',
- 'notice_setting' => '',
- );
- public function getNoticeSettingByUid($uid) {
- $notice_setting = iunserializer($this->where('uid', $uid)->getcolumn('notice_setting'));
- if (!is_array($notice_setting)) {
- $notice_setting = array();
- }
- return $notice_setting;
- }
- public function getUsersList() {
- return $this->query
- ->from('users', 'u')
- ->select(
- 'u.uid, u.owner_uid, u.groupid, u.username, u.type, u.status, u.joindate, u.joinip, u.lastvisit,
- u.lastip, u.remark, u.starttime, u.endtime, u.founder_groupid,u.register_type, u.openid, u.welcome_link,
- p.avatar as avatar, p.mobile as mobile, p.uid as puid, p.mobile as mobile'
- )
- ->leftjoin('users_profile', 'p')
- ->on(array('u.uid' => 'p.uid'))
- ->orderby('u.uid', 'DESC')
- ->getall('uid');
- }
- public function searchFounderOwnUsers($founder_uid) {
- $this->query
- ->innerjoin('users_founder_own_users', 'f')
- ->on(array('u.uid' => 'f.uid'))
- ->where('f.founder_uid', $founder_uid);
- return $this;
- }
- public function searchWithViceFounder() {
- global $_W;
- if (user_is_vice_founder()) {
- $this->query->where('u.owner_uid', $_W['uid']);
- }
- return $this;
- }
- public function searchWithStatus($status) {
- $this->query->where('u.status', $status);
- return $this;
- }
- public function searchWithType($type) {
- $this->query->where('u.type', $type);
- return $this;
- }
- public function searchWithFounder($founder_groupids) {
- $this->query->where('u.founder_groupid', $founder_groupids);
- return $this;
- }
- public function searchWithoutFounder()
- {
- return $this->query->where('u.founder_groupid !=', ACCOUNT_MANAGE_GROUP_FOUNDER);
- }
- public function searchWithTimelimitStatus($status) {
- if ($status == 1) {
- $this->where(function ($query) {
- $query->where('u.endtime', 0)->whereor('u.endtime >', TIMESTAMP);
- });
- } elseif ($status == 2) {
- $this->where('u.endtime !=', 0)->where('u.endtime <=', TIMESTAMP);
- }
- return $this;
- }
- public function searchWithEndtime($day) {
- $this->query->where('u.endtime !=', 0)->where('u.endtime <', TIMESTAMP + 86400 * $day);
- return $this;
- }
- public function searchWithMobile() {
- $this->query->where('p.mobile !=', '');
- return $this;
- }
- public function searchWithGroupId($group_id) {
- $this->query->where('u.groupid', $group_id);
- return $this;
- }
- public function searchWithSendStatus() {
- $this->query->where('p.send_expire_status', 0);
- return $this;
- }
- public function searchWithNameOrMobile($search) {
- $this->query->where('u.username LIKE', "%{$search}%")->whereor('p.mobile LIKE', "%{$search}%");
- return $this;
- }
- public function searchWithOwnerUid($owner_uid) {
- $this->query->where('u.owner_uid', $owner_uid);
- return $this;
- }
- public function userOrderBy($field = 'uid', $order = 'desc') {
- $field = !empty($field) ? $field : 'joindate';
- $order = !empty($order) ? $order : 'desc';
- $this->query->orderby($field, $order);
- return $this;
- }
- }
|