/** * 获取审批吧主列表 * @access private * @param string $fid 贴吧id * @param string $is_pass 是否通过 * @return array */ private function getManagerPendList($fid, $is_pass) { $u = getTableName('users'); $fma = getTableName('forum_manager_apply'); if ($is_pass == 0) { $condition["{$fma}.is_pass"] = 0; } elseif ($is_pass == 1) { $condition["{$fma}.is_pass"] = array('neq', 0); } $condition["{$fma}.forum_id"] = $fid; $count = M('forum_manager_apply')->where($condition)->count(); $Pager = new \Tieba\Library\Pager($count, 20, 'active', true); $show = $Pager->show(); $info = M('forum_manager_apply')->field("{$u}.user_name,{$fma}.data_id,{$fma}.user_id,{$fma}.apply_date,{$fma}.apply_type,{$fma}.apply_content")->join("{$u} ON {$fma}.user_id = {$u}.user_id")->where($condition)->limit($Pager->firstRow . ',' . $Pager->listRows)->select(); foreach ($info as $key => $value) { $info[$key]['user_age'] = A('Home')->getAge($info[$key]['user_id']); $info[$key]['post_count'] = A('Home')->getPostCount($info[$key]['user_id']); $info[$key]['apply_type_cn'] = $info[$key]['apply_type'] == 0 ? '吧主' : '小吧主'; $info[$key]['user_level'] = A('Home')->getLevel($info[$key]['user_id'], $fid); } $array[0] = $info; $array[1] = $show; $array[2] = $count; $array[3] = $Pager->totalPages; return $array; }
/** * 获取精品列表 * @access private * @param string $uid 用户id * @return array */ private function getGoodList($uid) { $tt = getTableName('thread_type'); $t = getTableName('thread'); $l = getTableName('log'); $u = getTableName('users'); $f = getTableName('forum'); $condition["{$t}.user_id"] = $uid; $condition["{$tt}.thread_type"] = array('in', array('good', 'good,top')); $condition["{$l}.log_type"] = 'set-good'; $join1 = "{$tt} ON {$t}.thread_id = {$tt}.thread_id"; $join2 = "{$l} ON {$t}.thread_id = {$l}.object_id"; $count = M('thread')->join($join1)->join($join2)->where($condition)->count(); $Pager = new \Tieba\Library\Pager($count, 20, 'cur', false); $show = $Pager->show(); $info = M('thread')->field("{$t}.thread_id,{$t}.thread_title,{$t}.forum_id,{$f}.forum_name,{$l}.log_date,{$l}.user_id,{$u}.user_name")->join($join1)->join($join2)->join("{$f} ON {$t}.forum_id = {$f}.forum_id")->join("{$u} ON {$l}.user_id = {$u}.user_id")->where($condition)->group("{$l}.object_id")->order("{$l}.log_date desc")->limit($Pager->firstRow . ',' . $Pager->listRows)->select(); $array[0] = $info; $array[1] = $show; return $array; }
/** * 获取回复列表 * @access private * @param string $tid 帖子id * @param int $see_lz 是否只看楼主 * @return array */ private function getPostList($tid, $see_lz = 0) { $p = getTableName('post'); $t = getTableName('thread'); $u = getTableName('users'); $condition["{$p}.thread_id"] = $tid; $condition["{$p}.is_exist"] = 1; if ($see_lz == 1) { //先获得楼主的id $info_2 = M('thread')->field("user_id")->where(array('thread_id' => $tid))->find(); $thread_user_id = $info_2['user_id']; $condition["{$p}.user_id"] = $thread_user_id; } $count = M('post')->where($condition)->count(); $Pager = new \Tieba\Library\Pager($count, 30, 'tP', false); $show = $Pager->show(); //获取帖子所属的贴吧信息 $forum_info = $this->getForumInfoByTid($tid); $forum_id = $forum_info['forum_id']; $condition["{$t}.is_exist"] = 1; $info = M('post')->field("{$p}.post_id,{$p}.thread_id,{$p}.user_id,{$p}.post_content,{$p}.post_date,{$p}.reply_post_id,{$p}.floor_id,{$u}.user_name")->join("{$u} ON {$p}.user_id = {$u}.user_id")->join("{$t} ON {$p}.thread_id = {$t}.thread_id")->where($condition)->order('post_date')->limit($Pager->firstRow . ',' . $Pager->listRows)->select(); foreach ($info as $key => $value) { $info[$key]['reply_content'] = $this->getReply($info[$key]['reply_post_id']); $info[$key]['level_css'] = $this->getLevel($info[$key]['user_id'], $forum_id, 'css'); $info[$key]['level_level'] = $this->getLevel($info[$key]['user_id'], $forum_id, 'level'); $info[$key]['level_exp'] = $this->getLevel($info[$key]['user_id'], $forum_id, 'exp'); $info[$key]['post_content_convert'] = $this->convertPostContent($info[$key]['post_content']); $info[$key]['member_title'] = A('Forum')->getMemberTitle($forum_id, $info[$key]['level_level']); } $array[0] = $info; $array[1] = $show; $array[2] = $count; $array[3] = $Pager->totalPages; return $array; }
/** * 获取搜索结果列表 * @access private * @param string $fid 贴吧id * @param string $word 关键字 * @param string $order 排序方式 * @return array */ private function getSearchResultList($fid, $word, $order) { $f = getTableName('forum'); $p = getTableName('post'); $t = getTableName('thread'); $u = getTableName('users'); if ($fid != '') { $condition_is_forum = "AND {$t}.forum_id='{$fid}'"; } else { $condition_is_forum = ''; } switch ($order) { case '': $order = "post_date desc"; break; case 'date': $order = "post_date asc"; break; case 'thread': $condition_is_thread = "AND {$p}.floor_id=1"; $order = "post_date desc"; break; } $sql = "(SELECT tb_post.thread_id,tb_thread.thread_title,tb_post.post_content,tb_post.post_id,tb_post.post_date,tb_post.user_id,tb_forum.forum_name,tb_thread.forum_id,tb_users.user_name,tb_post.floor_id FROM `tb_post` INNER JOIN tb_thread ON tb_post.thread_id = tb_thread.thread_id INNER JOIN tb_forum ON tb_thread.forum_id = tb_forum.forum_id INNER JOIN tb_users ON tb_post.user_id = tb_users.user_id WHERE tb_post.post_content LIKE '%{$word}%' AND tb_post.is_exist = 1 {$condition_is_forum} {$condition_is_thread}) UNION (SELECT tb_post.thread_id,tb_thread.thread_title,tb_post.post_content,tb_post.post_id,tb_post.post_date,tb_post.user_id,tb_forum.forum_name,tb_thread.forum_id,tb_users.user_name,tb_post.floor_id FROM `tb_thread` INNER JOIN tb_post ON tb_post.thread_id = tb_thread.thread_id INNER JOIN tb_forum ON tb_thread.forum_id = tb_forum.forum_id INNER JOIN tb_users ON tb_post.user_id = tb_users.user_id WHERE tb_thread.thread_title LIKE '%{$word}%' AND tb_thread.is_exist = 1 AND tb_post.floor_id=1 {$condition_is_forum}) "; $count_array = M()->query($sql); $count = count($count_array); $Pager = new \Tieba\Library\Pager($count, 20, 'cur', false); $sql_end = "ORDER BY {$order} LIMIT {$Pager->firstRow},{$Pager->listRows}"; $show = $Pager->show(); //开始计时 $s_time = microtime(true); // $info = M('post')->field("{$p}.thread_id,{$t}.thread_title,{$p}.post_content,{$p}.post_id,{$p}.post_date,{$p}.user_id,{$f}.forum_name,{$t}.forum_id,{$u}.user_name,{$p}.floor_id")->join($join)->join("{$f} ON {$t}.forum_id = {$f}.forum_id")->join("{$u} ON {$p}.user_id = {$u}.user_id") // ->where($condition)->group("{$p}.post_id")->order($order)->limit($Pager->firstRow . ',' . $Pager->listRows)->select(); $info = M()->query($sql . $sql_end); foreach ($info as $key => $value) { $info[$key]['post_content_convert'] = $this->getThreadText($info[$key]['post_content'], 'post'); $info[$key]['post_content_convert'] = str_replace($word, '<em>' . $word . '</em>', $info[$key]['post_content_convert']); $info[$key]['thread_title_convert'] = str_replace($word, '<em>' . $word . '</em>', $info[$key]['thread_title']); } //结束计时 $e_time = microtime(true); $total_time = number_format($e_time - $s_time, 3); $array[0] = $info; $array[1] = $show; $array[2] = $count; $array[3] = $total_time; return $array; }