private void GetSearchResults()
        {
            // Get the paging variable
            int?p = null;

            if (Request.QueryString["p"] != null)
            {
                p = Convert.ToInt32(Request.QueryString["p"]);
            }

            // Get the search variable
            string s = null;

            if (Request.QueryString["s"] != null)
            {
                s = Request.QueryString["s"];
            }

            if (s != null)
            {
                // Strip out any nasties from the term
                var searchterm = Helpers.SafePlainText(s).ToLower();

                // Get the posts that contain the search
                var posts = Factory.SearchPosts(searchterm).Select(x => x.ParentId);

                // Now get topics the posts are in
                var maintopics = from t in Factory.ReturnAllTopics(true)
                                 where posts.Contains(t.Id)
                                 select t;

                // Pass to my pager helper
                var pagedResults = new PaginatedList <ForumTopic>(maintopics, p ?? 0, Helpers.MainForumSettings().TopicsPerPage);

                // Decide whether to show pager or not
                if (pagedResults.TotalPages > 1)
                {
                    litPager.Text = pagedResults.ReturnPager();
                }

                // Now bind
                rptTopicList.DataSource = pagedResults;
                rptTopicList.DataBind();
            }
            else
            {
                topiclist.Visible = false;
            }
        }
        private void GetSearchResults()
        {
            // Get the paging variable
            int? p = null;
            if (Request.QueryString["p"] != null)
                p = Convert.ToInt32(Request.QueryString["p"]);

            // Get the search variable
            string s = null;
            if (Request.QueryString["s"] != null)
                s = Request.QueryString["s"];

            if(s != null)
            {
                // Strip out any nasties from the term
                var searchterm = Helpers.SafePlainText(s).ToLower();

                // Get the posts that contain the search
                var posts = Factory.SearchPosts(searchterm).Select(x => x.ParentId);

                // Now get topics the posts are in
                var maintopics = from t in Factory.ReturnAllTopics(true)
                                 where posts.Contains(t.Id)
                                 select t;

                // Pass to my pager helper
                var pagedResults = new PaginatedList<ForumTopic>(maintopics, p ?? 0, Helpers.MainForumSettings().TopicsPerPage);

                // Decide whether to show pager or not
                if (pagedResults.TotalPages > 1)
                {
                    litPager.Text = pagedResults.ReturnPager();
                }

                // Now bind
                rptTopicList.DataSource = pagedResults;
                rptTopicList.DataBind();
            }
            else
            {
                topiclist.Visible = false;
            }
        }
Example #3
0
        /// <summary>
        /// Gets the topics and returns them in a pager
        /// </summary>
        private void GetTopicPosts()
        {
            // Get the paging variable
            if (Request.QueryString["p"] != null)
            {
                p = Convert.ToInt32(Request.QueryString["p"]);
            }

            // Before anything see if the category has been marked as private, if so make sure user is loggged in
            var parentCategory = Mapper.MapForumCategory(new Node(ParentTopic.CategoryId));
            var userHasAccess  = true;

            if (MembershipHelper.IsAuthenticated())
            {
                // Member is logged in so it doesn't matter if forum is private or not,
                // now check they have enough karma to view this category and hide if not
                if (CurrentMember.MemberKarmaAmount < parentCategory.KarmaAccessAmount)
                {
                    userHasAccess = false;
                }

                // check user has enough karma to be able to post in this category
                if (CurrentMember.MemberKarmaAmount < parentCategory.KarmaPostAmount)
                {
                    lvNewPost.Visible = false;
                }
            }
            else
            {
                if (parentCategory.IsPrivate)
                {
                    userHasAccess = false;
                }
            }
            // Check to see if user has access
            if (!userHasAccess)
            {
                Response.Redirect(string.Concat(Settings.Url, "?m=", library.GetDictionaryItem("NoPermissionToViewPage")));
            }

            //Get all the posts
            var useNodeFactory = Request.QueryString["nf"] != null;
            var topicposts     = Factory.ReturnAllPostsInTopic(ParentTopic.Id, useNodeFactory);

            var starterPost = topicposts.SingleOrDefault(tp => tp.IsTopicStarter);

            if (starterPost == null)
            {
                return;
            }

            // Pass to my pager helper
            var pagedResults = new PaginatedList <ForumPost>(topicposts, p ?? 0, Convert.ToInt32(Settings.PostsPerPage));

            // Decide whether to show pager or not
            if (pagedResults.TotalPages > 1)
            {
                pnlPager.Visible = true;
                litPager.Text    = pagedResults.ReturnPager();
            }

            rprDiscussionPosts.DataSource = pagedResults;
            rprDiscussionPosts.DataBind();

            var mDesc           = Factory.ReturnTopicStarterPost(ParentTopic.Id).Content;
            var metaDescription = new HtmlMeta
            {
                Name    = "description",
                Content = library.TruncateString(library.StripHtml(mDesc), 300, "...")
            };

            Page.Header.Controls.Add(metaDescription);
        }
