/// <summary>
        /// Handles the Load event of the Page control.
        /// </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)
        {
            if (this.IsPostBack)
            {
                return;
            }

            var boardSettings = this.Get <YafBoardSettings>();

            this.PageLinks.AddLink(boardSettings.Name, YafBuildLink.GetLink(ForumPages.forum));
            this.PageLinks.AddLink(
                this.GetText("ADMIN_ADMIN", "Administration"), YafBuildLink.GetLink(ForumPages.admin_admin));
            this.PageLinks.AddLink(this.GetText("ADMIN_BOARDSETTINGS", "TITLE"), string.Empty);

            this.Page.Header.Title = "{0} - {1}".FormatWith(
                this.GetText("ADMIN_ADMIN", "Administration"), this.GetText("ADMIN_BOARDSETTINGS", "TITLE"));

            this.Save.Text = this.GetText("COMMON", "SAVE");

            // create list boxes by populating datasources from Data class
            var themeData = StaticDataHelper.Themes().AsEnumerable().Where(x => !x.Field <bool>("IsMobile"));

            if (themeData.Any())
            {
                this.Theme.DataSource     = themeData.CopyToDataTable();
                this.Theme.DataTextField  = "Theme";
                this.Theme.DataValueField = "FileName";
            }

            var mobileThemeData = StaticDataHelper.Themes().AsEnumerable().Where(x => x.Field <bool>("IsMobile"));

            if (mobileThemeData.Any())
            {
                var mobileThemes = mobileThemeData.CopyToDataTable();

                // Add Dummy Disabled Mobile Theme Item to allow disabling the Mobile Theme
                DataRow dr = mobileThemes.NewRow();
                dr["Theme"] = "[ {0} ]".FormatWith(this.GetText("ADMIN_COMMON", "DISABLED"));

                dr["FileName"] = string.Empty;
                dr["IsMobile"] = false;

                mobileThemes.Rows.InsertAt(dr, 0);

                this.MobileTheme.DataSource     = mobileThemes;
                this.MobileTheme.DataTextField  = "Theme";
                this.MobileTheme.DataValueField = "FileName";
            }

            this.Culture.DataSource =
                StaticDataHelper.Cultures()
                .AsEnumerable()
                .OrderBy(x => x.Field <string>("CultureNativeName"))
                .CopyToDataTable();

            this.Culture.DataTextField  = "CultureNativeName";
            this.Culture.DataValueField = "CultureTag";

            this.ShowTopic.DataSource     = StaticDataHelper.TopicTimes();
            this.ShowTopic.DataTextField  = "TopicText";
            this.ShowTopic.DataValueField = "TopicValue";

            this.FileExtensionAllow.DataSource     = StaticDataHelper.AllowDisallow();
            this.FileExtensionAllow.DataTextField  = "Text";
            this.FileExtensionAllow.DataValueField = "Value";

            this.JqueryUITheme.DataSource     = StaticDataHelper.JqueryUIThemes();
            this.JqueryUITheme.DataTextField  = "Theme";
            this.JqueryUITheme.DataValueField = "Theme";

            this.BindData();

            // bind poll group list
            var pollGroup =
                LegacyDb.PollGroupList(this.PageContext.PageUserID, null, this.PageContext.PageBoardID)
                .Distinct(new AreEqualFunc <TypedPollGroup>((v1, v2) => v1.PollGroupID == v2.PollGroupID))
                .ToList();

            pollGroup.Insert(0, new TypedPollGroup(string.Empty, -1));

            // TODO: vzrus needs some work, will be in polls only until feature is debugged there.
            this.PollGroupListDropDown.Items.AddRange(pollGroup.Select(x => new ListItem(x.Question, x.PollGroupID.ToString())).ToArray());

            // population default notification setting options...
            var items = EnumHelper.EnumToDictionary <UserNotificationSetting>();

            if (!boardSettings.AllowNotificationAllPostsAllTopics)
            {
                // remove it...
                items.Remove(UserNotificationSetting.AllTopics.ToInt());
            }

            var notificationItems =
                items.Select(x => new ListItem(HtmlHelper.StripHtml(this.GetText("CP_SUBSCRIPTIONS", x.Value)), x.Key.ToString())).ToArray();

            this.DefaultNotificationSetting.Items.AddRange(notificationItems);

            SetSelectedOnList(ref this.JqueryUITheme, boardSettings.JqueryUITheme);

            // Get first default full culture from a language file tag.
            string langFileCulture = StaticDataHelper.CultureDefaultFromFile(boardSettings.Language)
                                     ?? "en-US";

            SetSelectedOnList(ref this.Theme, boardSettings.Theme);
            SetSelectedOnList(ref this.MobileTheme, boardSettings.MobileTheme);

            // If 2-letter language code is the same we return Culture, else we return  a default full culture from language file

            /* SetSelectedOnList(
            *   ref this.Culture,
            *   langFileCulture.Substring(0, 2) == this.Get<YafBoardSettings>().Culture
            *     ? this.Get<YafBoardSettings>().Culture
            *     : langFileCulture);*/
            SetSelectedOnList(ref this.Culture, boardSettings.Culture);
            if (this.Culture.SelectedIndex == 0)
            {
                // If 2-letter language code is the same we return Culture, else we return  a default full culture from language file
                SetSelectedOnList(
                    ref this.Culture, langFileCulture.Substring(0, 2) == boardSettings.Culture ? boardSettings.Culture : langFileCulture);
            }

            SetSelectedOnList(ref this.ShowTopic, boardSettings.ShowTopicsDefault.ToString());
            SetSelectedOnList(
                ref this.FileExtensionAllow, boardSettings.FileExtensionAreAllowed ? "0" : "1");

            SetSelectedOnList(
                ref this.DefaultNotificationSetting,
                boardSettings.DefaultNotificationSetting.ToInt().ToString());

            this.NotificationOnUserRegisterEmailList.Text =
                boardSettings.NotificationOnUserRegisterEmailList;
            this.AllowThemedLogo.Checked = boardSettings.AllowThemedLogo;
            this.EmailModeratorsOnModeratedPost.Checked = boardSettings.EmailModeratorsOnModeratedPost;
            this.EmailModeratorsOnReportedPost.Checked  = boardSettings.EmailModeratorsOnReportedPost;
            this.AllowDigestEmail.Checked       = boardSettings.AllowDigestEmail;
            this.DefaultSendDigestEmail.Checked = boardSettings.DefaultSendDigestEmail;
            this.ForumEmail.Text       = boardSettings.ForumEmail;
            this.ForumBaseUrlMask.Text = boardSettings.BaseUrlMask;

            this.CopyrightRemovalKey.Text = boardSettings.CopyrightRemovalDomainKey;

            this.DigestSendEveryXHours.Text = boardSettings.DigestSendEveryXHours.ToString();

            if (boardSettings.BoardPollID > 0)
            {
                this.PollGroupListDropDown.SelectedValue = boardSettings.BoardPollID.ToString();
            }
            else
            {
                this.PollGroupListDropDown.SelectedIndex = 0;
            }

            this.PollGroupList.Visible = true;

            // Copyright Linkback Algorithm
            // Please keep if you haven't purchased a removal or commercial license.
            this.CopyrightHolder.Visible = true;
        }
