예제 #1
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            //点击了快速发帖按钮
            if (_Request.IsClick("postButton"))
            {
                ProcessThread();
            }

            ForumBO.Instance.SetForumsLastThread(Forum.SubForumsForList);

            int totalThreads = 0;

            int pageSize = AllSettings.Current.BbsSettings.ThreadsPageSize;

            if (_Request.IsSpider)
            {
                if (ThreadCatalogID != -1)
                {
                    m_ThreadCatalogID = -1;
                }

                if (Action != "list")
                {
                    m_Action = "list";
                }
            }

            //如果要显示某个主题分类的主题
            if (ThreadCatalogID != -1)
            {
                AddNavigationItem(Forum.ForumName, BbsUrlHelper.GetForumUrl(CodeName));

                Action = "";
                if (ThreadCatalogID != 0)
                {
                    ThreadCatalog threadCatalog = ForumBO.Instance.GetThreadCatalog(ThreadCatalogID);
                    if (threadCatalog == null)
                    {
                        Response.End();
                    }

                    AddNavigationItem(string.Concat("[", threadCatalog.ThreadCatalogName, "]"));
                    //navigation += "  [" + threadCatalog.ThreadCatalogName + "]";
                }
                else
                {
                    AddNavigationItem("[其他]");
                }
                //navigation += "    [其他]";


                threads = PostBOV5.Instance.GetThreads(ForumID, ThreadCatalogID, PageNumber, pageSize, SortType, BeginDate, EndDate, IsDesc, out totalThreads);

                //设置分页控件的显示
                SetPager("ThreadListPager", BbsUrlHelper.GetThreadCatalogUrlForPager(CodeName, ThreadCatalogID) + (parms == null ? "" : "?" + parms), PageNumber, pageSize, totalThreads);
                //url = BbsUrlHelper.GetForumEmoticonUrlForPager(CodeName, ThreadCatalogID, PageNumber, IsGetAllDefaultEmoticon, EmoticonGroupID);
            }
            else
            {
                string navigation = null;

                switch (Action)
                {
                //精华帖
                case "valued":

                    navigation = "[精华帖]";
                    threads    = PostBOV5.Instance.GetValuedThreads(ForumID, PageNumber, pageSize, SortType, BeginDate, EndDate, IsDesc, true, out totalThreads);

                    break;

                //投票帖
                case "poll":

                    navigation = "[投票帖]";
                    threads    = PostBOV5.Instance.GetThreads(ForumID, ThreadType.Poll, PageNumber, pageSize, SortType, BeginDate, EndDate, IsDesc, true, out totalThreads);
                    break;

                //问题帖
                case "question":

                    navigation = "[提问帖]";
                    threads    = PostBOV5.Instance.GetThreads(ForumID, ThreadType.Question, PageNumber, pageSize, SortType, BeginDate, EndDate, IsDesc, true, out totalThreads);
                    break;

                //辩论帖
                case "polemize":

                    navigation = "[辩论帖]";
                    threads    = PostBOV5.Instance.GetThreads(ForumID, ThreadType.Polemize, PageNumber, pageSize, SortType, BeginDate, EndDate, IsDesc, true, out totalThreads);
                    break;

                //回收
                case "recycled":

                    IsNormalThreads = false;
                    IsRecycleBin    = true;
                    navigation      = "[回收站]";
                    if (ForumManagePermission.HasPermissionForSomeone(My, ManageForumPermissionSetNode.ActionWithTarget.SetThreadsRecycled) == false)
                    {
                        ShowError("您没有权限进入回收站");
                    }
                    threads = PostBOV5.Instance.GetThreadsByStatus(ThreadStatus.Recycled, ForumID, SortType, BeginDate, EndDate, IsDesc, PageNumber, pageSize, out totalThreads);
                    break;

                //未审核主题
                case "unapproved":

                    IsNormalThreads     = false;
                    IsUnapprovedThreads = true;
                    navigation          = "[未审核主题]";
                    if (ForumManagePermission.HasPermissionForSomeone(My, ManageForumPermissionSetNode.ActionWithTarget.ApproveThreads) == false)
                    {
                        ShowError("您没有权限查看未审核的主题");
                    }

                    threads = PostBOV5.Instance.GetThreadsByStatus(ThreadStatus.UnApproved, ForumID, SortType, BeginDate, EndDate, IsDesc, PageNumber, pageSize, out totalThreads);
                    break;

                //未审核回复
                case "unapprovedpost":

                    IsNormalThreads          = false;
                    IsUnapprovedPostsThreads = true;
                    navigation = "[未审核回复]";
                    if (ForumManagePermission.Can(My, ManageForumPermissionSetNode.Action.ApprovePosts) == false)
                    {
                        ShowError("您没有权限查看未审核的回复");
                    }
                    threads      = PostBOV5.Instance.GetUnapprovedPostThreads(ForumID, PageNumber, pageSize);
                    totalThreads = threads.TotalRecords;
                    break;

                //正常帖子
                default:

                    IsDefaultList = true;
                    Action        = "list";
                    threads       = PostBOV5.Instance.GetThreads(ForumID, SortType, BeginDate, EndDate, IsDesc, PageNumber, pageSize, _Request.IsSpider, out totalThreads);
                    break;
                }

                if (navigation == null)
                {
                    AddNavigationItem(Forum.ForumName);
                }
                else
                {
                    AddNavigationItem(Forum.ForumName, BbsUrlHelper.GetForumUrl(CodeName));
                    AddNavigationItem(navigation);
                }

                //设置分页控件的显示
                SetPager("ThreadListPager", BbsUrlHelper.GetForumUrlForPager(CodeName, Action) + (parms == null ? "" : "?" + parms), PageNumber, pageSize, totalThreads);
                //url = BbsUrlHelper.GetForumEmoticonUrlForPager(CodeName, Action, PageNumber, IsGetAllDefaultEmoticon, EmoticonGroupID);
            }

            if (PageNumber > 1 && threads.Count == 0)
            {
                Response.Redirect(AttachQueryString("page=1"));
            }


            //更新用户在在线列表中的状态
            UpdateOnlineStatus(OnlineAction.ViewThreadList, 0, "");
            //OnlineManager.UpdateOnlineUser(MyUserID, ForumID, 0, My.OnlineStatus, OnlineAction.ViewThreadList, Request, Response);

            if (IsNormalThreads)
            {
                PostBOV5.Instance.ProcessKeyword(threads, ProcessKeywordMode.TryUpdateKeyword);
            }
            else
            {
                PostBOV5.Instance.ProcessKeyword(threads, ProcessKeywordMode.FillOriginalText);
            }

            if (CanManageThread)
            {
                List <int> userIDs = new List <int>();
                foreach (BasicThread thread in threads)
                {
                    if (userIDs.Contains(thread.PostUserID) == false)
                    {
                        userIDs.Add(thread.PostUserID);
                    }
                }

                UserBO.Instance.GetUsers(userIDs, GetUserOption.WithAll);
            }

            WaitForFillSimpleUsers <Moderator>(Forum.Moderators);
            foreach (Forum subForum in Forum.SubForumsForList)
            {
                WaitForFillSimpleUsers <Moderator>(subForum.Moderators);
            }

            SubmitFillUsers();
        }