Example #1
0
 public override void OnPreRender()
 {
     // Get search results that will be rendered and the total number of search results
     _forumSearchInfoCollection = ForumDB.GetForumSearchResults(_searchTerms, ForumID, ForumUtils.GetPostsPerPage(), _searchPage);
     if (_forumSearchInfoCollection.Count > 0)
     {
         _postsCount = ((ForumSearchInfo)_forumSearchInfoCollection[0]).RecordCount;
     }
 }
Example #2
0
        private int AddNew(ForumPost forumPost)
        {
            if (_pinnedDropDownList == null)
            {
                return(ForumDB.AddPost(forumPost, ForumID));
            }

            DateTime pinnedDate;

            GetPinnedInfo(out pinnedDate);

            return(ForumDB.AddPostPinned(forumPost, ForumID, pinnedDate));
        }
Example #3
0
        private void EditPost(ForumPost forumPost)
        {
            if (_pinnedDropDownList == null)
            {
                ForumDB.UpdatePost(forumPost);
                return;
            }

            DateTime pinnedDate;

            GetPinnedInfo(out pinnedDate);

            ForumDB.UpdatePostPinned(forumPost, pinnedDate);
        }
Example #4
0
        private int AddReply(ForumPost forumPost)
        {
            // Add reply
            int postID = ForumDB.AddPost(forumPost, ForumID);

            // Check to see whether author of parent post should be notified
            ForumPost parentForumPost = ForumDB.GetPost(forumPost.ParentPostID);

            // Send e-mail
            if (parentForumPost.Notify && parentForumPost.User.UserID != forumPost.User.UserID)
            {
                EmailReplyNotification(parentForumPost, forumPost);
            }

            // Return identifier of newly created post
            return(postID);
        }
Example #5
0
        private bool PostCanBePinned()
        {
            if (!Page.User.IsInRole("ForumAdmin"))
            {
                return(false);
            }

            if (_action == "new")
            {
                return(true);
            }

            if (_action == "edit" && _postID == ForumDB.GetThreadFromPost(_postID))
            {
                return(true);
            }

            return(false);
        }
Example #6
0
        private void RenderFooter(HtmlTextWriter writer)
        {
            // Start the footer row
            writer.AddAttribute(HtmlTextWriterAttribute.Height, "25");
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);
            writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "2");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);

            // Into which we will put a table that will contain
            writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Width, "100%");
            writer.RenderBeginTag(HtmlTextWriterTag.Table);

            // On the left hand side: Page x of y
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);
            writer.AddAttribute(HtmlTextWriterAttribute.Align, "left");
            writer.AddAttribute(HtmlTextWriterAttribute.Width, "50%");
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "Normal");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);

            // Page x of y text
            int pageCount = ((ForumDB.GetThreadRepliesCount(_threadID)) / ForumUtils.GetPostsPerPage()) + 1;

            writer.RenderBeginTag(HtmlTextWriterTag.B);
            writer.Write(string.Format(" Page {0} of {1}", _threadPage + 1, pageCount));
            writer.RenderEndTag();              // B
            writer.RenderEndTag();              // Td

            // And on the right hand side, render thread navigation (<< < Previous | Next > >>)
            RenderThreadPaging(writer, pageCount);

            // Close out this table and row
            writer.RenderEndTag();              // Tr
            writer.RenderEndTag();              // Table
            writer.RenderEndTag();              // Td
            writer.RenderEndTag();              // Tr
        }
Example #7
0
        public override void OnPreRender()
        {
            // Determine whether we are in flat view or tree view mode.  This setting is
            // stored in a cookie, but should probably be moved in to the user's profile
            // which is stored in the database.
            if (!_viewDropDownSelected)
            {
                _forumView = ForumUtils.GetForumView(Page);
            }
            ListItem listItem = _viewDropDownList.Items.FindByValue(_forumView.ToString());

            if (listItem != null)
            {
                listItem.Selected = true;
            }

            // _threadID identifies the thread we are currently viewing.  _postID identifies
            // the post within the thread that is currently being shown. (i.e. in tree view,
            // only one post can be viewed at a time).  _threadID can be obtained from the value
            // of _postID.  We will also determine what page we are looking at.
            _threadID   = ForumDB.GetThreadFromPost(_postID);
            _threadPage = ForumDB.GetSortOrderFromPost(_postID, _forumView) / ForumUtils.GetPostsPerPage();

            // If looking at the first post in a thread, then increment the thread view count
            if (_threadID == _postID)
            {
                ForumDB.IncrementThreadViews(_threadID);
            }

            // Get page of posts that will be rendered
            _forumPostCollection = ForumDB.GetThread(_threadID, _threadPage, ForumUtils.GetPostsPerPage(), _forumView);

            // Register javascript for dynamically showing threads in tree view
            if (_forumView == ForumUtils.ForumView.TreeViewDynamic)
            {
                RegisterJavascript();
            }
        }
