function doSearchTag($k) { global $ts; $keyinfo = M('tag')->where("tag_name='{$k}'")->find(); if ($keyinfo && $k) { $list = $this->where("tag_id=" . $keyinfo['tag_id'])->field('uid')->findPage(); $uids = getSubByKey($list['data'], 'uid'); /* * 缓存用户的资料, 粉丝数, 关注数, Tag列表 */ $user_model = D('User', 'home'); $user_count_model = model('UserCount'); $user_model->setUserObjectCache($uids); $user_count_model->setUserFollowerCount($uids); $user_count_model->setUserFollowingCount($uids); $this->setUserTagObjectCache($uids); foreach ($list['data'] as $k => $v) { $list['data'][$k]['user'] = $user_model->getUserByIdentifier($v['uid']); $list['data'][$k]['taglist'] = $this->getUserTagList($v['uid']); $list['data'][$k]['following'] = $user_count_model->getUserFollowingCount($v['uid']); $list['data'][$k]['follower'] = $user_count_model->getUserFollowerCount($v['uid']); $list['data'][$k]['followState'] = getFollowState($ts['user']['uid'], $v['uid']); } } else { $list['count'] = 0; } return $list; }
function doSearchTag($k) { global $ts; $keyinfo = M('tag')->where("tag_name='{$k}'")->find(); if ($keyinfo && $k) { $list = $this->where("tag_id=" . $keyinfo['tag_id'])->field('uid')->findpage(); foreach ($list['data'] as $k => $v) { $list['data'][$k]['user'] = M('user')->where('uid=' . $v['uid'])->field('location')->find(); $list['data'][$k]['taglist'] = $this->getUserTagList($v['uid']); $list['data'][$k]['following'] = M('weibo_follow')->where('uid=' . $v['uid'] . ' AND type=0')->count(); $list['data'][$k]['follower'] = M('weibo_follow')->where('fid=' . $v['uid'] . ' AND type=0')->count(); $list['data'][$k]['followState'] = getFollowState($ts['user']['uid'], $v['uid']); } } else { $list['count'] = 0; } return $list; }
function getPrivacy($mid, $uid) { if ($mid == $uid) { $data['weibo_comment'] = true; $data['message'] = true; $data['follow'] = true; return $data; } $isBackList = isBlackList($uid, $mid); $followState = getFollowState($uid, $mid) != 'unfollow'; $userset = $this->getUserSet($uid); if ($isBackList) { $data['weibo_comment'] = false; $data['message'] = false; $data['follow'] = false; $data['blacklist'] = true; } else { $data['weibo_comment'] = $userset['weibo_comment'] ? $followState : true; $data['message'] = $userset['message'] ? $followState : true; $data['follow'] = true; $data['blacklist'] = false; } return $data; }
function getPrivacy($mid, $uid) { if ($mid == $uid) { $data['weibo_comment'] = true; $data['message'] = true; $data['follow'] = true; return $data; } $isBackList = M('user_blacklist')->where("uid={$uid} AND fid={$mid}")->count() == 0 ? false : true; $followState = getFollowState($uid, $mid) != 'unfollow' ? true : false; $userset = $this->getUserSet($uid); if ($isBackList) { $data['weibo_comment'] = false; $data['message'] = false; $data['follow'] = false; $data['blacklist'] = true; } else { $data['weibo_comment'] = $userset['weibo_comment'] ? $followState : true; $data['message'] = $userset['message'] ? $followState : true; $data['follow'] = true; $data['blacklist'] = false; } return $data; }
public function hot_topics() { //热门话题榜 $data['hotTopic'] = D('Topic', 'weibo')->getHot(); //热门话题推荐 $re_topic_num = 3; if (count($data['hotTopic']) > $re_topic_num) { for ($i = 0; $i < $re_topic_num; $i++) { $data['re_hot_topic'][$i] = $data['hotTopic'][$i]; } } else { $data['re_hot_topic'] = $data['hotTopic']; } $uids = array(); foreach ($data['re_hot_topic'] as &$rh) { $rh['data'] = D('Operate', 'weibo')->where("content LIKE '%" . addslashes($rh['name']) . "%' AND isdel=0")->order('weibo_id DESC')->limit(3)->findAll(); $uids = array_merge($uids, getSubByKey($rh['data'], 'uid')); $rh['follow'] = getFollowState($this->mid, $rh, 1); if (is_array($rh['data'])) { $weibo_ids = getSubByKey($rh['data'], 'weibo_id'); foreach ($rh['data'] as &$v) { $v['is_favorited'] = D('Favorite', 'weibo')->isFavorited($v['weibo_id'], $this->mid, $weibo_ids); $v = D('Operate', 'weibo')->getOne('', $v); } } } D('User', 'home')->setUserObjectCache($uids); $this->assign($data); $this->setTitle(L('hot_topic')); $this->display(); }
//获取关注状态 function getState($uid, $fid, $type = 0) { return getFollowState($uid, $fid);
<?php return array('weibo_reply' => array('title' => '{actor} 回复了你的' . ($reply_type == 'weibo' ? '微博' : '评论'), 'body' => $content, 'other' => '<a href="' . U('home/space/detail', array('id' => $weibo_id)) . '" target="_blank">去看看</a>'), 'weibo_follow' => array('title' => '{actor} 关注了你', 'other' => '<span class="right" id="follow_list_' . $from . '"><script>document.write(followState(\'' . getFollowState($receive, $from) . '\',\'dolistfollow\',' . $from . '))</script></span><a href="' . U('home/space/index', array('uid' => $from)) . '" target="_blank">去TA空间</a>'), 'weibo_atme' => array('title' => '{actor} 在微博中提到了你', 'body' => '<a href="' . U('home/space/detail', array('id' => $weibo_id)) . '" target="_blank">' . $content . '</a>'));
function getUserInfo($uid, $uname, $mid, $status = false) { $data = array(); $uid = intval($uid); $user = null; if ($uid > 0) { $user = D('User', 'home')->getUserByIdentifier($uid, 'uid'); } else { if (!empty($uname)) { $user = D('User', 'home')->getUserByIdentifier($uname, 'uname'); } } if (!$user) { return false; } if ($uid != $mid) { $isBlack = D('UserPrivacy', 'home')->isInBlackList($uid, $mid); $data['isInBlackList'] = $isBlack ? 1 : 0; } $data['uid'] = $user['uid']; $data['uname'] = $user['uname']; $data['province'] = $user['province']; $data['city'] = $user['city']; $data['location'] = $user['location']; $data['face'] = getUserFace($user['uid']); $data['space'] = $user['domain'] ? U('home/Space/index', array('uid' => $user['domain'])) : U('home/Space/index', array('uid' => $user['uid'])); $data['sex'] = getSex($user['sex']); $data['weibo_count'] = model('UserCount')->getUserWeiboCount($user['uid']); $data['favorite_count'] = (int) M('weibo_favorite')->where('uid=' . $user['uid'])->count(); $data['followers_count'] = model('UserCount')->getUserFollowerCount($user['uid']); $data['followed_count'] = model('UserCount')->getUserFollowingCount($user['uid']); $data['is_followed'] = getFollowState($mid, $user['uid']); $data['is_verified'] = intval(M('user_verified')->getField('verified', "uid={$uid}")); if ($status) { $status = M('weibo')->where('uid=' . $user['uid'])->order('weibo_id DESC')->find(); $data['status'] = $status ? D('Weibo', 'weibo')->getOneApi('', $status) : ''; } return $data; }
function followuser() { if ($_POST) { if ($_POST['followuid']) { foreach ($_POST['followuid'] as $value) { D('Follow', 'weibo')->dofollow($this->mid, $value, 0); } } if ($_POST['doajax']) { echo '1'; } else { redirect(U('home/user/index')); } } else { //$data['commenduser'] = M('user')->where('is_active=1 AND is_init=1 AND uid<>'.$this->mid)->limit(12)->findall(); $data['commenduser'] = M()->query("SELECT fid,count(uid) as count FROM ts_weibo_follow WHERE fid NOT IN(SELECT fid FROM ts_weibo_follow WHERE uid={$this->mid} AND type=0) AND fid<>{$this->mid} AND type=0 GROUP BY fid ORDER by count(uid) DESC LIMIT 12"); foreach ($data['commenduser'] as $key => $value) { $data['commenduser'][$key] = M('user')->where('uid=' . $value['fid'])->find(); if (!$data['commenduser'][$key]['is_init']) { unset($data['commenduser'][$key]); continue; } $data['commenduser'][$key]['follower_count'] = $value['count']; $data['commenduser'][$key]['followstate'] = getFollowState($this->mid, $value['fid']); } $this->assign($data); $this->display(); } }
function searchUser($key, $mid, $since_id, $max_id, $count = 20, $page = 1) { $key = t($key); if (!$key) { return false; } $limit = ($page - 1) * $count . ',' . $count; $map = 'uid>0'; if ($since_id) { $map .= " AND uid > {$since_id}"; } elseif ($max_id) { $map .= " AND uid < {$max_id}"; } $list = $this->table(C('DB_PREFIX') . 'user')->where($map . " AND uname LIKE '%{$key}%'")->limit($limit)->findall(); foreach ($list as $k => $v) { $list[$k]['mini'] = M('weibo')->where('uid=' . $v['uid'] . ' AND type=0')->order('weibo_id DESC')->find(); $list[$k]['followed_count'] = M('weibo_follow')->where('uid=' . $v['uid'])->count(); $list[$k]['followers_count'] = M('weibo_follow')->where('fid=' . $v['uid'])->count(); $list[$k]['is_followed'] = getFollowState($mid, $v['uid']); $list[$k]['area'] = $v['location']; $list[$k]['face'] = getUserFace($v['uid']); } return $list; }
/** * __getblog * 获得blog列表 * @param int|array|string $uid uid * @access private * @return void */ private function __getBlog($uid = null, $field = null, $order = null, $limit = null) { //将数字或者数字型字符串转换成整型 is_numeric($uid) && ($uid = intval($uid)); //归档 if (isset($_GET['date'])) { return $this->fileAway($uid, $_GET['cateId']); } //分类 if (isset($_GET['cateId'])) { $this->blog->category = intval($_GET['cateId']); $this->assign('cateId', intval($_GET['cateId'])); } //给blog对象的uid属性赋值 if (isset($uid)) { $map['uid'] = $uid; if ($uid != $this->mid) { $relationship = getFollowState($uid, $this->mid); if ($relationship == 'eachfollow' || $relationship == 'havefollow') { $map['private'] = array('in', array(0, 2)); // } else if (model('Friend')->identifyFriend($this->uid, $this->mid) == FriendModel::ARE_FRIENDS) { // $map['private'] = array('in',array(0,5)); } else { $map['private'] = 0; } } } else { $gid = intval($_GET['gid']); // $friends = $this->api->friend_getGroupUids($gid); if (empty($friends)) { return false; } $map['uid'] = array("in", $friends); $this->blog->private = array('neq', 2); } if (!$limit) { } return $this->blog->getBlogList($map, $field, $order); }
public function voteUsers() { $id = intval($_POST["id"]); if (empty($id) || 0 == $id) { $this->error("非法访问投票情况"); exit; } $join = getConfig('join'); $vote_users = D('VoteUser')->where("vote_id = {$id} AND opts<>'' ")->order('id DESC')->findPage(8); foreach ($vote_users['data'] as &$value) { if (getFollowState($this->mid, $value['uid']) != 'unfollow') { $value['following'] = true; } else { if ($this->mid == $value['uid'] || $this->uid == $value['uid']) { $value['admin'] = true; } else { if ('following' === $join) { $value['Show'] = false; } else { $value['Show'] = true; } } } } $this->assign('vote_users', $vote_users); $this->display(); }
function show() { return getFollowState($this->mid, $this->user_id); }
function findfriend() { $data['type'] = $_GET['type'] ? $_GET['type'] : 'newjoin'; switch ($data['type']) { case 'followers': $data['list'] = M()->query("SELECT fid as uid,count(uid) as count FROM ts_weibo_follow WHERE fid NOT IN (SELECT fid FROM ts_weibo_follow WHERE uid={$this->mid} AND type=0) AND fid<>{$this->mid} AND type=0 GROUP BY fid ORDER by count(uid) DESC LIMIT 10"); foreach ($data['list'] as $key => $value) { $data['list'][$key] = M('user')->where('uid=' . $value['uid'])->field('uid,location,ctime')->find(); $data['list'][$key]['follower'] = $value['count']; $data['list'][$key]['followstate'] = getFollowState($this->mid, $value['uid']); } break; case 'hot': $data['list'] = M()->query("SELECT uid,count(weibo_id) as weibo_num FROM ts_weibo where uid NOT IN (SELECT fid FROM ts_weibo_follow WHERE uid={$this->mid} AND type=0) AND uid!={$this->mid} GROUP BY uid ORDER by count(weibo_id) DESC LIMIT 10"); foreach ($data['list'] as $key => $value) { $data['list'][$key] = M('user')->where('uid=' . $value['uid'])->field('uid,location,ctime')->find(); $data['list'][$key]['follower'] = M('weibo_follow')->where('fid=' . $value['uid'])->count(); $data['list'][$key]['weibo_num'] = $value['weibo_num']; $data['list'][$key]['followstate'] = getFollowState($this->mid, $value['uid']); } break; case 'understanding': $data['list'] = model('Friend')->getRelatedUser($this->mid, $max = 10); foreach ($data['list'] as $key => $value) { $data['list'][$key] = M('user')->where('uid=' . $value)->field('uid,location,ctime')->find(); $data['list'][$key]['follower'] = M('weibo_follow')->where('fid=' . $value)->count(); $data['list'][$key]['followstate'] = getFollowState($this->mid, $value); } break; case 'newjoin': $data['list'] = M("user")->where("is_active=1 AND is_init=1 AND uid NOT IN (SELECT fid FROM ts_weibo_follow WHERE uid={$this->mid}) AND uid!={$this->mid}")->order('uid DESC')->field('uid,location,ctime')->limit(10)->findall(); foreach ($data['list'] as $key => $value) { $data['list'][$key]['follower'] = M('weibo_follow')->where('fid=' . $value['uid'])->count(); $data['list'][$key]['followstate'] = getFollowState($this->mid, $value['uid']); } break; } $data['topfollow'] = M()->query("SELECT fid as uid,count(uid) as count FROM ts_weibo_follow GROUP BY fid ORDER by count(uid) DESC LIMIT 10"); $this->assign($data); $this->display(); }
public function home_space_middle($param) { $config = model('AddonData')->lget('space_app_show'); $uid = $param['uid']; if (model('App')->isAppExistForUser($uid, 'photo') && in_array('photo', $config['open'])) { if ($uid == $this->mid) { } else { if ('unfollow' == getFollowState($uid, $this->mid)) { $photo_map['privacy'] = 1; } else { $photo_map['privacy'] = array('IN', '1,2'); } } $photo_map['userId'] = $uid; $data['photo_list'] = D('Photo', 'photo')->where($photo_map)->order('id DESC')->limit(4)->findAll(); $data['photo_preview'] = model('Xdata')->get('photo:photo_preview'); } if ($data['photo_list']) { $this->assign($data); $this->display('photo'); } }
/** * checkRoll * 检查权限 * @param mixed $uid */ public function checkMember($eventAdmin, $opts, $mid) { $result = array('admin' => false, 'follow' => true, 'canJoin' => true, 'canAtt' => true, 'hasMember' => false); if ($mid == $eventAdmin) { $result['admin'] = true; $result['follow'] = false; $result['canJoin'] = false; $result['canAtt'] = false; return $result; } //如果是好友可以参加 if (1 == $opts['friend']) { if ('unfollow' == getFollowState($eventAdmin, $mid)) { $result['canJoin'] = false; $result['follow'] = false; } } return $result; }
/** * 显示一张图片 * @return void */ public function photo() { $uid = intval($_REQUEST['uid']); $aid = intval($_REQUEST['aid']); $id = intval($_REQUEST['id']); $type = t($_REQUEST['type']); // 图片来源类型,来自某相册,还是其它的 // 判断来源类型 if (!empty($type) && $type != 'mAll') { $this->error('错误的链接!'); } $this->assign('type', $type); // 获取所在相册信息 $albumDao = D('Album'); $album = $albumDao->find($aid); if (!$album) { $this->assign('jumpUrl', U('photo/Index/index')); $this->error('专辑不存在或已被删除!'); } // 获取图片信息 $photoDao = D('Photo'); $photo = $photoDao->where(" albumId={$aid} AND `id`={$id} AND userId={$uid} ")->find(); $this->assign('photo', $photo); // 验证图片信息是否正确 if (!$photo) { $this->assign('jumpUrl', U('photo/Index/album', array('uid' => $this->uid, 'id' => $aid))); $this->error('图片不存在或已被删除!'); } // 隐私控制 if ($this->mid != $album['userId']) { $relationship = getFollowState($this->mid, $this->uid); if ($album['privacy'] == 3) { $this->error('这个' . $this->appName . '的图片,只有主人自己可见。'); } else { if ($album['privacy'] == 2 && $relationship == 'unfollow') { $this->error('这个' . $this->appName . '的图片,只有主人的粉丝可见。'); } else { if ($album['privacy'] == 4) { $cookie_password = cookie('album_password_' . $album['id']); // 如果密码不正确,则需要输入密码 if ($cookie_password != md5($album['privacy_data'] . '_' . $album['id'] . '_' . $album['userId'] . '_' . $this->mid)) { $this->need_password($album, $id); exit; } } } } } $this->assign('album', $album); $this->assign('albumId', $album['id']); $this->assign('photoId', $id); // 获取所有图片数据 $photos = $albumDao->getPhotos($this->uid, $aid, '', '`order` DESC, `id` DESC', 0); // 获取上一页 下一页 和 预览图 if ($photos) { foreach ($photos as $v) { $photoIds[] = intval($v['id']); } $photoCount = count($photoIds); // 颠倒数组,取索引 $pindex = array_flip($photoIds); // 当前位置索引 $now_index = $pindex[$id]; // 上一张 $pre_index = $now_index - 1; if ($now_index <= 0) { $pre_index = $photoCount - 1; } $pre_photo = $photos[$pre_index]; // 下一张 $next_index = $now_index + 1; if ($now_index >= $photoCount - 1) { $next_index = 0; } $next_photo = $photos[$next_index]; // 预览图的位置索引 $start_index = $now_index - 2; if ($photoCount - $start_index < 5) { $start_index = $photoCount - 5; } if ($start_index < 0) { $start_index = 0; } // 取出预览图列表 最多5个 $preview_photos = array_slice($photos, $start_index, 5); } else { $this->error('图片列表数据错误!'); } // 点击率加1 $res = $photoDao->where("id={$id} AND albumId={$aid} AND userId={$this->uid}")->setInc('readCount'); //dump($res);dump($albumDao->getLastSql());exit; $this->assign('photoCount', $photoCount); $this->assign('now', $now_index + 1); $this->assign('pre', $pre_photo); $this->assign('next', $next_photo); $this->assign('previews', $preview_photos); unset($pindex); unset($photos); unset($album); unset($preview_photos); $this->setTitle(getUserName($this->uid) . '的图片:' . $photo['name']); $this->display(); }