示例#1
0
        public void GetLatestSkipValue_NoThreadFound_Returns0()
        {
            var threads = new ForumThreads();
            Assert.AreEqual(0, threads.GetLatestSkipValue(0,1));

        }
示例#2
0
        public void GetLatestSkipValue_ThreadFoundWith11PostsAndShow5_Returns10()
        {
            var threads = new ForumThreads();
            threads.Thread.Add(new ThreadSummary { ThreadId = 1, TotalPosts = 11 });
            Assert.AreEqual(10, threads.GetLatestSkipValue(1, 5));

        }
示例#3
0
        /// <summary>
        /// Used to process the current request.
        /// </summary>
        public override void ProcessRequest()
        {
            //get the parameters from the querystring
            GetQueryParameters();
            //Process any commands sent through querystring
            ProcessCommand();

            //Assemble page parts.
            //add topics
            if (InputContext.IsPreviewMode())
            {
                RootElement.AppendChild(ImportNode(InputContext.CurrentSite.GetPreviewTopicsXml(_creator)));
            }
            else
            {
                RootElement.AppendChild(ImportNode(InputContext.CurrentSite.GetTopicListXml()));
            }

            

            //add forumsource
            ForumSource forumSource = ForumSource.CreateForumSource(_cache, _creator, _viewingUser, _forumId, _threadId,
                                                                    InputContext.CurrentSite.SiteID,
                                                                    true, _ignoreCache, false);

            if (forumSource == null)
            {
                AddErrorXml("ForumOrThreadNotFound", "Unable to find the requested forum or thread.", null);
                return;
            }
            if (forumSource.Type == ForumSourceType.Redirect)
            {
//do redirect now
                AddDnaRedirect(((ForumSourceRedirect) forumSource).Url);
                return;
            }
            SerialiseAndAppend(forumSource, String.Empty);

            ForumThreads threads = new ForumThreads();
            //check for article ForumStyle - if 1 then dont include threads
            if (forumSource.Article != null && forumSource.Article.ForumStyle != 1)
            {
//dont add threads for forumstyle=1
                threads = ForumThreads.CreateForumThreads(_cache, _creator, InputContext.TheSiteList,
                                                                       _forumId,
                                                                       THREADSTOSHOW, _skip, _threadId, false,
                                                                       ThreadOrder.LatestPost, _viewingUser, _ignoreCache, false);
                SerialiseAndAppend(threads, String.Empty);
            }

            //get subscriptions
            SubscribeState subscribeState = SubscribeState.GetSubscriptionState(_creator,
                                                                                InputContext.ViewingUser.UserID,
                                                                                _threadId, _forumId);
            if (subscribeState != null)
            {
                SerialiseAndAppend(subscribeState, String.Empty);
            }

            if (_latest)
            {
                _skip = threads.GetLatestSkipValue(_threadId, POSTSTOSHOW);
            }

            //add threadposts if required
            if (_threadId > 0 || (forumSource.Article != null && forumSource.Article.ForumStyle == 1))
            {
//get the thread
                ProcessThreadPosts(subscribeState);
                //add online users
                OnlineUsers users = OnlineUsers.GetOnlineUsers(_creator, _cache, OnlineUsersOrderBy.None,
                                                               InputContext.CurrentSite.SiteID, true, _ignoreCache);
                SerialiseAndAppend(users, String.Empty);
            }


            //add page ui to xml
            PageUi pageUi = PageUi.GetPageUi(_creator, forumSource.Article, _viewingUser);
            SerialiseAndAppend(pageUi, String.Empty);
            
        }