Example #8
0
        public void Render(HtmlTextWriter writer, int threadsPerPage, DateTime lastVisited, Page page, string images, string document, int postsPerPage, ForumUtils.ForumView forumView)
        {
            // Start row
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);

            // Render thread image.  If the total number of posts in this thread is great than the
            // number of posts that can be displayed on one page, then we display a special image that
            // indicates this thread is "on fire".
            int totalPosts = (int)Replies + 1;

            writer.AddAttribute(HtmlTextWriterAttribute.Class, "WebSolutionRow");
            writer.AddAttribute(HtmlTextWriterAttribute.Width, "25");
            writer.AddAttribute(HtmlTextWriterAttribute.Valign, "middle");
            writer.AddAttribute(HtmlTextWriterAttribute.Align, "center");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            if (totalPosts > threadsPerPage)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Src, images + "board_thread_fire.gif");
            }
            else
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Src, images + "board_thread.gif");
            }
            writer.RenderBeginTag(HtmlTextWriterTag.Img);
            writer.RenderEndTag();              // Img
            writer.RenderEndTag();              // Td

            // Thread subject with link (and indicate whether or not this thread is pinned)
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "WebSolutionRow");
            writer.AddAttribute(HtmlTextWriterAttribute.Valign, "middle");
            writer.AddAttribute(HtmlTextWriterAttribute.Valign, "left");
            writer.AddAttribute(HtmlTextWriterAttribute.Height, "25");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "Normal");
            writer.RenderBeginTag(HtmlTextWriterTag.Span);
            if (PinnedDate > DateTime.Now)
            {
                writer.RenderBeginTag(HtmlTextWriterTag.B);
                writer.Write("Sticky: ");
                writer.RenderEndTag();                  // B
            }
            writer.AddAttribute(HtmlTextWriterAttribute.Href, WebSolutionUtils.GetURL(document, page, string.Format("postid={0}", ThreadID), "forumaction=&searchpage=&threadspage=") + string.Format("#{0}", ThreadID));
            writer.RenderBeginTag(HtmlTextWriterTag.A);
            ForumText subjectForumText = new ForumText(Subject);

            writer.Write(subjectForumText.ProcessSingleLine(images));
            writer.RenderEndTag();              // A

            // If thread spans several pages, then we need to indicate this in the thread list
            // by displaying text like (Page 1, 2, 3, ..., 5)
            if (totalPosts > threadsPerPage)
            {
                writer.Write(" (Page: ");
                int  pageCount       = ((totalPosts - 1) / threadsPerPage) + 1;
                int  pageCountCapped = Math.Min(pageCount, 4);
                bool showFinalPage   = (pageCountCapped < pageCount);
                for (int threadPage = 0; threadPage < pageCountCapped; threadPage++)
                {
                    int postID = ForumDB.GetPostFromThreadAndPage(ThreadID, threadPage, postsPerPage, forumView);
                    writer.AddAttribute(HtmlTextWriterAttribute.Href, WebSolutionUtils.GetURL(document, page, string.Format("postid={0}", postID), "forumaction=&searchpage=&threadspage="));
                    writer.RenderBeginTag(HtmlTextWriterTag.A);
                    writer.Write(string.Format("{0}", threadPage + 1));
                    writer.RenderEndTag();                      // A
                    if ((threadPage < pageCountCapped - 1) || showFinalPage)
                    {
                        writer.Write(", ");
                    }
                }
                if (showFinalPage)
                {
                    if (pageCount > 5)
                    {
                        writer.Write("..., ");
                    }
                    int postID = ForumDB.GetPostFromThreadAndPage(ThreadID, pageCount - 1, postsPerPage, forumView);
                    writer.AddAttribute(HtmlTextWriterAttribute.Href, WebSolutionUtils.GetURL(document, page, string.Format("postid={0}", postID), "forumaction=&searchpage=&threadspage="));
                    writer.RenderBeginTag(HtmlTextWriterTag.A);
                    writer.Write(pageCount.ToString());
                    writer.RenderEndTag();                      // A
                }
                writer.Write(")");
            }

            // Display new image if this thread is new since last time user visited
            if (lastVisited < _dateLastPost)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Src, images + "new.gif");
                writer.RenderBeginTag(HtmlTextWriterTag.Img);
                writer.RenderEndTag();
            }
            writer.RenderEndTag();              // Span
            writer.RenderEndTag();              // Td

            // Started by
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "WebSolutionRowHighlight");
            writer.AddAttribute(HtmlTextWriterAttribute.Align, "center");
            writer.AddAttribute(HtmlTextWriterAttribute.Width, "100");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "Normal");
            writer.RenderBeginTag(HtmlTextWriterTag.Span);
            ForumText startedByAliasForumText = new ForumText(StartedByAlias);

            writer.Write(startedByAliasForumText.ProcessSingleLine(images));
            writer.RenderEndTag();              // Span
            writer.RenderEndTag();              // Td

            // Replies
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "WebSolutionRowHighlight");
            writer.AddAttribute(HtmlTextWriterAttribute.Align, "center");
            writer.AddAttribute(HtmlTextWriterAttribute.Width, "50");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "Normal");
            writer.RenderBeginTag(HtmlTextWriterTag.Span);
            writer.Write(Replies);
            writer.RenderEndTag();              // Span
            writer.RenderEndTag();              // Td

            // Views
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "WebSolutionRowHighlight");
            writer.AddAttribute(HtmlTextWriterAttribute.Align, "center");
            writer.AddAttribute(HtmlTextWriterAttribute.Width, "50");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "Normal");
            writer.RenderBeginTag(HtmlTextWriterTag.Span);
            writer.Write(Views);
            writer.RenderEndTag();              // Span
            writer.RenderEndTag();              // Td

            // Last Post
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "WebSolutionRowHighlight");
            writer.AddAttribute(HtmlTextWriterAttribute.Align, "center");
            writer.AddAttribute(HtmlTextWriterAttribute.Width, "140");
            writer.AddAttribute(HtmlTextWriterAttribute.Nowrap, "nowrap");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "Normal");
            writer.RenderBeginTag(HtmlTextWriterTag.Span);
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "WebSolutionSmallerFont");
            writer.RenderBeginTag(HtmlTextWriterTag.Span);
            writer.Write(DateLastPost.ToString("dd MMM yy"));
            writer.Write("&nbsp;");
            writer.Write(DateLastPost.ToString("t"));
            writer.Write("<BR>");
            ForumText lastPostAliasForumText = new ForumText(LastPostAlias);

            writer.Write(lastPostAliasForumText.ProcessSingleLine(images));
            writer.Write("&nbsp;");
            writer.AddAttribute(HtmlTextWriterAttribute.Href, WebSolutionUtils.GetURL(document, page, string.Format("postid={0}", LastPostID), "forumaction=&searchpage=&threadspage=") + string.Format("#{0}", LastPostID));
            writer.RenderBeginTag(HtmlTextWriterTag.A);
            writer.AddAttribute(HtmlTextWriterAttribute.Src, images + "last_post.gif");
            writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
            writer.RenderBeginTag(HtmlTextWriterTag.Img);
            writer.RenderEndTag();              // Img
            writer.RenderEndTag();              // A
            writer.RenderEndTag();              // Span
            writer.RenderEndTag();              // Span
            writer.RenderEndTag();              // Td

            // End row
            writer.RenderEndTag();              // Tr
        }
