Beispiel #1
0
        private void PagerLinkClick(object sender, EventArgs e)
        {
            var lnk = sender as LinkButton;

            if (lnk != null)
            {
                if (lnk.Text.IsNumeric())
                {
                    CurrentPage = int.Parse(lnk.Text) - 1;
                }
                else
                {
                    if (lnk.Text.Contains(">"))
                    {
                        CurrentPage += 1;
                    }
                    else if (lnk.Text.Contains("<"))
                    {
                        CurrentPage -= 1;
                    }
                    else if (lnk.Text.Contains("»"))
                    {
                        CurrentPage = ReplyPager.PageCount - 1;
                    }
                    else
                    {
                        CurrentPage = 0;
                    }
                }
                if (CurrentPage < 0)
                {
                    CurrentPage = 0;
                }
                if (CurrentPage >= ReplyPager.PageCount)
                {
                    CurrentPage = ReplyPager.PageCount - 1;
                }
            }
            SnitzCookie.TrackIt(_topic.Id, CurrentPage);
            ReplyPager.CurrentIndex = CurrentPage;
        }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (CurrentPage == -1)
            {
                CurrentPage = 0;
            }


            if (Request.Form["__EVENTTARGET"] != null)
            {
                //let's check what async call posted back and see if we need to refresh the page
                string target        = Request.Form["__EVENTTARGET"];
                var    listOfStrings = new List <string> {
                    "TopicSend", "DeleteTopic", "DeleteReply"
                };
                bool refreshAfterPostback = listOfStrings.Any(target.EndsWith);
                if (refreshAfterPostback)
                {
                    ReplyPager.CurrentIndex = CurrentPage;
                }
            }

            if (!Page.IsPostBack)
            {
                TopicInfo topic   = _topic;
                string    session = "FORUM" + topic.ForumId;

                if (IsAuthenticated)
                {
                    //do we have access to this forum
                    if (!Forums.IsUserInForumRole(Member.Username, topic.Forum.Id))
                    {
                        if (Session[session] == null || Session[session].ToString() != "true")
                        {
                            if (topic.Forum.Password != null &&
                                !String.IsNullOrEmpty(topic.Forum.Password.Trim()))
                            {
                                if (Session[session] == null || Session[session].ToString() == "")
                                {
                                    Response.Redirect("~/Content/Forums/forum.aspx?FORUM=" + topic.ForumId);
                                }
                                else
                                {
                                    if (Session[session].ToString() != "true")
                                    {
                                        throw new SecurityException("You are not authorised to view this forum");
                                    }
                                }
                            }
                        }
                        if (topic.Forum.Roles.Contains("All") || topic.Forum.Roles.Count == 0)
                        {
                            if (String.IsNullOrEmpty(topic.Forum.Password))
                            {
                                WriteShareItScriptTags();
                            }
                        }
                    }
                    else
                    {
                        Session[session] = "true";
                    }
                }
                else if (topic.Forum.Roles.Contains("All") || topic.Forum.Roles.Count == 0)
                {
                    Session[session] = "true";
                    WriteShareItScriptTags();
                }
                else if (topic.Forum.Roles.Count > 0 && !topic.Forum.Roles.Contains("All"))
                {
                    if (Session[session] == null || Session[session].ToString() != "true")
                    {
                        throw new SecurityException("You must be logged in to view this forum");
                    }
                }

                Topics.UpdateViewCount(_topic.Id);
                int pagejump = 0;

                if (Request.QueryString["LastVisit"] != null)
                {
                    pagejump = SnitzCookie.LastTopicPage(topic.Id);
                }
                if (pagejump == 0)
                {
                    if ((Request.Params["whichpage"] != null))
                    {
                        pagejump = Int32.Parse(Request.Params["whichpage"]);
                    }
                }
                if (pagejump != 0)
                {
                    if (pagejump == -1)
                    {
                        //jump to last page
                        int pagenum = topic.ReplyCount / Config.TopicPageSize;
                        if (topic.ReplyCount % Config.TopicPageSize == 0)
                        {
                            if (topic.ReplyCount > 0)
                            {
                                pagenum -= 1;
                            }
                        }
                        CurrentPage             = pagenum;
                        ReplyPager.CurrentIndex = pagenum;
                    }
                    else
                    {
                        int pagenum = pagejump - 1;
                        CurrentPage             = pagenum;
                        ReplyPager.CurrentIndex = pagenum;
                    }
                }
                else
                {
                    ReplyPager.CurrentIndex = CurrentPage;
                }
                SnitzCookie.TrackIt(_topic.Id, CurrentPage);
            }

            //TopicView.Visible = ReplyPager.CurrentIndex == 0;

            if (Request.Params["reply"] != null)
            {
                string reply = Request.Params["reply"];
                if (reply != "0")
                {
                    JumpToReply(reply);
                }
            }
        }