Exemplo n.º 1
0
 /**
  * 取得论坛板块的信息
  * @param:  NULL
  * @return: array
  * @access: private
  */
 private function &getBBSLayout()
 {
     $bbs_layout = array();
     $bbs_layout_id = LayoutUtil::getLayoutInfoByParentId($this->db);
     foreach ($bbs_layout_id as $rows) {
         $bbs_id = $rows['id'];
         $bbs_title = $rows['title'];
         //查询二级子论坛
         $sub_bbs_layout_id = LayoutUtil::getLayoutInfoByParentId($this->db, $bbs_id);
         $sub_array = array();
         foreach ($sub_bbs_layout_id as $sub_rows) {
             $sub_id = $sub_rows['id'];
             //注意:$sub_bbs_id是一个数组
             $sub_bbs_id = array();
             LayoutUtil::getChildId($this->db, $sub_id, $sub_bbs_id);
             array_push($sub_bbs_id, $sub_id);
             /**
              * 如果已经将论坛锁住,则不判断是否有新帖
              */
             /**
              *  $layout_status == 0 || $layout_status is null 则为开放
              *  $layout_status == 1 则需要验证
              *  $layout_status == 2 则为关闭
              */
             $layout_status = LayoutUtil::getLayoutStatus($this->db, $sub_id);
             /**
              * 判断是否有新帖子
              * 判断有新帖子的流程是:
              * 如果用户已经登录,则找出用户的作后动作的时间
              * 如果用户没有登录,则显示没有新帖子
              */
             $image = 'nonewtopic.gif';
             if ($layout_status == 2) {
                 $image = 'lock.gif';
             } else {
                 if (LayoutUtil::isClosedbyParent($this->db, $sub_id)) {
                     $image = 'lock.gif';
                 } else {
                     if (isset($_SESSION['user'])) {
                         if (LayoutUtil::haveNewTopic($this->db, $_SESSION['user']['name'], $sub_bbs_id)) {
                             /**
                              * 求出最后时间后,需要我们找出当前子论坛下各个子论坛的id
                              */
                             $image = 'havenewtopic.gif';
                         }
                     }
                 }
             }
             //求出论坛及子论坛下面的查看的人数
             $view_number = LayoutUtil::getViewNumber($this->db, $sub_bbs_id);
             //求出论坛和子论坛下的所有的主题
             $topic_number = LayoutUtil::getTopicNumber($this->db, $sub_bbs_id);
             //求出论坛下所有的回复数
             $reply_number = LayoutUtil::getReplyNumber($this->db, $sub_bbs_id);
             //求论坛里最后发表的帖子
             $temp_rows = LayoutUtil::getLastPostTopic($this->db, $sub_id);
             $last_id = $temp_rows['id'];
             $last_title = $temp_rows['title'];
             $last_time = $temp_rows['last_access_date'];
             $last_time = set_locale_time($last_time);
             $short_title = utf8_substr($last_title, 0, 10);
             //求版主列表的字符串
             $manager_list_array = LayoutUtil::getManagerList($this->db, $sub_id);
             $manager_str = "";
             foreach ($manager_list_array as $temp_rows) {
                 $manager_str .= "<option value=" . $temp_rows['user_id'] . ">";
                 $manager_str .= $temp_rows['user_name'] . "</option>\n";
             }
             $sub_array[] = array('id' => $sub_rows['id'], 'title' => $sub_rows['title'], 'content' => ConvertString(stripslashes($sub_rows['description']), ROOT_URL, IMAGE_URL . 'express/'), 'image' => $image, 'viewnumber' => $view_number, 'topic_number' => $topic_number, 'reply_number' => $reply_number, 'topicid' => $last_id, 'topic_title' => $last_title, 'short_title' => $short_title, 'last_time' => $last_time, 'managerlist' => $manager_str);
         }
         $bbs_layout[] = array('id' => $bbs_id, 'title' => $bbs_title, 'subbbs' => $sub_array);
     }
     return $bbs_layout;
 }