示例#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={0}".FormatWith(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('{0}').click();return false;}}}} else {{return true}}; "
                    .FormatWith(this.forumSearchOK.ClientID);
            }

            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();
            }

            using (var dt = LegacyDb.forum_list(this.PageContext.PageBoardID, this.PageContext.PageForumID))
            {
                this._forum = dt.Rows[0];
            }

            if (this._forum["RemoteURL"] != DBNull.Value)
            {
                this.Response.Clear();
                this.Response.Redirect((string)this._forum["RemoteURL"]);
            }

            this._forumFlags = new ForumFlags(this._forum["Flags"]);

            this.PageTitle.Text = this._forum["Description"].ToString().IsSet()
                                      ? "{0} - <em>{1}</em>".FormatWith(
                this.HtmlEncode(this._forum["Name"]),
                this.HtmlEncode(this._forum["Description"]))
                                      : this.HtmlEncode(this._forum["Name"]);

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

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

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

            this.moderate1.Visible = false;
            this.moderate2.Visible = false;
        }
示例#3
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;
        }
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </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)
        {
            if (this.IsPostBack)
            {
                return;
            }

            var boardSettings = this.Get <BoardSettings>();

            this.CdvVersion.Text = boardSettings.CdvVersion.ToString();

            // create list boxes by populating data sources from Data class
            var themeData = StaticDataHelper.Themes();

            if (themeData.Any())
            {
                this.Theme.DataSource = themeData;
            }

            this.Culture.DataSource = StaticDataHelper.Cultures().AsEnumerable()
                                      .OrderBy(x => x.Field <string>("CultureNativeName")).CopyToDataTable();

            this.Culture.DataTextField  = "CultureNativeName";
            this.Culture.DataValueField = "CultureTag";

            this.ShowTopic.DataSource     = StaticDataHelper.TopicTimes();
            this.ShowTopic.DataTextField  = "TopicText";
            this.ShowTopic.DataValueField = "TopicValue";

            this.BindData();

            // bind poll group list
            var pollGroup = this.GetRepository <Poll>()
                            .PollGroupList(this.PageContext.PageUserID, null, this.PageContext.PageBoardID).Distinct(
                new AreEqualFunc <TypedPollGroup>((v1, v2) => v1.PollGroupID == v2.PollGroupID)).ToList();

            pollGroup.Insert(0, new TypedPollGroup(this.GetText("NONE"), -1));

            // TODO: vzrus needs some work, will be in polls only until feature is debugged there.
            this.PollGroupListDropDown.Items.AddRange(
                pollGroup.Select(x => new ListItem(x.Question, x.PollGroupID.ToString())).ToArray());

            // population default notification setting options...
            var items = EnumHelper.EnumToDictionary <UserNotificationSetting>();

            if (!boardSettings.AllowNotificationAllPostsAllTopics)
            {
                // remove it...
                items.Remove(UserNotificationSetting.AllTopics.ToInt());
            }

            var notificationItems = items.Select(
                x => new ListItem(
                    HtmlHelper.StripHtml(this.GetText("SUBSCRIPTIONS", x.Value)),
                    x.Key.ToString()))
                                    .ToArray();

            this.DefaultNotificationSetting.Items.AddRange(notificationItems);

            // Get first default full culture from a language file tag.
            var langFileCulture = StaticDataHelper.CultureDefaultFromFile(boardSettings.Language) ?? "en-US";

            if (boardSettings.Theme.Contains(".xml"))
            {
                SetSelectedOnList(ref this.Theme, "yaf");
            }
            else
            {
                SetSelectedOnList(ref this.Theme, boardSettings.Theme);
            }

            // If 2-letter language code is the same we return Culture, else we return  a default full culture from language file

            /* SetSelectedOnList(
            *   ref this.Culture,
            *   langFileCulture.Substring(0, 2) == this.Get<BoardSettings>().Culture
            *     ? this.Get<BoardSettings>().Culture
            *     : langFileCulture);*/
            SetSelectedOnList(ref this.Culture, boardSettings.Culture);
            if (this.Culture.SelectedIndex == 0)
            {
                // If 2-letter language code is the same we return Culture, else we return  a default full culture from language file
                SetSelectedOnList(
                    ref this.Culture,
                    langFileCulture.Substring(0, 2) == boardSettings.Culture ? boardSettings.Culture : langFileCulture);
            }

            SetSelectedOnList(ref this.ShowTopic, boardSettings.ShowTopicsDefault.ToString());
            SetSelectedOnList(
                ref this.DefaultNotificationSetting,
                boardSettings.DefaultNotificationSetting.ToInt().ToString());

            this.FileExtensionAllow.Checked = boardSettings.FileExtensionAreAllowed;

            this.NotificationOnUserRegisterEmailList.Text = boardSettings.NotificationOnUserRegisterEmailList;
            this.EmailModeratorsOnModeratedPost.Checked   = boardSettings.EmailModeratorsOnModeratedPost;
            this.EmailModeratorsOnReportedPost.Checked    = boardSettings.EmailModeratorsOnReportedPost;
            this.AllowDigestEmail.Checked       = boardSettings.AllowDigestEmail;
            this.DefaultSendDigestEmail.Checked = boardSettings.DefaultSendDigestEmail;
            this.ForumEmail.Text       = boardSettings.ForumEmail;
            this.ForumBaseUrlMask.Text = boardSettings.BaseUrlMask;

            var item = this.BoardLogo.Items.FindByText(boardSettings.ForumLogo);

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

            this.CopyrightRemovalKey.Text = boardSettings.CopyrightRemovalDomainKey;

            this.DigestSendEveryXHours.Text = boardSettings.DigestSendEveryXHours.ToString();

            if (boardSettings.BoardPollID > 0)
            {
                this.PollGroupListDropDown.SelectedValue = boardSettings.BoardPollID.ToString();
            }
            else
            {
                this.PollGroupListDropDown.SelectedIndex = 0;
            }

            this.PollGroupList.Visible = true;

            // Copyright Link-back Algorithm
            // Please keep if you haven't purchased a removal or commercial license.
            this.CopyrightHolder.Visible = true;

            // Render board Announcement

            // add items to the dropdown
            this.BoardAnnouncementUntilUnit.Items.Add(new ListItem(this.GetText("PROFILE", "MONTH"), "3"));
            this.BoardAnnouncementUntilUnit.Items.Add(new ListItem(this.GetText("PROFILE", "DAYS"), "1"));
            this.BoardAnnouncementUntilUnit.Items.Add(new ListItem(this.GetText("PROFILE", "HOURS"), "2"));

            // select hours
            this.BoardAnnouncementUntilUnit.SelectedIndex = 0;

            // default number of hours to suspend user for
            this.BoardAnnouncementUntil.Text = "1";

            if (boardSettings.BoardAnnouncement.IsNotSet())
            {
                return;
            }

            this.CurrentAnnouncement.Visible = true;
            this.CurrentMessage.Text         =
                $"{this.GetText("ANNOUNCEMENT_CURRENT")}:&nbsp;{boardSettings.BoardAnnouncementUntil}";
            this.BoardAnnouncementType.SelectedValue = boardSettings.BoardAnnouncementType;
            this.BoardAnnouncement.Text = boardSettings.BoardAnnouncement;
        }
