search(array('ids' => $yes)); } if (!$keyword) { $where['limit'] = '0,10'; $data = Dever::db($table)->search($where); } else { $where['search'] = $keyword; $data = Dever::db($table)->search($where); } $result = array(); if ($yes) { foreach ($yes as $k => $v) { if (isset($data[$k])) { unset($data[$k]); } $yes[$k]['selected'] = true; } $data = $yes + $data; $data = array_merge($data, array()); } else { $data = array_merge($data, array()); } if (!$data) { Dever::alert('暂无数据'); } return $data; } public function get($uid) { $info = array(); if ($uid < 100000000) { $info = Dever::db('manage/admin')->find($uid); if ($info) { $info['name'] = $info['username']; $info['area_string'] = ''; $info['avatar'] = ''; $info['aname'] = $info['name'] . ($info['mobile'] ? '('.$info['mobile'].')' : ''); } } else { $info = Dever::db('user/info')->find($uid); if ($info) { if (isset($info['area']) && $info['area']) { $info['area_string'] = Dever::load('area/api')->string($info['area']); } if (!$info['avatar'] && $info['avatar_id'] > 0) { $avatar = Dever::db('user/avatar')->one($info['avatar_id']); if ($avatar) { $info['avatar'] = $avatar['avatar']; } } $info['aname'] = $info['name'] . '('.$info['mobile'].')'; } } return $info; } /** * 设置项目 * * @return mixed */ public function setProject($uid, $project) { $where['uid'] = $uid; $where['project_id'] = $project; $one = Dever::db('user/user_project')->find($where); if (!$one) { Dever::db('user/user_project')->insert($where); } } /** * 获取加密信息 * * @return mixed */ public function getSign($uid, $data = array()) { $data['signature'] = Dever::login($uid); return $data; } /** * 检测用户有效性 * * @return mixed */ public function check($state = true, $name = 'signature') { $signature = Dever::input($name); $user = Dever::checkLogin($signature, $state); if ($state && !isset($user['uid'])) { Dever::alert('user error'); } if (isset($user['uid']) && $user['uid']) { return $user['uid']; } return -1; } # 更新 public function update($uid, $name, $avatar, $sex) { $info = Dever::db('user/info')->find($uid); if ($info) { $update['username'] = $name; $update['avatar'] = $avatar; $update['sex'] = $sex; $update['where_id'] = $uid; Dever::db('user/info')->update($update); } else { Dever::alert('无效的用户id,请重新登录'); } $result = Dever::db('user/info')->one(array('id' => $uid, 'clear' => true)); return $this->getSign($uid, $result); } }