Example #4
0
        /// <summary>
        /// Gets all the topics from the parent category
        /// </summary>
        private void GetTopicsFromCategory()
        {
            // Before anything see if the category has been marked as private, if so make sure user is loggged in
            var currentCategory = Mapper.MapForumCategory(CurrentNode);
            var userHasAccess   = true;

            if (MembershipHelper.IsAuthenticated())
            {
                // Member is logged in so it doesn't matter if forum is private or not,
                // now check they have enough karma to view this category and hide if not
                if (CurrentMember.MemberKarmaAmount < currentCategory.KarmaAccessAmount)
                {
                    userHasAccess = false;
                }

                // Double check they have enough karma to post a topic
                if (CurrentMember.MemberKarmaAmount < currentCategory.KarmaPostAmount)
                {
                    hlCreateTopic.Visible = false;
                }
            }
            else
            {
                if (currentCategory.IsPrivate)
                {
                    userHasAccess = false;
                }
            }

            // Check to see if user has access
            if (!userHasAccess)
            {
                Response.Redirect(string.Concat(Settings.Url, "?m=", library.GetDictionaryItem("NoPermissionToViewPage")));
            }


            // First get title and description
            litHeading.Text = currentCategory.Name;
            var fDescription = currentCategory.Description;

            litDescription.Text = fDescription;
            // Set the meta description
            var metaDescription = new HtmlMeta
            {
                Name    = "description",
                Content = library.StripHtml(fDescription)
            };

            Page.Header.Controls.Add(metaDescription);

            // Get the paging variable
            int?p = null;

            if (Request.QueryString["p"] != null)
            {
                p = Convert.ToInt32(Request.QueryString["p"]);
            }

            // Set cache variables
            var useNodeFactory = Request.QueryString["nf"] != null;
            var maintopics     = from t in Factory.ReturnAllTopicsInCategory(CurrentNode.Id, true, useNodeFactory)
                                 where !t.IsSticky
                                 select t;

            // Pass to my pager helper
            var pagedResults = new PaginatedList <ForumTopic>(maintopics, p ?? 0, Convert.ToInt32(Settings.TopicsPerPage));

            // Decide whether to show pager or not
            if (pagedResults.TotalPages > 1)
            {
                litPager.Text = pagedResults.ReturnPager();
            }

            // Now bind
            rptTopicList.DataSource = pagedResults;
            rptTopicList.DataBind();
        }
        /// <summary>
        /// Gets all the topics from the parent category
        /// </summary>
        private void GetTopicsFromCategory()
        {
            // Before anything see if the category has been marked as private, if so make sure user is loggged in
            var currentCategory = Mapper.MapForumCategory(CurrentNode);
            var userHasAccess = true;
            if (MembershipHelper.IsAuthenticated())
            {
                // Member is logged in so it doesn't matter if forum is private or not,
                // now check they have enough karma to view this category and hide if not
                if (CurrentMember.MemberKarmaAmount < currentCategory.KarmaAccessAmount)
                {
                    userHasAccess = false;
                }
            }
            else
            {
                if (currentCategory.IsPrivate)
                {
                    userHasAccess = false;
                }
            }

            // Check to see if user has access
            if(!userHasAccess)
            {
                Response.Redirect(string.Concat(Settings.Url, "?m=", library.GetDictionaryItem("NoPermissionToViewPage")));
            }

            // Get the paging variable
            int? p = null;
            if (Request.QueryString["p"] != null)
                p = Convert.ToInt32(Request.QueryString["p"]);

            // Set cache variables
            var useNodeFactory = Request.QueryString["nf"] != null;
            var maintopics = from t in Factory.ReturnAllTopicsInCategory(CurrentNode.Id, true, useNodeFactory)
                             where !t.IsSticky
                             select t;

            if(!ShowAll)
            {
                maintopics = maintopics.Take(2);
                btnShowAll.Visible = true;
            }

            // Pass to my pager helper
            var pagedResults = new PaginatedList<ForumTopic>(maintopics, p ?? 0, Convert.ToInt32(Settings.TopicsPerPage));

            // Decide whether to show pager or not
            if (pagedResults.TotalPages > 1)
            {
                litPager.Text = pagedResults.ReturnPager();
            }

            // Now bind
            rptTopicList.DataSource = pagedResults;
            rptTopicList.DataBind();
        }
        /// <summary>
        /// Gets the topics and returns them in a pager
        /// </summary>
        private void GetTopicPosts()
        {
            // Get the paging variable
            if (Request.QueryString["p"] != null)
                p = Convert.ToInt32(Request.QueryString["p"]);

            // Before anything see if the category has been marked as private, if so make sure user is loggged in
            var parentCategory = Mapper.MapForumCategory(new Node(ParentTopic.CategoryId));
            var userHasAccess = true;
            if (MembershipHelper.IsAuthenticated())
            {
                // Member is logged in so it doesn't matter if forum is private or not,
                // now check they have enough karma to view this category and hide if not
                if (CurrentMember.MemberKarmaAmount < parentCategory.KarmaAccessAmount)
                {
                    userHasAccess = false;
                }

                // check user has enough karma to be able to post in this category
                if (CurrentMember.MemberKarmaAmount < parentCategory.KarmaPostAmount)
                {
                    lvNewPost.Visible = false;
                }

            }
            else
            {
                if (parentCategory.IsPrivate)
                {
                    userHasAccess = false;
                }
            }
            // Check to see if user has access
            if (!userHasAccess)
            {
                Response.Redirect(string.Concat(Settings.Url, "?m=", library.GetDictionaryItem("NoPermissionToViewPage")));
            }

            //Get all the posts
            var useNodeFactory = Request.QueryString["nf"] != null;
            var topicposts = Factory.ReturnAllPostsInTopic(ParentTopic.Id, useNodeFactory);

            // Pass to my pager helper
            var pagedResults = new PaginatedList<ForumPost>(topicposts, p ?? 0, Convert.ToInt32(Settings.PostsPerPage));

            // Decide whether to show pager or not
            if (pagedResults.TotalPages > 1)
            {
                litPager.Text = pagedResults.ReturnPager();
            }

            // Now bind
            rptTopicPostList.DataSource = pagedResults;
            rptTopicPostList.DataBind();

            // Set the meta description
            var starterPost = Factory.ReturnTopicStarterPost(ParentTopic.Id);

            if (starterPost == null) return;

            var mDesc = Factory.ReturnTopicStarterPost(ParentTopic.Id).Content;
            var metaDescription = new HtmlMeta
                                      {
                                          Name = "description",
                                          Content = library.TruncateString(library.StripHtml(mDesc), 300, "...")
                                      };
            Page.Header.Controls.Add(metaDescription);
        }