Exemple #1
0
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            this.Get <ISession>().UnreadTopics = 0;

            this.RssFeed.AdditionalParameters =
                $"f={this.PageContext.PageForumID}&name={this.PageContext.PageForumName}";

            this.ForumJumpHolder.Visible = this.PageContext.BoardSettings.ShowForumJump &&
                                           this.PageContext.Settings.LockedForum == 0;

            if (this.ForumSearchHolder.Visible)
            {
                this.forumSearch.Attributes.Add(
                    "onkeydown",
                    JavaScriptBlocks.ClickOnEnterJs(this.forumSearchOK.ClientID));
            }

            if (!this.IsPostBack)
            {
                this.ShowList.DataSource     = StaticDataHelper.TopicTimes();
                this.ShowList.DataTextField  = "Name";
                this.ShowList.DataValueField = "Value";
                this.showTopicListSelected   = this.Get <ISession>().ShowList == -1
                                                  ? this.PageContext.BoardSettings.ShowTopicsDefault
                                                  : this.Get <ISession>().ShowList;

                this.moderate1.NavigateUrl     =
                    this.moderate2.NavigateUrl =
                        BuildLink.GetLink(ForumPages.Moderate_Forums, "f={0}", this.PageContext.PageForumID);

                this.NewTopic1.NavigateUrl     =
                    this.NewTopic2.NavigateUrl =
                        BuildLink.GetLink(ForumPages.PostTopic, "f={0}", this.PageContext.PageForumID);

                this.HandleWatchForum();
            }

            if (!this.Get <HttpRequestBase>().QueryString.Exists("f"))
            {
                BuildLink.AccessDenied();
            }

            if (this.PageContext.IsGuest && !this.PageContext.ForumReadAccess)
            {
                // attempt to get permission by redirecting to login...
                this.Get <IPermissions>().HandleRequest(ViewPermissions.RegisteredUsers);
            }
            else if (!this.PageContext.ForumReadAccess)
            {
                BuildLink.AccessDenied();
            }

            this.forum = this.GetRepository <Forum>().GetById(this.PageContext.PageForumID);

            if (this.forum.RemoteURL.IsSet())
            {
                this.Get <HttpResponseBase>().Clear();
                this.Get <HttpResponseBase>().Redirect(this.forum.RemoteURL);
            }

            this.PageTitle.Text = this.forum.Description.IsSet()
                                      ? $"{this.HtmlEncode(this.forum.Name)} - <em>{this.HtmlEncode(this.forum.Description)}</em>"
                                      : this.HtmlEncode(this.forum.Name);

            this.BindData(); // Always because of yaf:TopicLine

            if (!this.PageContext.ForumPostAccess ||
                this.forum.ForumFlags.IsLocked && !this.PageContext.ForumModeratorAccess)
            {
                this.NewTopic1.Visible = false;
                this.NewTopic2.Visible = false;
            }

            if (this.PageContext.IsGuest)
            {
                this.WatchForum.Visible = false;
                this.MarkRead.Visible   = false;
            }

            if (this.PageContext.ForumModeratorAccess)
            {
                return;
            }

            this.moderate1.Visible = false;
            this.moderate2.Visible = false;
        }
Exemple #2
0
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            this.Get <IYafSession>().UnreadTopics = 0;

            this.RssFeed.AdditionalParameters = $"f={this.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("f")}";

            this.ForumJumpHolder.Visible = this.Get <YafBoardSettings>().ShowForumJump &&
                                           this.PageContext.Settings.LockedForum == 0;

            this.LastPostImageTT = this.GetText("DEFAULT", "GO_LAST_POST");

            if (this.ForumSearchHolder.Visible)
            {
                this.forumSearch.Attributes["onkeydown"] =
                    $"if(event.which || event.keyCode){{if ((event.which == 13) || (event.keyCode == 13)) {{document.getElementById('{this.forumSearchOK.ClientID}').click();return false;}}}} else {{return true}}; ";
            }

            if (!this.IsPostBack)
            {
                // PageLinks.Clear();
                if (this.PageContext.Settings.LockedForum == 0)
                {
                    this.PageLinks.AddRoot();
                    this.PageLinks.AddLink(
                        this.PageContext.PageCategoryName,
                        YafBuildLink.GetLink(ForumPages.forum, "c={0}", this.PageContext.PageCategoryID));
                }

                this.PageLinks.AddForum(this.PageContext.PageForumID, true);

                this.ShowList.DataSource     = StaticDataHelper.TopicTimes();
                this.ShowList.DataTextField  = "TopicText";
                this.ShowList.DataValueField = "TopicValue";
                this.showTopicListSelected   = this.Get <IYafSession>().ShowList == -1
                                                  ? this.Get <YafBoardSettings>().ShowTopicsDefault
                                                  : this.Get <IYafSession>().ShowList;

                this.moderate1.NavigateUrl     =
                    this.moderate2.NavigateUrl =
                        YafBuildLink.GetLinkNotEscaped(ForumPages.moderating, "f={0}", this.PageContext.PageForumID);

                this.NewTopic1.NavigateUrl     =
                    this.NewTopic2.NavigateUrl =
                        YafBuildLink.GetLinkNotEscaped(ForumPages.postmessage, "f={0}", this.PageContext.PageForumID);

                this.HandleWatchForum();
            }

            if (this.Request.QueryString.GetFirstOrDefault("f") == null)
            {
                YafBuildLink.AccessDenied();
            }

            if (this.PageContext.IsGuest && !this.PageContext.ForumReadAccess)
            {
                // attempt to get permission by redirecting to login...
                this.Get <IPermissions>().HandleRequest(ViewPermissions.RegisteredUsers);
            }
            else if (!this.PageContext.ForumReadAccess)
            {
                YafBuildLink.AccessDenied();
            }

            var dt = this.GetRepository <Forum>().List(
                this.PageContext.PageBoardID,
                this.PageContext.PageForumID);

            this.forum = dt.FirstOrDefault();

            if (this.forum.RemoteURL.IsSet())
            {
                this.Response.Clear();
                this.Response.Redirect(this.forum.RemoteURL);
            }

            this.PageTitle.Text = this.forum.Description.IsSet()
                                      ? $"{this.HtmlEncode(this.forum.Name)} - <em>{this.HtmlEncode(this.forum.Description)}</em>"
                                      : this.HtmlEncode(this.forum.Name);

            this.BindData(); // Always because of yaf:TopicLine

            if (!this.PageContext.ForumPostAccess ||
                this.forum.ForumFlags.IsLocked && !this.PageContext.ForumModeratorAccess)
            {
                this.NewTopic1.Visible = false;
                this.NewTopic2.Visible = false;
            }

            if (this.PageContext.IsGuest)
            {
                this.WatchForum.Visible = false;
                this.MarkRead.Visible   = false;
            }

            if (this.PageContext.ForumModeratorAccess)
            {
                return;
            }

            this.moderate1.Visible = false;
            this.moderate2.Visible = false;
        }