Beispiel #1
0
 /**
  * 取得查询后的帖子的情况
  * @param:  &$id Database Connection
  * @param:  $id 论坛板块的id
  * @return; array
  * @acess:  public
  * @static
  */
 public static function &getCacheSubjectInfo(&$db, $pre_page, $offset_page, $q)
 {
     /*{{{*/
     $sql = 'select id, title, author, subject_status, express, is_best, click_number, reply_number,' . ' last_access_date from bbs_subject ' . $q . ' order by last_access_date desc';
     $info_array = array();
     $res = $db->CacheSelectLimit(1800, $sql, $pre_page, $offset_page);
     $now_user_id = UserUtil::getUserId($db, $_SESSION['user']['name']);
     while ($rows = $res->FetchRow()) {
         $user_id = UserUtil::getUserId($db, $rows['author']);
         //看状态。
         //==0, 开放
         //==1, 需要验证
         //==2, 帖子被关闭
         //如果被关闭,则不需看是否有新帖
         $status_image = 'no_topic.gif';
         if ($rows['subject_status'] == 2) {
             $status_image = 'topic_lock.gif';
         } else {
             if (!isset($_SESSION['user'])) {
                 $status_iamge = 'no_topic.gif';
             } else {
                 if (TopicUtil::haveNewReply($db, $rows['id'], $now_user_id)) {
                     $status_image = 'new_topic.gif';
                 } else {
                     $status_image = 'no_topic.gif';
                 }
             }
         }
         $last_user_name = '';
         $last_user_id = '';
         $total_page = 0;
         $find_number = 0;
         if ($rows['reply_number'] > 0) {
             $temp_sql = 'select author from bbs_reply where subject_id=? order by id desc ';
             $temp_res = $db->SelectLimit($temp_sql, 1, 0, array($rows['id']));
             $temp_rows = $temp_res->FetchRow();
             $last_user_name = $temp_rows['author'];
             $last_user_id = UserUtil::getUserId($db, $last_user_name);
             $temp_sql = 'select count(*) as num from bbs_reply where subject_id=?';
             $temp_sth = $db->Prepare($temp_sql);
             $temp_res = $db->Execute($temp_sth, array($rows['id']));
             $temp_rows = $temp_res->FetchRow();
             $total_number = $temp_rows['num'];
             $total_page = ceil(($total_number + 1) / 10);
             if ($total_page > 10) {
                 $find_number = ($total_number + 1) % 10;
             } else {
                 $find_number = $total_number + 1;
             }
         }
         $temp_sql = 'select count(*) as num from bbs_subject_attach where subject_id=?';
         $temp_sth = $db->Prepare($temp_sql);
         $temp_res = $db->Execute($temp_sth, array($rows['id']));
         $temp_rows = $temp_res->FetchRow();
         $is_have_attach = $temp_rows['num'];
         $title = "";
         if ($rows['is_best']) {
             $title .= "&nbsp;<font color=red>[" . LU_IS_BEST . "]</font>";
         }
         $title .= $rows['title'];
         $info_array[] = array('image' => $status_image, 'id' => $rows['id'], 'title' => $title, 'have_new_reply' => $status_image == 'new_topic.gif' ? 1 : 0, 'userid' => $user_id, 'username' => $rows['author'], 'clicks_number' => $rows['click_number'], 'reply_number' => $rows['reply_number'], 'last_time' => set_locale_time($rows['last_access_date']), 'last_username' => $last_user_name, 'last_userid' => $last_user_id, 'last_page' => $total_page, 'last_number' => $find_number, 'have_attach' => $is_have_attach, 'express' => $rows['express']);
     }
     return $info_array;
 }