示例#5
0
        /// <summary>
        /// Binds the data.
        /// </summary>
        private void BindData()
        {
            var board = this.GetRepository <Board>().GetById(this.PageContext.PageBoardID);

            using (var dt = new DataTable("Files"))
            {
                dt.Columns.Add("FileName", typeof(string));
                dt.Columns.Add("Description", typeof(string));

                var dr = dt.NewRow();
                dr["FileName"] =
                    BoardInfo.GetURLToContent("images/spacer.gif"); // use spacer.gif for Description Entry
                dr["Description"] = this.GetText("BOARD_LOGO_SELECT");
                dt.Rows.Add(dr);

                var dir = new DirectoryInfo(
                    this.Get <HttpRequestBase>()
                    .MapPath($"{BoardInfo.ForumServerFileRoot}{BoardFolders.Current.Logos}"));
                var files = dir.GetFiles("*.*");

                dt.AddImageFiles(files, BoardFolders.Current.Logos);

                this.BoardLogo.DataSource     = dt;
                this.BoardLogo.DataValueField = "FileName";
                this.BoardLogo.DataTextField  = "Description";
                this.BoardLogo.DataBind();
            }

            this.Name.Text = board.Name;

            var boardSettings = this.Get <BoardSettings>();

            this.CdvVersion.Text = boardSettings.CdvVersion.ToString();

            // create list boxes by populating data sources from Data class
            var themeData = StaticDataHelper.Themes();

            if (themeData.Any())
            {
                this.Theme.DataSource = themeData;
                this.Theme.DataBind();
            }

            this.Culture.DataSource = StaticDataHelper.Cultures().OrderBy(x => x.CultureNativeName);

            this.Culture.DataTextField  = "CultureNativeName";
            this.Culture.DataValueField = "CultureTag";
            this.Culture.DataBind();

            this.ShowTopic.DataSource     = StaticDataHelper.TopicTimes();
            this.ShowTopic.DataTextField  = "Name";
            this.ShowTopic.DataValueField = "Value";
            this.ShowTopic.DataBind();

            // population default notification setting options...
            var items = EnumHelper.EnumToDictionary <UserNotificationSetting>();

            if (!boardSettings.AllowNotificationAllPostsAllTopics)
            {
                // remove it...
                items.Remove(UserNotificationSetting.AllTopics.ToInt());
            }

            var notificationItems = items.Select(
                x => new ListItem(
                    HtmlHelper.StripHtml(this.GetText("SUBSCRIPTIONS", x.Value)),
                    x.Key.ToString()))
                                    .ToArray();

            this.DefaultNotificationSetting.Items.AddRange(notificationItems);

            // Get first default full culture from a language file tag.
            var langFileCulture = StaticDataHelper.CultureDefaultFromFile(boardSettings.Language) ?? "en-US";

            if (boardSettings.Theme.Contains(".xml"))
            {
                SetSelectedOnList(ref this.Theme, "yaf");
            }
            else
            {
                SetSelectedOnList(ref this.Theme, boardSettings.Theme);
            }

            SetSelectedOnList(ref this.Culture, boardSettings.Culture);
            if (this.Culture.SelectedIndex == 0)
            {
                // If 2-letter language code is the same we return Culture, else we return  a default full culture from language file
                SetSelectedOnList(
                    ref this.Culture,
                    langFileCulture.Substring(0, 2) == boardSettings.Culture ? boardSettings.Culture : langFileCulture);
            }

            SetSelectedOnList(ref this.ShowTopic, boardSettings.ShowTopicsDefault.ToString());
            SetSelectedOnList(
                ref this.DefaultNotificationSetting,
                boardSettings.DefaultNotificationSetting.ToInt().ToString());

            this.NotificationOnUserRegisterEmailList.Text = boardSettings.NotificationOnUserRegisterEmailList;
            this.EmailModeratorsOnModeratedPost.Checked   = boardSettings.EmailModeratorsOnModeratedPost;
            this.EmailModeratorsOnReportedPost.Checked    = boardSettings.EmailModeratorsOnReportedPost;
            this.AllowDigestEmail.Checked       = boardSettings.AllowDigestEmail;
            this.DefaultSendDigestEmail.Checked = boardSettings.DefaultSendDigestEmail;
            this.ForumEmail.Text       = boardSettings.ForumEmail;
            this.ForumBaseUrlMask.Text = boardSettings.BaseUrlMask;

            var item = this.BoardLogo.Items.FindByText(boardSettings.ForumLogo);

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

            this.CopyrightRemovalKey.Text = boardSettings.CopyrightRemovalDomainKey;

            this.DigestSendEveryXHours.Text = boardSettings.DigestSendEveryXHours.ToString();

            // Copyright Link-back Algorithm
            // Please keep if you haven't purchased a removal or commercial license.
            this.CopyrightHolder.Visible = true;
        }