Example #9
0
 public override void OnPreRender()
 {
     // Get threads that will be rendered and the total number of forum threads
     _forumThreadInfoCollection = ForumDB.GetThreads(ForumID, _threadsPerPage, _threadsPage);
     _threadCount = ForumDB.GetThreadCount(ForumID);
 }
Example #10
0
        private void PopulateUnits()
        {
            if (_action == "new" || _action == "reply" || _action == "quote")
            {
                ForumText aliasForumText = new ForumText(UserDB.GetUser(_userID).Alias);
                _nameLabel.Text = aliasForumText.ProcessSingleLine(GetImages());
            }

            if (_action == "edit" || _action == "reply" || _action == "quote")
            {
                _forumPost = ForumDB.GetPost(_postID);

                if (_action == "edit")
                {
                    if (LoggedOnUserID != _forumPost.User.UserID && !Page.User.IsInRole("ForumAdmin"))
                    {
                        RedirectUserHasNoAuthority();
                    }

                    ForumText postAliasForumText = new ForumText(_forumPost.User.Alias);
                    _nameLabel.Text         = postAliasForumText.ProcessSingleLine(GetImages());
                    _subjectTextBox.Text    = _forumPost.Subject;
                    _bodyTextBox.Text       = _forumPost.Body;
                    _notifyCheckBox.Checked = _forumPost.Notify;
                }
                else
                {
                    // If action is quote or reply, make sure subject begins "Re:"
                    string subject      = _forumPost.Subject;
                    string replySubject = subject;
                    if (replySubject.Length >= 3)
                    {
                        if (replySubject.Substring(0, 3) != "Re:")
                        {
                            replySubject = "Re: " + replySubject;
                        }
                    }
                    else
                    {
                        replySubject = "Re: " + replySubject;
                    }
                    _subjectTextBox.Text = replySubject;

                    // If action is quote, add message being replied to within QUOTE tags
                    if (_action == "quote")
                    {
                        ForumText forumText = new ForumText(_forumPost.Body);
                        _bodyTextBox.Text = forumText.ProcessQuoteBody(_forumPost.User.Alias);
                    }
                }
            }

            if (_pinnedDropDownList != null && !Page.IsPostBack)
            {
                _pinnedDropDownList.Items.Add(new ListItem("Not Sticky", "0"));
                _pinnedDropDownList.Items.Add(new ListItem("1 Day", "1"));
                _pinnedDropDownList.Items.Add(new ListItem("3 Days", "3"));
                _pinnedDropDownList.Items.Add(new ListItem("1 Week", "7"));
                _pinnedDropDownList.Items.Add(new ListItem("2 Weeks", "14"));
                _pinnedDropDownList.Items.Add(new ListItem("1 Month", "30"));
                _pinnedDropDownList.Items.Add(new ListItem("3 Months", "90"));
                _pinnedDropDownList.Items.Add(new ListItem("6 Months", "180"));
                _pinnedDropDownList.Items.Add(new ListItem("1 Year", "365"));
                _pinnedDropDownList.Items.Add(new ListItem("3 Years", "1095"));
            }
        }