示例#6
0
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Page_Load([NotNull] object sender, [NotNull] EventArgs e)
        {
            if (!this.IsPostBack)
            {
                this.PageLinks.AddLink(this.PageContext.BoardSettings.Name, YafBuildLink.GetLink(ForumPages.forum));
                this.PageLinks.AddLink("Administration", YafBuildLink.GetLink(ForumPages.admin_admin));
                this.PageLinks.AddLink("Board Settings", string.Empty);

                // create list boxes by populating datasources from Data class
                var themeData = StaticDataHelper.Themes().AsEnumerable().Where(x => !x.Field <bool>("IsMobile"));

                if (themeData.Any())
                {
                    this.Theme.DataSource     = themeData.CopyToDataTable();
                    this.Theme.DataTextField  = "Theme";
                    this.Theme.DataValueField = "FileName";
                }

                var mobileThemeData = StaticDataHelper.Themes().AsEnumerable().Where(x => x.Field <bool>("IsMobile"));

                if (mobileThemeData.Any())
                {
                    this.MobileTheme.DataSource     = mobileThemeData.CopyToDataTable();
                    this.MobileTheme.DataTextField  = "Theme";
                    this.MobileTheme.DataValueField = "FileName";
                }

                this.Culture.DataSource =
                    StaticDataHelper.Cultures().AsEnumerable().OrderBy(x => x.Field <string>("CultureNativeName")).CopyToDataTable(
                        );
                this.Culture.DataTextField  = "CultureNativeName";
                this.Culture.DataValueField = "CultureTag";

                this.ShowTopic.DataSource     = StaticDataHelper.TopicTimes();
                this.ShowTopic.DataTextField  = "TopicText";
                this.ShowTopic.DataValueField = "TopicValue";

                this.FileExtensionAllow.DataSource     = StaticDataHelper.AllowDisallow();
                this.FileExtensionAllow.DataTextField  = "Text";
                this.FileExtensionAllow.DataValueField = "Value";

                this.BindData();

                // bind poll group list
                var pollGroup =
                    DB.PollGroupList(this.PageContext.PageUserID, null, this.PageContext.PageBoardID).Distinct(
                        new AreEqualFunc <TypedPollGroup>((v1, v2) => v1.PollGroupID == v2.PollGroupID)).ToList();

                pollGroup.Insert(0, new TypedPollGroup(String.Empty, -1));

                // TODO: vzrus needs some work, will be in polls only until feature is debugged there.
                this.PollGroupListDropDown.Items.AddRange(
                    pollGroup.Select(x => new ListItem(x.Question, x.PollGroupID.ToString())).ToArray());

                // population default notification setting options...
                var items = EnumHelper.EnumToDictionary <UserNotificationSetting>();

                if (!this.PageContext.BoardSettings.AllowNotificationAllPostsAllTopics)
                {
                    // remove it...
                    items.Remove(UserNotificationSetting.AllTopics.ToInt());
                }

                var notificationItems =
                    items.Select(
                        x =>
                        new ListItem(
                            HtmlHelper.StripHtml(this.PageContext.Localization.GetText("CP_SUBSCRIPTIONS", x.Value)), x.Key.ToString()))
                    .ToArray();

                this.DefaultNotificationSetting.Items.AddRange(notificationItems);

                // Get first default full culture from a language file tag.
                string langFileCulture = StaticDataHelper.CultureDefaultFromFile(this.PageContext.BoardSettings.Language) ??
                                         "en";

                SetSelectedOnList(ref this.Theme, this.PageContext.BoardSettings.Theme);
                SetSelectedOnList(ref this.MobileTheme, this.PageContext.BoardSettings.MobileTheme);

                // If 2-letter language code is the same we return Culture, else we return  a default full culture from language file
                SetSelectedOnList(
                    ref this.Culture,
                    langFileCulture.Substring(0, 2) == this.PageContext.BoardSettings.Culture
            ? this.PageContext.BoardSettings.Culture
            : langFileCulture);

                SetSelectedOnList(ref this.ShowTopic, this.PageContext.BoardSettings.ShowTopicsDefault.ToString());
                SetSelectedOnList(
                    ref this.FileExtensionAllow, this.PageContext.BoardSettings.FileExtensionAreAllowed ? "0" : "1");

                SetSelectedOnList(
                    ref this.DefaultNotificationSetting,
                    this.PageContext.BoardSettings.DefaultNotificationSetting.ToInt().ToString());

                this.NotificationOnUserRegisterEmailList.Text =
                    this.PageContext.BoardSettings.NotificationOnUserRegisterEmailList;
                this.AllowThemedLogo.Checked = this.PageContext.BoardSettings.AllowThemedLogo;
                this.EmailModeratorsOnModeratedPost.Checked = this.PageContext.BoardSettings.EmailModeratorsOnModeratedPost;
                this.AllowDigestEmail.Checked       = this.PageContext.BoardSettings.AllowDigestEmail;
                this.DefaultSendDigestEmail.Checked = this.PageContext.BoardSettings.DefaultSendDigestEmail;

                if (this.PageContext.BoardSettings.BoardPollID > 0)
                {
                    this.PollGroupListDropDown.SelectedValue = this.PageContext.BoardSettings.BoardPollID.ToString();
                }
                else
                {
                    this.PollGroupListDropDown.SelectedIndex = 0;
                }

                this.PollGroupList.Visible = true;
            }
        }
示例#7
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.Get<HttpRequestBase>().QueryString.GetFirstOrDefault("f")}";

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

            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,
                        BuildLink.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 <ISession>().ShowList == -1
                                                  ? this.Get <BoardSettings>().ShowTopicsDefault
                                                  : this.Get <ISession>().ShowList;

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

                this.NewTopic1.NavigateUrl     =
                    this.NewTopic2.NavigateUrl =
                        BuildLink.GetLinkNotEscaped(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;
        }
示例#8
0
        /// <summary>
        /// The page_ load.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected void Page_Load(object sender, EventArgs e)
        {
            YafContext.Current.Get <YafSession>().UnreadTopics = 0;
            this.AtomFeed.AdditionalParameters = "f={0}".FormatWith(this.Request.QueryString.GetFirstOrDefault("f"));
            this.RssFeed.AdditionalParameters  = "f={0}".FormatWith(this.Request.QueryString.GetFirstOrDefault("f"));
            this.MarkRead.Text           = GetText("MARKREAD");
            this.ForumJumpHolder.Visible = PageContext.BoardSettings.ShowForumJump && PageContext.Settings.LockedForum == 0;
            this.lastPostImageTT         = this.PageContext.Localization.GetText("DEFAULT", "GO_LAST_POST");

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

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

                this.ShowList.DataSource     = StaticDataHelper.TopicTimes();
                this.ShowList.DataTextField  = "TopicText";
                this.ShowList.DataValueField = "TopicValue";
                this._showTopicListSelected  = (YafContext.Current.Get <YafSession>().ShowList == -1) ? PageContext.BoardSettings.ShowTopicsDefault : YafContext.Current.Get <YafSession>().ShowList;

                HandleWatchForum();
            }

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

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

            using (DataTable dt = DB.forum_list(PageContext.PageBoardID, PageContext.PageForumID))
            {
                this._forum = dt.Rows[0];
            }

            if (this._forum["RemoteURL"] != DBNull.Value)
            {
                Response.Clear();
                Response.Redirect((string)this._forum["RemoteURL"]);
            }

            this._forumFlags = new ForumFlags(this._forum["Flags"]);

            this.PageTitle.Text = HtmlEncode((string)this._forum["Name"]);

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

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

            if (!PageContext.ForumModeratorAccess)
            {
                this.moderate1.Visible = false;
                this.moderate2.Visible = false;
            }
        }