Example #11
0
        private void RenderThreadPaging(HtmlTextWriter writer, int pageCount)
        {
            // Start the new column
            writer.AddAttribute(HtmlTextWriterAttribute.Align, "right");
            writer.AddAttribute(HtmlTextWriterAttribute.Width, "50%");
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "Normal");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);

            // First, previous, next, last thread hyperlinks
            bool backwards = _threadPage != 0;
            bool forwards  = _threadPage != pageCount - 1;

            // << First and < Previous links
            if (backwards)
            {
                int postID = 0;

                // << First
                postID = _threadID;
                writer.AddAttribute(HtmlTextWriterAttribute.Href, WebSolutionUtils.GetURL(GetDocument(), Page, string.Format("postid={0}", postID), "forumaction="));
                writer.RenderBeginTag(HtmlTextWriterTag.A);
                writer.Write("&lt;&lt;");
                writer.RenderEndTag();                  // A
                writer.Write("&nbsp;");

                // < Previous
                postID = ForumDB.GetPostFromThreadAndPage(_threadID, _threadPage - 1, ForumUtils.GetPostsPerPage(), _forumView);
                writer.AddAttribute(HtmlTextWriterAttribute.Href, WebSolutionUtils.GetURL(GetDocument(), Page, string.Format("postid={0}", postID), "forumaction="));
                writer.RenderBeginTag(HtmlTextWriterTag.A);
                writer.Write("&lt;&nbsp;Previous");
                writer.RenderEndTag();                  // A
            }

            // Divider
            if (backwards && forwards)
            {
                writer.Write("&nbsp;|&nbsp;");
            }

            // Next > and Last >> links
            if (forwards)
            {
                int postID = 0;

                // Next >
                postID = ForumDB.GetPostFromThreadAndPage(_threadID, _threadPage + 1, ForumUtils.GetPostsPerPage(), _forumView);
                writer.AddAttribute(HtmlTextWriterAttribute.Href, WebSolutionUtils.GetURL(GetDocument(), Page, string.Format("postid={0}", postID), "forumaction="));
                writer.RenderBeginTag(HtmlTextWriterTag.A);
                writer.Write("Next&nbsp;&gt;");
                writer.RenderEndTag();
                writer.Write("&nbsp;");

                // Last >>
                postID = ForumDB.GetPostFromThreadAndPage(_threadID, pageCount - 1, ForumUtils.GetPostsPerPage(), _forumView);
                writer.AddAttribute(HtmlTextWriterAttribute.Href, WebSolutionUtils.GetURL(GetDocument(), Page, string.Format("postid={0}", postID), "forumaction="));
                writer.RenderBeginTag(HtmlTextWriterTag.A);
                writer.Write("&gt;&gt;");
                writer.RenderEndTag();
            }

            // Close column
            writer.Write("&nbsp;");
            writer.RenderEndTag();              // Td
        }